diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 42cb38ab746..c28f38cad8e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -86,6 +86,7 @@ "packages/google-cloud-redis": "3.1.5", "packages/google-cloud-resourcemanager": "4.1.3", "packages/google-cloud-resourcesettings": "2.0.3", + "packages/google-cloud-retail": "2.1.1", "packages/google-cloud-scheduler": "3.0.5", "packages/google-cloud-secretmanager": "4.1.4", "packages/google-cloud-security-privateca": "4.1.2", diff --git a/packages/google-cloud-retail/.OwlBot.yaml b/packages/google-cloud-retail/.OwlBot.yaml new file mode 100644 index 00000000000..a83221d6d9e --- /dev/null +++ b/packages/google-cloud-retail/.OwlBot.yaml @@ -0,0 +1,21 @@ +# 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/cloud/retail/(.*)/.*-nodejs + dest: /owl-bot-staging/google-cloud-retail/$1 + diff --git a/packages/google-cloud-retail/.eslintignore b/packages/google-cloud-retail/.eslintignore new file mode 100644 index 00000000000..ea5b04aebe6 --- /dev/null +++ b/packages/google-cloud-retail/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ +samples/generated/ diff --git a/packages/google-cloud-retail/.eslintrc.json b/packages/google-cloud-retail/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/packages/google-cloud-retail/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/packages/google-cloud-retail/.gitattributes b/packages/google-cloud-retail/.gitattributes new file mode 100644 index 00000000000..33739cb74e4 --- /dev/null +++ b/packages/google-cloud-retail/.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/packages/google-cloud-retail/.gitignore b/packages/google-cloud-retail/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/packages/google-cloud-retail/.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/packages/google-cloud-retail/.jsdoc.js b/packages/google-cloud-retail/.jsdoc.js new file mode 100644 index 00000000000..1972981017b --- /dev/null +++ b/packages/google-cloud-retail/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/packages/google-cloud-retail/.mocharc.js b/packages/google-cloud-retail/.mocharc.js new file mode 100644 index 00000000000..cdb7b752160 --- /dev/null +++ b/packages/google-cloud-retail/.mocharc.js @@ -0,0 +1,29 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +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/packages/google-cloud-retail/.nycrc b/packages/google-cloud-retail/.nycrc new file mode 100644 index 00000000000..b18d5472b62 --- /dev/null +++ b/packages/google-cloud-retail/.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/packages/google-cloud-retail/.prettierignore b/packages/google-cloud-retail/.prettierignore new file mode 100644 index 00000000000..9340ad9b86d --- /dev/null +++ b/packages/google-cloud-retail/.prettierignore @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ diff --git a/packages/google-cloud-retail/.prettierrc.js b/packages/google-cloud-retail/.prettierrc.js new file mode 100644 index 00000000000..d546a4ad546 --- /dev/null +++ b/packages/google-cloud-retail/.prettierrc.js @@ -0,0 +1,17 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/packages/google-cloud-retail/.repo-metadata.json b/packages/google-cloud-retail/.repo-metadata.json new file mode 100644 index 00000000000..22035054335 --- /dev/null +++ b/packages/google-cloud-retail/.repo-metadata.json @@ -0,0 +1,17 @@ +{ + "client_documentation": "https://cloud.google.com/nodejs/docs/reference/retail/latest", + "api_id": "retail.googleapis.com", + "distribution_name": "@google-cloud/retail", + "release_level": "stable", + "default_version": "v2beta", + "language": "nodejs", + "name_pretty": "Retail API", + "repo": "googleapis/google-cloud-node", + "product_documentation": "https://cloud.google.com/recommendations/", + "requires_billing": true, + "name": "retail", + "issue_tracker": "https://github.com/googleapis/google-cloud-node/issues", + "api_shortname": "retail", + "library_type": "GAPIC_AUTO", + "codeowner_team": "@googleapis/cloud-retail-team" +} diff --git a/packages/google-cloud-retail/CHANGELOG.md b/packages/google-cloud-retail/CHANGELOG.md new file mode 100644 index 00000000000..cfd45fa220e --- /dev/null +++ b/packages/google-cloud-retail/CHANGELOG.md @@ -0,0 +1,227 @@ +# Changelog + +## [2.1.1](https://github.com/googleapis/nodejs-retail/compare/v2.1.0...v2.1.1) (2022-11-16) + + +### Bug Fixes + +* **deps:** Use google-gax v3.5.2 ([#221](https://github.com/googleapis/nodejs-retail/issues/221)) ([5eb17fc](https://github.com/googleapis/nodejs-retail/commit/5eb17fc9c340cacbb8627442c58597015a2d4134)) + +## [2.1.0](https://github.com/googleapis/nodejs-retail/compare/v2.0.0...v2.1.0) (2022-09-20) + + +### Features + +* add local inventories info to the Product resource ([166a195](https://github.com/googleapis/nodejs-retail/commit/166a195d3d8b2d858418a6058ee72c5dd9036463)) +* allow adding labels in search requests ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow adding labels in search requests ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow disabling spell check in search requests ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow disabling spell check in search requests ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow enabling recommendation filtering on custom attributes ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow enabling recommendation filtering on custom attributes ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow returning min/max values on search numeric facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow returning min/max values on search numeric facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow skiping default branch protection when doing product full import ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow to return min/max values on search numeric facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow to use serving configs as an alias of placements ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow using serving configs as an alias of placements ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* allow using serving configs as an alias of placements ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* Model Services, BatchRemoveCatalogAttributes, ExactSearchableOption ([be33b58](https://github.com/googleapis/nodejs-retail/commit/be33b5817ce85ca245fc08a9598c7c1b48cb84fc)) +* new model service to manage recommendation models ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* release AttributesConfig APIs to v2 version ([166a195](https://github.com/googleapis/nodejs-retail/commit/166a195d3d8b2d858418a6058ee72c5dd9036463)) +* release CompletionConfig APIs to v2 version ([166a195](https://github.com/googleapis/nodejs-retail/commit/166a195d3d8b2d858418a6058ee72c5dd9036463)) +* release Control and ServingConfig serivces to v2 version ([166a195](https://github.com/googleapis/nodejs-retail/commit/166a195d3d8b2d858418a6058ee72c5dd9036463)) +* return output BigQuery table on product / event export response ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* return output BigQuery table on product / event export response ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* support case insensitive match on search facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* support case insensitive match on search facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* support case insensitive match on search facets ([b20cb74](https://github.com/googleapis/nodejs-retail/commit/b20cb7417e6e8daf3745d75224b2ea87a21680a1)) +* Support regapic LRO ([c074f6c](https://github.com/googleapis/nodejs-retail/commit/c074f6c8125d16e375c6c0bc8bae6b2e84ed56f9)) + + +### Bug Fixes + +* Allow passing gax instance to client constructor ([#206](https://github.com/googleapis/nodejs-retail/issues/206)) ([166a195](https://github.com/googleapis/nodejs-retail/commit/166a195d3d8b2d858418a6058ee72c5dd9036463)) +* Better support for fallback mode ([#204](https://github.com/googleapis/nodejs-retail/issues/204)) ([4256e26](https://github.com/googleapis/nodejs-retail/commit/4256e2690e9d66a9083a13962b8f9f706e4db710)) +* Change import long to require ([#205](https://github.com/googleapis/nodejs-retail/issues/205)) ([9acff3d](https://github.com/googleapis/nodejs-retail/commit/9acff3daf2571f5a087f85882ed50b23be52d4e8)) +* **deps:** Update dependency @google-cloud/storage to v6 ([#185](https://github.com/googleapis/nodejs-retail/issues/185)) ([d0e7c2f](https://github.com/googleapis/nodejs-retail/commit/d0e7c2fdd9306c8b162a4b1bd676937f60bcd1cb)) +* Do not import the whole google-gax from proto JS ([#1553](https://github.com/googleapis/nodejs-retail/issues/1553)) ([#208](https://github.com/googleapis/nodejs-retail/issues/208)) ([a079b82](https://github.com/googleapis/nodejs-retail/commit/a079b82805b9550d9a7772ec620d70e5d28bc5a2)) +* Remove pip install statements ([#1546](https://github.com/googleapis/nodejs-retail/issues/1546)) ([#207](https://github.com/googleapis/nodejs-retail/issues/207)) ([b742392](https://github.com/googleapis/nodejs-retail/commit/b7423929a30f635880eff37f479f95498cbfcde5)) +* use google-gax v3.3.0 ([a079b82](https://github.com/googleapis/nodejs-retail/commit/a079b82805b9550d9a7772ec620d70e5d28bc5a2)) + +## [2.0.0](https://github.com/googleapis/nodejs-retail/compare/v1.8.1...v2.0.0) (2022-06-20) + + +### ⚠ BREAKING CHANGES + +* update library to use Node 12 (#181) + +### Features + +* allow users to disable spell check in search requests ([#183](https://github.com/googleapis/nodejs-retail/issues/183)) ([05005ea](https://github.com/googleapis/nodejs-retail/commit/05005ea09accff4d04b152f2fa2bf452f6b9768b)) + + +### Bug Fixes + +* **deps:** update dependency @google-cloud/bigquery to v6 ([#186](https://github.com/googleapis/nodejs-retail/issues/186)) ([fc07923](https://github.com/googleapis/nodejs-retail/commit/fc0792311aac235e917fe045fc491858408bd770)) + + +### Build System + +* update library to use Node 12 ([#181](https://github.com/googleapis/nodejs-retail/issues/181)) ([809853f](https://github.com/googleapis/nodejs-retail/commit/809853f84e0bfe0f09ccb59ca750963732e23965)) + +### [1.8.1](https://github.com/googleapis/nodejs-retail/compare/v1.8.0...v1.8.1) (2022-05-06) + + +### Bug Fixes + +* read projectId from retailClient.getProjectId ([#159](https://github.com/googleapis/nodejs-retail/issues/159)) ([f4fa61c](https://github.com/googleapis/nodejs-retail/commit/f4fa61c2a385b197dd0cfd923b1ac1d07d6539de)) + +## [1.8.0](https://github.com/googleapis/nodejs-retail/compare/v1.7.0...v1.8.0) (2022-04-08) + + +### Features + +* allow search users to skip validation for invalid boost specs (v2alpha) ([3c6ffc1](https://github.com/googleapis/nodejs-retail/commit/3c6ffc1d6fee7095213824d45c3ca5bb0f974a1b)) +* Retail Tutorials. If create BQ table is requested, check if it exists and remove before creation ([#157](https://github.com/googleapis/nodejs-retail/issues/157)) ([349e171](https://github.com/googleapis/nodejs-retail/commit/349e171baacff751044665389e92e67f02ebc22c)) +* search returns applied control ids in the response (v2alpha) ([3c6ffc1](https://github.com/googleapis/nodejs-retail/commit/3c6ffc1d6fee7095213824d45c3ca5bb0f974a1b)) +* support batch products purge (v2alpha) ([#167](https://github.com/googleapis/nodejs-retail/issues/167)) ([3c6ffc1](https://github.com/googleapis/nodejs-retail/commit/3c6ffc1d6fee7095213824d45c3ca5bb0f974a1b)) +* support search personalization (v2alpha) ([3c6ffc1](https://github.com/googleapis/nodejs-retail/commit/3c6ffc1d6fee7095213824d45c3ca5bb0f974a1b)) +* users cannot switch to empty default branch unless force override (v2alpha) ([3c6ffc1](https://github.com/googleapis/nodejs-retail/commit/3c6ffc1d6fee7095213824d45c3ca5bb0f974a1b)) + +## [1.7.0](https://github.com/googleapis/nodejs-retail/compare/v1.6.1...v1.7.0) (2022-04-01) + + +### Features + +* users can skip validation, search personalization, return ids, and more; docs: suggest search users to not send IP, deprecate request_id, and more ([#160](https://github.com/googleapis/nodejs-retail/issues/160)) ([c793285](https://github.com/googleapis/nodejs-retail/commit/c7932857fc2326971041564094bb4b75802fc741)) + +### [1.6.1](https://github.com/googleapis/nodejs-retail/compare/v1.6.0...v1.6.1) (2022-03-15) + + +### Bug Fixes + +* remove gcloud_project env variable ([#156](https://github.com/googleapis/nodejs-retail/issues/156)) ([16cefb4](https://github.com/googleapis/nodejs-retail/commit/16cefb46e213f094daca8121bb09ec1e5c4da206)) + +## [1.6.0](https://github.com/googleapis/nodejs-retail/compare/v1.5.0...v1.6.0) (2022-02-15) + + +### Features + +* add ControlService ([92d4d84](https://github.com/googleapis/nodejs-retail/commit/92d4d849b9c4093778cf81bd56e8ebc2d6afd98b)) +* add ServingConfigService ([92d4d84](https://github.com/googleapis/nodejs-retail/commit/92d4d849b9c4093778cf81bd56e8ebc2d6afd98b)) + +## [1.5.0](https://www.github.com/googleapis/nodejs-retail/compare/v1.4.0...v1.5.0) (2021-11-23) + + +### Features + +* update grpc service config settings to reflect correct API deadlines ([0f24f0e](https://www.github.com/googleapis/nodejs-retail/commit/0f24f0e42c0cb3430935487fe6569873cfdb6860)) +* update grpc service config settings to reflect correct API deadlines ([#117](https://www.github.com/googleapis/nodejs-retail/issues/117)) ([0f24f0e](https://www.github.com/googleapis/nodejs-retail/commit/0f24f0e42c0cb3430935487fe6569873cfdb6860)) + +## [1.4.0](https://www.github.com/googleapis/nodejs-retail/compare/v1.3.0...v1.4.0) (2021-11-04) + + +### Features + +* Add local inventory ingestion APIs to product service in alpha channel ([#112](https://www.github.com/googleapis/nodejs-retail/issues/112)) ([8387781](https://www.github.com/googleapis/nodejs-retail/commit/8387781135ddb02b43af222bbbd3d5852e0147d3)) + +## [1.3.0](https://www.github.com/googleapis/nodejs-retail/compare/v1.2.2...v1.3.0) (2021-10-19) + + +### Features + +* add search mode to search request. If not specified, a single search request triggers both product search and faceted search. ([49b9b8e](https://www.github.com/googleapis/nodejs-retail/commit/49b9b8e22eba6318f54e44025df4e3c1900cb73e)) +* update grpc service config settings to reflect correct API deadlines ([49b9b8e](https://www.github.com/googleapis/nodejs-retail/commit/49b9b8e22eba6318f54e44025df4e3c1900cb73e)) + +### [1.2.2](https://www.github.com/googleapis/nodejs-retail/compare/v1.2.1...v1.2.2) (2021-09-10) + + +### Bug Fixes + +* **build:** set default branch to main ([#98](https://www.github.com/googleapis/nodejs-retail/issues/98)) ([637a23e](https://www.github.com/googleapis/nodejs-retail/commit/637a23e229641c42103c7b60f2ce2fb974e23d90)) + +### [1.2.1](https://www.github.com/googleapis/nodejs-retail/compare/v1.2.0...v1.2.1) (2021-08-17) + + +### Bug Fixes + +* **deps:** google-gax v2.24.1 ([#91](https://www.github.com/googleapis/nodejs-retail/issues/91)) ([893845a](https://www.github.com/googleapis/nodejs-retail/commit/893845aae9f43a41ad21f97000bc73da3fb985c0)) + +## [1.2.0](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.6...v1.2.0) (2021-08-02) + + +### Features + +* Add restricted Retail Search features for Retail API v2 ([b8279f4](https://www.github.com/googleapis/nodejs-retail/commit/b8279f4b3e90150d349ddd2071d8e25c51c07ec4)) +* Add restricted Retail Search features for Retail API v2alpha ([b8279f4](https://www.github.com/googleapis/nodejs-retail/commit/b8279f4b3e90150d349ddd2071d8e25c51c07ec4)) +* Add restricted Retail Search features for Retail API v2beta. ([#79](https://www.github.com/googleapis/nodejs-retail/issues/79)) ([b8279f4](https://www.github.com/googleapis/nodejs-retail/commit/b8279f4b3e90150d349ddd2071d8e25c51c07ec4)) + +### [1.1.6](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.5...v1.1.6) (2021-07-16) + + +### Bug Fixes + +* Updating WORKSPACE files to use the newest version of the Typescript generator. ([#73](https://www.github.com/googleapis/nodejs-retail/issues/73)) ([9ba9a09](https://www.github.com/googleapis/nodejs-retail/commit/9ba9a09c270b0ed2ef3eae76a284bb19af789317)) + +### [1.1.5](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.4...v1.1.5) (2021-07-13) + + +### Bug Fixes + +* **deps:** google-gax v2.17.1 ([#69](https://www.github.com/googleapis/nodejs-retail/issues/69)) ([b414012](https://www.github.com/googleapis/nodejs-retail/commit/b4140124e136a75e3a33baece43ef7ee5a717c7a)) + +### [1.1.5](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.4...v1.1.5) (2021-07-12) + + +### Bug Fixes + +* **deps:** google-gax v2.17.1 ([#69](https://www.github.com/googleapis/nodejs-retail/issues/69)) ([b414012](https://www.github.com/googleapis/nodejs-retail/commit/b4140124e136a75e3a33baece43ef7ee5a717c7a)) + +### [1.1.4](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.3...v1.1.4) (2021-07-01) + + +### Bug Fixes + +* **deps:** require google-gax v2.17.0 ([#66](https://www.github.com/googleapis/nodejs-retail/issues/66)) ([94fd8a8](https://www.github.com/googleapis/nodejs-retail/commit/94fd8a842f4fc7cfb480e72d4b3375ec0293cc09)) + +### [1.1.3](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.2...v1.1.3) (2021-06-22) + + +### Bug Fixes + +* make request optional in all cases ([#62](https://www.github.com/googleapis/nodejs-retail/issues/62)) ([ea912e8](https://www.github.com/googleapis/nodejs-retail/commit/ea912e887a5a0b0695bcc54d506ec8e7c4c605c3)) + +### [1.1.2](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.1...v1.1.2) (2021-05-25) + + +### Bug Fixes + +* GoogleAdsError missing using generator version after 1.3.0 ([#55](https://www.github.com/googleapis/nodejs-retail/issues/55)) ([907ba0c](https://www.github.com/googleapis/nodejs-retail/commit/907ba0cc02b8c02b85a2549b4d1e76bf8dc59c93)) + +### [1.1.1](https://www.github.com/googleapis/nodejs-retail/compare/v1.1.0...v1.1.1) (2021-05-12) + + +### Bug Fixes + +* **deps:** require google-gax v2.12.0 ([#47](https://www.github.com/googleapis/nodejs-retail/issues/47)) ([3ed1774](https://www.github.com/googleapis/nodejs-retail/commit/3ed1774f8c50a9f1e96610e1cef724d233b10cc3)) +* use require() to load JSON protos ([#50](https://www.github.com/googleapis/nodejs-retail/issues/50)) ([45348f3](https://www.github.com/googleapis/nodejs-retail/commit/45348f3958cb3e1b70f4e335c3aba5b255887e06)) + +## [1.1.0](https://www.github.com/googleapis/nodejs-retail/compare/v1.0.0...v1.1.0) (2021-03-02) + + +### Features + +* **docs:** promote to ga ([#18](https://www.github.com/googleapis/nodejs-retail/issues/18)) ([e54b324](https://www.github.com/googleapis/nodejs-retail/commit/e54b32404d2de0cb6b460e9ca0cada6bd0e5b856)) + +## 1.0.0 (2021-01-13) + + +### ⚠ BREAKING CHANGES + +* initial stub of library + +### Features + +* add initial samples ([#2](https://www.github.com/googleapis/nodejs-retail/issues/2)) ([8a64439](https://www.github.com/googleapis/nodejs-retail/commit/8a644390cc834141304d8903a0ab9da344221412)) +* initial stub of library ([82b5f8d](https://www.github.com/googleapis/nodejs-retail/commit/82b5f8d167189dd9eab0ff6209878a727014f0f7)) diff --git a/packages/google-cloud-retail/CODE_OF_CONDUCT.md b/packages/google-cloud-retail/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..2add2547a81 --- /dev/null +++ b/packages/google-cloud-retail/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/packages/google-cloud-retail/CONTRIBUTING.md b/packages/google-cloud-retail/CONTRIBUTING.md new file mode 100644 index 00000000000..0e48f15b5f0 --- /dev/null +++ b/packages/google-cloud-retail/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# 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 billing for your project][billing]. +1. [Enable the Retail API 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=retail.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/packages/google-cloud-retail/LICENSE b/packages/google-cloud-retail/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/packages/google-cloud-retail/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/packages/google-cloud-retail/README.md b/packages/google-cloud-retail/README.md new file mode 100644 index 00000000000..1ca590f9d1b --- /dev/null +++ b/packages/google-cloud-retail/README.md @@ -0,0 +1,305 @@ +[//]: # "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 + +# [Retail API: Node.js Client](https://github.com/googleapis/google-cloud-node) + +[![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/retail.svg)](https://www.npmjs.org/package/@google-cloud/retail) + + + + +Retail client for Node.js + + +A comprehensive list of changes in each version may be found in +[the CHANGELOG](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-retail/CHANGELOG.md). + +* [Retail API Node.js Client API Reference][client-docs] +* [Retail API Documentation][product-docs] +* [github.com/googleapis/google-cloud-node/packages/google-cloud-retail](https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-retail) + +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 billing for your project][billing]. +1. [Enable the Retail API API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + +### Installing the client library + +```bash +npm install @google-cloud/retail +``` + + +### Using the client library + +```javascript + +// Imports the Google Cloud client library +const {CatalogServiceClient} = require('@google-cloud/retail'); + +// TODO(developer): uncomment these variables with your information +// const projectId = 'my-project' +// const location = 'global' + +// Creates a client +const client = new CatalogServiceClient(); + +async function listCatalogs() { + const catalogs = await client.listCatalogs({ + parent: `projects/${projectId}/locations/${location}`, + }); + console.info(catalogs); +} +listCatalogs(); + +``` + + + +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| Catalog_service.add_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.add_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.add_catalog_attribute.js,samples/README.md) | +| Catalog_service.get_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_attributes_config.js,samples/README.md) | +| Catalog_service.get_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_completion_config.js,samples/README.md) | +| Catalog_service.get_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_default_branch.js,samples/README.md) | +| Catalog_service.list_catalogs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.list_catalogs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.list_catalogs.js,samples/README.md) | +| Catalog_service.remove_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.remove_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.remove_catalog_attribute.js,samples/README.md) | +| Catalog_service.replace_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.replace_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.replace_catalog_attribute.js,samples/README.md) | +| Catalog_service.set_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.set_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.set_default_branch.js,samples/README.md) | +| Catalog_service.update_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_attributes_config.js,samples/README.md) | +| Catalog_service.update_catalog | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_catalog.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_catalog.js,samples/README.md) | +| Catalog_service.update_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_completion_config.js,samples/README.md) | +| Completion_service.complete_query | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/completion_service.complete_query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/completion_service.complete_query.js,samples/README.md) | +| Completion_service.import_completion_data | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/completion_service.import_completion_data.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/completion_service.import_completion_data.js,samples/README.md) | +| Control_service.create_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.create_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.create_control.js,samples/README.md) | +| Control_service.delete_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.delete_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.delete_control.js,samples/README.md) | +| Control_service.get_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.get_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.get_control.js,samples/README.md) | +| Control_service.list_controls | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.list_controls.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.list_controls.js,samples/README.md) | +| Control_service.update_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.update_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.update_control.js,samples/README.md) | +| Prediction_service.predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/prediction_service.predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/prediction_service.predict.js,samples/README.md) | +| Product_service.add_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.add_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.add_fulfillment_places.js,samples/README.md) | +| Product_service.add_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.add_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.add_local_inventories.js,samples/README.md) | +| Product_service.create_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.create_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.create_product.js,samples/README.md) | +| Product_service.delete_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.delete_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.delete_product.js,samples/README.md) | +| Product_service.get_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.get_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.get_product.js,samples/README.md) | +| Product_service.import_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.import_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.import_products.js,samples/README.md) | +| Product_service.list_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.list_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.list_products.js,samples/README.md) | +| Product_service.remove_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.remove_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.remove_fulfillment_places.js,samples/README.md) | +| Product_service.remove_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.remove_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.remove_local_inventories.js,samples/README.md) | +| Product_service.set_inventory | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.set_inventory.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.set_inventory.js,samples/README.md) | +| Product_service.update_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.update_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.update_product.js,samples/README.md) | +| Search_service.search | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/search_service.search.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/search_service.search.js,samples/README.md) | +| Serving_config_service.add_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.add_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.add_control.js,samples/README.md) | +| Serving_config_service.create_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.create_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.create_serving_config.js,samples/README.md) | +| Serving_config_service.delete_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.delete_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.delete_serving_config.js,samples/README.md) | +| Serving_config_service.get_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.get_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.get_serving_config.js,samples/README.md) | +| Serving_config_service.list_serving_configs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.list_serving_configs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.list_serving_configs.js,samples/README.md) | +| Serving_config_service.remove_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.remove_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.remove_control.js,samples/README.md) | +| Serving_config_service.update_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.update_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.update_serving_config.js,samples/README.md) | +| User_event_service.collect_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.collect_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.collect_user_event.js,samples/README.md) | +| User_event_service.import_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.import_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.import_user_events.js,samples/README.md) | +| User_event_service.purge_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.purge_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.purge_user_events.js,samples/README.md) | +| User_event_service.rejoin_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.rejoin_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.rejoin_user_events.js,samples/README.md) | +| User_event_service.write_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.write_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.write_user_event.js,samples/README.md) | +| Catalog_service.add_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js,samples/README.md) | +| Catalog_service.get_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_attributes_config.js,samples/README.md) | +| Catalog_service.get_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_completion_config.js,samples/README.md) | +| Catalog_service.get_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_default_branch.js,samples/README.md) | +| Catalog_service.list_catalogs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.list_catalogs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.list_catalogs.js,samples/README.md) | +| Catalog_service.remove_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js,samples/README.md) | +| Catalog_service.replace_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js,samples/README.md) | +| Catalog_service.set_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.set_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.set_default_branch.js,samples/README.md) | +| Catalog_service.update_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_attributes_config.js,samples/README.md) | +| Catalog_service.update_catalog | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_catalog.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_catalog.js,samples/README.md) | +| Catalog_service.update_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_completion_config.js,samples/README.md) | +| Completion_service.complete_query | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/completion_service.complete_query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/completion_service.complete_query.js,samples/README.md) | +| Completion_service.import_completion_data | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/completion_service.import_completion_data.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/completion_service.import_completion_data.js,samples/README.md) | +| Control_service.create_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.create_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.create_control.js,samples/README.md) | +| Control_service.delete_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.delete_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.delete_control.js,samples/README.md) | +| Control_service.get_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.get_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.get_control.js,samples/README.md) | +| Control_service.list_controls | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.list_controls.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.list_controls.js,samples/README.md) | +| Control_service.update_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.update_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.update_control.js,samples/README.md) | +| Model_service.create_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.create_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.create_model.js,samples/README.md) | +| Model_service.delete_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.delete_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.delete_model.js,samples/README.md) | +| Model_service.list_models | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.list_models.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.list_models.js,samples/README.md) | +| Model_service.pause_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.pause_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.pause_model.js,samples/README.md) | +| Model_service.resume_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.resume_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.resume_model.js,samples/README.md) | +| Model_service.tune_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.tune_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.tune_model.js,samples/README.md) | +| Model_service.update_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.update_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.update_model.js,samples/README.md) | +| Prediction_service.predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/prediction_service.predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/prediction_service.predict.js,samples/README.md) | +| Product_service.add_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_fulfillment_places.js,samples/README.md) | +| Product_service.add_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_local_inventories.js,samples/README.md) | +| Product_service.create_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.create_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.create_product.js,samples/README.md) | +| Product_service.delete_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.delete_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.delete_product.js,samples/README.md) | +| Product_service.get_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.get_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.get_product.js,samples/README.md) | +| Product_service.import_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.import_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.import_products.js,samples/README.md) | +| Product_service.list_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.list_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.list_products.js,samples/README.md) | +| Product_service.purge_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.purge_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.purge_products.js,samples/README.md) | +| Product_service.remove_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_fulfillment_places.js,samples/README.md) | +| Product_service.remove_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_local_inventories.js,samples/README.md) | +| Product_service.set_inventory | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.set_inventory.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.set_inventory.js,samples/README.md) | +| Product_service.update_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.update_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.update_product.js,samples/README.md) | +| Search_service.search | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/search_service.search.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/search_service.search.js,samples/README.md) | +| Serving_config_service.add_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.add_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.add_control.js,samples/README.md) | +| Serving_config_service.create_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.create_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.create_serving_config.js,samples/README.md) | +| Serving_config_service.delete_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.delete_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.delete_serving_config.js,samples/README.md) | +| Serving_config_service.get_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.get_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.get_serving_config.js,samples/README.md) | +| Serving_config_service.list_serving_configs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.list_serving_configs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.list_serving_configs.js,samples/README.md) | +| Serving_config_service.remove_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.remove_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.remove_control.js,samples/README.md) | +| Serving_config_service.update_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.update_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.update_serving_config.js,samples/README.md) | +| User_event_service.collect_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.collect_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.collect_user_event.js,samples/README.md) | +| User_event_service.import_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.import_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.import_user_events.js,samples/README.md) | +| User_event_service.purge_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.purge_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.purge_user_events.js,samples/README.md) | +| User_event_service.rejoin_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.rejoin_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.rejoin_user_events.js,samples/README.md) | +| User_event_service.write_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.write_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.write_user_event.js,samples/README.md) | +| Catalog_service.add_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.add_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.add_catalog_attribute.js,samples/README.md) | +| Catalog_service.batch_remove_catalog_attributes | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js,samples/README.md) | +| Catalog_service.get_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_attributes_config.js,samples/README.md) | +| Catalog_service.get_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_completion_config.js,samples/README.md) | +| Catalog_service.get_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_default_branch.js,samples/README.md) | +| Catalog_service.list_catalogs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.list_catalogs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.list_catalogs.js,samples/README.md) | +| Catalog_service.remove_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js,samples/README.md) | +| Catalog_service.replace_catalog_attribute | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js,samples/README.md) | +| Catalog_service.set_default_branch | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.set_default_branch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.set_default_branch.js,samples/README.md) | +| Catalog_service.update_attributes_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_attributes_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_attributes_config.js,samples/README.md) | +| Catalog_service.update_catalog | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_catalog.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_catalog.js,samples/README.md) | +| Catalog_service.update_completion_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_completion_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_completion_config.js,samples/README.md) | +| Completion_service.complete_query | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/completion_service.complete_query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/completion_service.complete_query.js,samples/README.md) | +| Completion_service.import_completion_data | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/completion_service.import_completion_data.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/completion_service.import_completion_data.js,samples/README.md) | +| Control_service.create_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.create_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.create_control.js,samples/README.md) | +| Control_service.delete_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.delete_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.delete_control.js,samples/README.md) | +| Control_service.get_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.get_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.get_control.js,samples/README.md) | +| Control_service.list_controls | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.list_controls.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.list_controls.js,samples/README.md) | +| Control_service.update_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.update_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.update_control.js,samples/README.md) | +| Model_service.create_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.create_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.create_model.js,samples/README.md) | +| Model_service.delete_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.delete_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.delete_model.js,samples/README.md) | +| Model_service.list_models | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.list_models.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.list_models.js,samples/README.md) | +| Model_service.pause_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.pause_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.pause_model.js,samples/README.md) | +| Model_service.resume_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.resume_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.resume_model.js,samples/README.md) | +| Model_service.tune_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.tune_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.tune_model.js,samples/README.md) | +| Model_service.update_model | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.update_model.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.update_model.js,samples/README.md) | +| Prediction_service.predict | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/prediction_service.predict.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/prediction_service.predict.js,samples/README.md) | +| Product_service.add_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.add_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.add_fulfillment_places.js,samples/README.md) | +| Product_service.add_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.add_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.add_local_inventories.js,samples/README.md) | +| Product_service.create_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.create_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.create_product.js,samples/README.md) | +| Product_service.delete_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.delete_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.delete_product.js,samples/README.md) | +| Product_service.get_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.get_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.get_product.js,samples/README.md) | +| Product_service.import_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.import_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.import_products.js,samples/README.md) | +| Product_service.list_products | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.list_products.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.list_products.js,samples/README.md) | +| Product_service.remove_fulfillment_places | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_fulfillment_places.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_fulfillment_places.js,samples/README.md) | +| Product_service.remove_local_inventories | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_local_inventories.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_local_inventories.js,samples/README.md) | +| Product_service.set_inventory | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.set_inventory.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.set_inventory.js,samples/README.md) | +| Product_service.update_product | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.update_product.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.update_product.js,samples/README.md) | +| Search_service.search | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/search_service.search.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/search_service.search.js,samples/README.md) | +| Serving_config_service.add_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.add_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.add_control.js,samples/README.md) | +| Serving_config_service.create_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.create_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.create_serving_config.js,samples/README.md) | +| Serving_config_service.delete_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.delete_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.delete_serving_config.js,samples/README.md) | +| Serving_config_service.get_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.get_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.get_serving_config.js,samples/README.md) | +| Serving_config_service.list_serving_configs | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.list_serving_configs.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.list_serving_configs.js,samples/README.md) | +| Serving_config_service.remove_control | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.remove_control.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.remove_control.js,samples/README.md) | +| Serving_config_service.update_serving_config | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.update_serving_config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.update_serving_config.js,samples/README.md) | +| User_event_service.collect_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.collect_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.collect_user_event.js,samples/README.md) | +| User_event_service.import_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.import_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.import_user_events.js,samples/README.md) | +| User_event_service.purge_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.purge_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.purge_user_events.js,samples/README.md) | +| User_event_service.rejoin_user_events | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.rejoin_user_events.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.rejoin_user_events.js,samples/README.md) | +| User_event_service.write_user_event | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.write_user_event.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.write_user_event.js,samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/quickstart.js,samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/test/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/test/quickstart.js,samples/README.md) | + + + +The [Retail API 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://nodejs.org/en/about/releases/). +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/retail@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/google-cloud-node/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/google-cloud-node/blob/main/LICENSE) + +[client-docs]: https://cloud.google.com/nodejs/docs/reference/retail/latest +[product-docs]: https://cloud.google.com/recommendations/ +[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=retail.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started diff --git a/packages/google-cloud-retail/linkinator.config.json b/packages/google-cloud-retail/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/packages/google-cloud-retail/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/packages/google-cloud-retail/package.json b/packages/google-cloud-retail/package.json new file mode 100644 index 00000000000..909eb0d60e4 --- /dev/null +++ b/packages/google-cloud-retail/package.json @@ -0,0 +1,74 @@ +{ + "name": "@google-cloud/retail", + "version": "2.1.1", + "description": "Retail client for Node.js", + "repository": { + "type": "git", + "directory": "packages/google-cloud-retail", + "url": "https://github.com/googleapis/google-cloud-node.git" + }, + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google retail", + "retail", + "catalog service", + "prediction service", + "product service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "npm run compile && c8 mocha build/system-test", + "test": "c8 mocha build/test", + "samples-test": "npm run compile && cd samples/ && npm link ../ && npm i && npm test", + "prelint": "cd samples; npm link ../; npm i" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^18.0.0", + "@types/sinon": "^10.0.0", + "c8": "^7.3.5", + "gts": "^3.1.0", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.0", + "jsdoc-region-tag": "^2.0.0", + "linkinator": "^4.0.0", + "mocha": "^9.2.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^9.0.0", + "typescript": "^4.6.4", + "webpack": "^5.9.0", + "webpack-cli": "^4.2.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-retail" +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog.proto new file mode 100644 index 00000000000..0e1b85f6af0 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog.proto @@ -0,0 +1,350 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] if + // unset. + // * `variant` (incompatible with Retail Search): You can only + // ingest + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. This means + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one [Product][google.cloud.retail.v2.Product] + // is using this attribute in + // [Product.attributes][google.cloud.retail.v2.Product.attributes]. Otherwise, + // this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] can be + // pre-loaded by using + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][], or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]s. + // + // Only pre-loaded + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]s that are + // neither in use by products nor predefined can be deleted. + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]s that are + // either in use by products or are predefined cannot be deleted; however, + // their configuration properties will reset to default values upon removal + // request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], as + // there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2.AttributeConfigLevel] used + // for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + // + // Value range is 1 to 20. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The source data for the latest import of the autocomplete + // suggestion phrases. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog_service.proto new file mode 100644 index 00000000000..4d667d1f9e3 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/catalog_service.proto @@ -0,0 +1,476 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with + // the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to + // route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add + // already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the + // catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2.Catalog]s under this location, regardless + // of whether or not this location exists, a PERMISSION_DENIED error is + // returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2.Catalog]s to return. If + // unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2.Catalog], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2.Catalog] to update does not exist, + // a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2.SetDefaultBranchRequest.force] is not set, a + // FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2.SetDefaultBranchRequest.branch_id] even + // if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The [CompletionConfig][google.cloud.retail.v2.CompletionConfig] + // to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2.CompletionConfig] to update. The + // following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The [AttributesConfig][google.cloud.retail.v2.AttributesConfig] + // to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] to update. The + // following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] + // to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to update. The + // following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/common.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/common.proto new file mode 100644 index 00000000000..9864ee7d64f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/common.proto @@ -0,0 +1,766 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. In this case, server behavior defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently rules only work for [controls][google.cloud.retail.v2.Control] with +// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No + // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2.Rule.FilterAction.filter] must be set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter]. See + // more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // + // * Rule Condition: + // - Must specify + // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2.CustomAttribute.numbers] should be set. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2.Catalog] is set to the deprecated + // 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about product-level + // attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are indexed, so that they can be filtered, + // faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This field is ignored in a [UserEvent][google.cloud.retail.v2.UserEvent]. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4 [deprecated = true]; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2.FulfillmentInfo.type], such + // as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must not be larger than max. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than min. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2.PriceInfo.price] + // interval of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2.PriceInfo.original_price] + // internal of all [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2.PriceInfo.currency_code]. Otherwise, + // a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2.PriceInfo.price]. If set, + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] should be + // greater than or equal to [price][google.cloud.retail.v2.PriceInfo.price], + // otherwise an INVALID_ARGUMENT error is thrown. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2.PriceInfo.price] - + // [cost][google.cloud.retail.v2.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used before + // [price_effective_time][google.cloud.retail.v2.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2.PriceInfo.price] + // stops to be effective. The [price][google.cloud.retail.v2.PriceInfo.price] + // is used for search before + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. If + // this field is set, the + // [original_price][google.cloud.retail.v2.PriceInfo.original_price] must be + // set and [original_price][google.cloud.retail.v2.PriceInfo.original_price] + // is used after + // [price_expire_time][google.cloud.retail.v2.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2.Product] got 41 ratings with 1 star, 14 + // ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2.UserInfo.user_agent] can be populated + // from the HTTP request. This flag should be set only if the API request is + // made directly from the end user such as a mobile app (and not if a gateway + // or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/completion_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/completion_service.proto new file mode 100644 index 00000000000..af0fac87e79 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/completion_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail: + // This option requires enabling auto-learning function first. See + // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. It requires + // [UserEvent.product_details][google.cloud.retail.v2.UserEvent.product_details] + // is imported properly. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2.UserEvent] is imported. + // The recent searches satisfy the follow rules: + // + // * They are ordered from latest to oldest. + // + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2.CompleteQueryRequest.query] + // case insensitively. + // + // * They are transformed to lower case. + // + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/control.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/control.proto new file mode 100644 index 00000000000..5558e44dd8c --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/control.proto @@ -0,0 +1,93 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Configures dynamic metadata that can be linked to a +// [ServingConfig][google.cloud.retail.v2.ServingConfig] and affect search or +// recommendation results at serving time. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/controls/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of [serving + // configuration][google.cloud.retail.v2.ServingConfig] ids that are + // associated with this control in the same + // [Catalog][google.cloud.retail.v2.Catalog]. + // + // Note the association is managed via the + // [ServingConfig][google.cloud.retail.v2.ServingConfig], this is an output + // only denormalized view. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the control is used for. + // Currently we support setting only one type of solution at creation time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the use case for the control. + // Affects what condition fields can be set. + // Only settable by search controls. + // Will default to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH] + // if not specified. Currently only allow one search_solution_use_case per + // control. + repeated SearchSolutionUseCase search_solution_use_case = 7; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/control_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/control_service.proto new file mode 100644 index 00000000000..24e8c1c4464 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/control_service.proto @@ -0,0 +1,185 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2.Control] to create already exists, + // an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2.Control] to delete does not exist, + // a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2.Control] to update does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls by their parent + // [Catalog][google.cloud.retail.v2.Catalog]. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2.Control] to update. The following are NOT + // supported: + // + // * [Control.name][google.cloud.retail.v2.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/import_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/import_config.proto new file mode 100644 index 00000000000..23b06369206 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/import_config.proto @@ -0,0 +1,386 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Google Cloud Storage location for input content. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * `control` (default): One JSON [Control][google.cloud.retail.v2.Control] + // per line. + // + // Supported values for catalog attribute imports: + // + // * `catalog_attribute` (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported in + // [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON [Product][google.cloud.retail.v2.Product] + // per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2.Product.id]. Recommended max of + // 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors are written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported `products` to update. If + // not set, all fields are updated. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + // to be within the same project as + // [ImportProductsRequest.parent][google.cloud.retail.v2.ImportProductsRequest.parent]. + // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + // `pubsub.topics.publish` IAM permission on the topic. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This is +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. If the +// long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/prediction_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/prediction_service.proto new file mode 100644 index 00000000000..717405b2b81 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/prediction_service.proto @@ -0,0 +1,223 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + additional_bindings { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Managing serving configurations] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + // + // Don't set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] to the same + // fixed ID for different users. If you are trying to receive non-personalized + // recommendations (not recommended; this can negatively impact model + // performance), instead set + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id] to a + // random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return. Set this property to the number of + // prediction results needed. If zero, the service will choose a reasonable + // default. The maximum allowed value is 100. Values above 100 will be coerced + // to 100. + int32 page_size = 3; + + // This field is not used; leave it unset. + string page_token = 4 [deprecated = true]; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Is set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Is set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/product.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/product.proto new file mode 100644 index 00000000000..fe5d212cf07 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/product.proto @@ -0,0 +1,565 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s that are sold together, such + // as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // [expire_time][google.cloud.retail.v2.Product.expire_time]. However, the + // product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2.Product.expire_time] must be later + // than [available_time][google.cloud.retail.v2.Product.available_time] and + // [publish_time][google.cloud.retail.v2.Product.publish_time], otherwise an + // INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2.Product.ttl] is + // left blank when retrieving the [Product][google.cloud.retail.v2.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] after + // current timestamp plus [ttl][google.cloud.retail.v2.Product.ttl]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2.Product] identifier, which is + // the final component of [name][google.cloud.retail.v2.Product.name]. For + // example, this field is "id_1", if + // [name][google.cloud.retail.v2.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2.Product.id], with the same parent branch with + // this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s, this field can only be empty or + // set to the same value as [id][google.cloud.retail.v2.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2.Product]s, this field cannot + // be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2.Product.id] of the collection members when + // [type][google.cloud.retail.v2.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] otherwise an + // INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Empty values are not allowed. + // Each value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The [Product][google.cloud.retail.v2.Product] + // can include text in different languages, but duplicating + // [Product][google.cloud.retail.v2.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2.Product] becomes + // available for + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the [Product][google.cloud.retail.v2.Product]. + // Default to + // [Availability.IN_STOCK][google.cloud.retail.v2.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2.Product.available_time], given it + // purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the [Product][google.cloud.retail.v2.Product]s + // are returned in [SearchResponse][google.cloud.retail.v2.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2.Product.type]s: + // + // * [audience][google.cloud.retail.v2.Product.audience] + // * [availability][google.cloud.retail.v2.Product.availability] + // * [brands][google.cloud.retail.v2.Product.brands] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // * [conditions][google.cloud.retail.v2.Product.conditions] + // * [gtin][google.cloud.retail.v2.Product.gtin] + // * [materials][google.cloud.retail.v2.Product.materials] + // * [name][google.cloud.retail.v2.Product.name] + // * [patterns][google.cloud.retail.v2.Product.patterns] + // * [price_info][google.cloud.retail.v2.Product.price_info] + // * [rating][google.cloud.retail.v2.Product.rating] + // * [sizes][google.cloud.retail.v2.Product.sizes] + // * [title][google.cloud.retail.v2.Product.title] + // * [uri][google.cloud.retail.v2.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2.Product.categories] + // * [description][google.cloud.retail.v2.Product.description] + // * [images][google.cloud.retail.v2.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]: + // + // * Only the first image in [images][google.cloud.retail.v2.Product.images] + // + // To mark [attributes][google.cloud.retail.v2.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2.Product.name] + // * [color_info][google.cloud.retail.v2.Product.color_info] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2.SearchResponse] can increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2.Product.primary_product_id] for + // all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A list of local inventories specific to different places. + // + // This is only available for users who have Retail Search enabled, and it can + // be managed by [AddLocalInventories][] and [RemoveLocalInventories][] APIs. + repeated LocalInventory local_inventories = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/product_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/product_service.proto new file mode 100644 index 00000000000..5ca2cb32696 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/product_service.proto @@ -0,0 +1,910 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting [Product][google.cloud.retail.v2.Product] information +// of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. + // + // Request processing may be synchronous. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2.Product] while respecting the last update + // timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // or + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + // + // The returned [Operation][]s will be obsolete after 1 day, and + // [GetOperation][] API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the [Operation][]s associated with the + // stale updates will not be marked as [done][Operation.done] until being + // obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // The returned [Operation][]s will be obsolete after 1 day, and + // [GetOperation][] API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the [Operation][]s associated with the + // stale updates will not be marked as [done][Operation.done] until being + // obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // The returned [Operation][]s will be obsolete after 1 day, and + // [GetOperation][] API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the [Operation][]s associated with the + // stale updates will not be marked as [done][Operation.done] until being + // obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][]s will be obsolete after 1 day, and + // [GetOperation][] API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the [Operation][]s associated with the + // stale updates will not be marked as [done][Operation.done] until being + // obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2.Product] at a list of places at a removal + // timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][]s will be obsolete after 1 day, and + // [GetOperation][] API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the [Operation][]s associated with the + // stale updates will not be marked as [done][Operation.done] until being + // obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for +// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] +// method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the [Product][google.cloud.retail.v2.Product], + // which will become the final component of the + // [Product.name][google.cloud.retail.v2.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2.Product]s with the same + // [parent][google.cloud.retail.v2.CreateProductRequest.parent]. Otherwise, an + // ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] +// method. +message GetProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2.Product] does not exist, + // a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] +// method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not exist + // and + // [allow_missing][google.cloud.retail.v2.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + // + // The attribute key can be updated by setting the mask path as + // "attributes.${key_name}". If a key name is present in the mask but not in + // the patching product from the request, this key will be deleted after the + // update. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, a new [Product][google.cloud.retail.v2.Product] will be created. In + // this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for +// [ProductService.DeleteProduct][google.cloud.retail.v2.ProductService.DeleteProduct] +// method. +message DeleteProductRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to delete does not exist, + // a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2.Product] to delete can neither be a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] with more than one + // [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2.Product]s under this branch, regardless of + // whether or not this branch exists, a PERMISSION_DENIED error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2.ListProductsRequest.filter] is unset. + // * List [Product.Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2.Product]s with a partibular type. + // For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2.Product] does not exist, a NOT_FOUND error + // is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2.Product] to return in the + // responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2.Product.name] + // * [Product.id][google.cloud.retail.v2.Product.id] + // * [Product.title][google.cloud.retail.v2.Product.title] + // * [Product.uri][google.cloud.retail.v2.Product.uri] + // * [Product.images][google.cloud.retail.v2.Product.images] + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.brands][google.cloud.retail.v2.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2.Product.name] is always returned no + // matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory] +// method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask]. + // + // If + // [SetInventoryRequest.inventory.name][google.cloud.retail.v2.Product.name] + // is empty or invalid, an INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2.Product] named in + // [Product.name][google.cloud.retail.v2.Product.name], regardless of whether + // or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2.Product] to update does not have + // existing inventory information, the provided inventory information will be + // inserted. + // + // If the [Product][google.cloud.retail.v2.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // * [Product.availability][google.cloud.retail.v2.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] with name + // [Product.name][google.cloud.retail.v2.Product.name] is not found, the + // inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2.Product] is created. If set to + // false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type]. Duplicate + // IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory will still be processed and retained for at most + // 1 day and processed once the [Product][google.cloud.retail.v2.Product] is + // created. If set to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of [Product][google.cloud.retail.v2.Product], + // such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2.Product], regardless of whether or not it + // exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type], such as + // the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2.Product] is not + // found, the fulfillment information will still be processed and retained for + // at most 1 day and processed once the + // [Product][google.cloud.retail.v2.Product] is created. If set to false, a + // NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/promotion.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/promotion.proto new file mode 100644 index 00000000000..9ba323475f2 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/purge_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/purge_config.proto new file mode 100644 index 00000000000..cb510745025 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/purge_config.proto @@ -0,0 +1,82 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2.UserEvent.event_type] string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/search_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/search_service.proto new file mode 100644 index 00000000000..32de76da6f3 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/search_service.proto @@ -0,0 +1,917 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + additional_bindings { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search" + body: "*" + } + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2.Product] object, over which the facet + // values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on predefined textual fields, custom textual + // attributes and fulfillments. Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.value] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. Notice that there is no limitation on + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match the query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // + // By default, + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 products with the color facet "Red" + // and 200 products with the color facet "Blue". A query containing the + // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.key] + // would by default return only "Red" products in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue products available, "Blue" would not be shown as an + // available facet value. + // + // If "colorFamilies" is listed in "excludedFilterKeys", then the query + // returns the facet values "Red" with count 100 and "Blue" with count + // 200, because the "colorFamilies" key is now excluded from the filter. + // Because this field doesn't affect search results, the search results + // are still correctly filtered to return only "Red" products. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 20. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. In this case, server behavior + // defaults to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization based on quality of user + // event data. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Google Retail Search will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.retail.v2.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by Google Retail Search. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of + // [SearchRequest.facet_specs][google.cloud.retail.v2.SearchRequest.facet_specs] + // and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + // + // If this field is empty, the request is considered a category browsing + // request and returned results are based on + // [filter][google.cloud.retail.v2.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2.SearchRequest.page_categories]. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2.Product]s to return. If + // unspecified, defaults to a reasonable value. The maximum allowed value is + // 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search] must + // match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + // error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if [page_token][google.cloud.retail.v2.SearchRequest.page_token] + // is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2.Product] object. Leave it + // unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s attributes. The + // attributes from all the matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s or + // [LocalInventory][google.cloud.retail.v2.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.local_inventories.attributes][google.cloud.retail.v2.LocalInventory.attributes] + // map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. + PersonalizationSpec personalization_spec = 32; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 34; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + optional SpellCorrectionSpec spell_correction_spec = 35; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2.SearchService.Search] method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2.Product.id] of the searched + // [Product][google.cloud.retail.v2.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2.Product.name] is guaranteed to be + // populated. + // + // [Product.variants][google.cloud.retail.v2.Product.variants] contains the + // product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] matches the search query, this + // map indicates which [Product][google.cloud.retail.v2.Product] fields are + // matched. The key is the + // [Product.name][google.cloud.retail.v2.Product.name], the value is a field + // mask of the matched [Product][google.cloud.retail.v2.Product] fields. If + // matched attributes cannot be determined, this map will be empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2.Product] attributes. The key is one of + // the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2.FulfillmentInfo], the rollup + // values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + + // Specifies previous events related to this product for this user based on + // [UserEvent][google.cloud.retail.v2.UserEvent] with same + // [SearchRequest.visitor_id][google.cloud.retail.v2.SearchRequest.visitor_id] + // or [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id]. + // + // This is set only when + // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.mode] + // is + // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + // + // Possible values: + // + // * `purchased`: Indicates that this product has been purchased before. + repeated string personal_labels = 7; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + + // The minimum value in the + // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2.SearchResponse.results] returned + // by pagination may be less than the + // [total_size][google.cloud.retail.v2.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query is used for search. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.retail.v2.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config.proto new file mode 100644 index 00000000000..45f317d63b8 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config.proto @@ -0,0 +1,248 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/servingConfig/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model in the same [Catalog][google.cloud.retail.v2.Catalog] + // to use at serving time. Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2.Catalog] as the + // [ServingConfig][google.cloud.retail.v2.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // The specification for personalization spec. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. + SearchRequest.PersonalizationSpec personalization_spec = 21; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config_service.proto new file mode 100644 index 00000000000..a4cabe26ba2 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/serving_config_service.proto @@ -0,0 +1,240 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are + // allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a + // FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event.proto new file mode 100644 index 00000000000..fc315f88f1a --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event.proto @@ -0,0 +1,343 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2/common.proto"; +import "google/cloud/retail/v2/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is optional except for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2.SearchRequest.query] for + // definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2.SearchRequest.filter] for + // definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See [SearchRequest.order_by][google.cloud.retail.v2.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2.SearchRequest.offset] for + // definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = [revenue][google.cloud.retail.v2.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event_service.proto new file mode 100644 index 00000000000..9a917bc6c6c --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2/user_event_service.proto @@ -0,0 +1,189 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/cloud/retail/v2/import_config.proto"; +import "google/cloud/retail/v2/purge_config.proto"; +import "google/cloud/retail/v2/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2"; +option ruby_package = "Google::Cloud::Retail::V2"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // `Operation.response` is of type `ImportResponse`. Note that it is + // possible for a subset of the items to be successfully inserted. + // `Operation.metadata` is of type `ImportMetadata`. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog.proto new file mode 100644 index 00000000000..f6c114d7ca4 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog.proto @@ -0,0 +1,419 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2alpha.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2alpha.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2alpha.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // if unset. + // * `variant` (incompatible with Retail Search): You can only + // ingest + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. This means + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2alpha.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2alpha.Product.id]. + // Acceptable values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2alpha.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2alpha.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] can be + // pre-loaded by using + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.ImportCatalogAttributes], + // or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. + // + // Only pre-loaded + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are + // neither in use by products nor predefined can be deleted. + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s that are + // either in use by products or are predefined cannot be deleted; however, + // their configuration properties will reset to default values upon removal + // request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2alpha.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // as there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, + // attribute values are filterable for recommendations. + // This option works for categorical features only, + // does not work for numerical features, inventory filtering. + RecommendationsFilteringOption recommendations_filtering_option = 8; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2alpha.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + // + // Value range is 1 to 20. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2alpha.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The source data for the latest import of the autocomplete + // suggestion phrases. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values can be found here. + // [https://support.google.com/merchants/answer/7501026] + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog_service.proto new file mode 100644 index 00000000000..088c01922de --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/catalog_service.proto @@ -0,0 +1,478 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by + // updating the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to + // return. If unspecified, defaults to 50. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2alpha.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2alpha.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2alpha.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2alpha.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/common.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/common.proto new file mode 100644 index 00000000000..02cf05ba8ec --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/common.proto @@ -0,0 +1,791 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. In this case, server behavior defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2alpha.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][google.cloud.retail.v2alpha.CatalogConfig.attribute_configs]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// If filtering for recommendations is enabled. +enum RecommendationsFilteringOption { + // Value used when unset. + // In this case, server behavior defaults to + // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2alpha.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; + + // Recommendation filtering is disabled. + RECOMMENDATIONS_FILTERING_DISABLED = 1; + + // Recommendation filtering is enabled. + RECOMMENDATIONS_FILTERING_ENABLED = 3; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2alpha.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // Example) "a b c" is 3 terms and allowed, " a b c d" is 4 terms and not + // allowed for partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently only boost rules are supported. +// Currently only supported by the search endpoint. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No + // [Condition.query_terms][google.cloud.retail.v2alpha.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2alpha.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2alpha.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // + // * Rule Condition: + // - Must specify + // [Condition.query_terms][google.cloud.retail.v2alpha.Condition.query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2alpha.Product] +// for whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2alpha.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2alpha.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is set to the + // deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about + // product-level attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2alpha.CustomAttribute.text] + // is set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.Catalog] is set to the + // deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about + // product-level attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are indexed, so that they can be filtered, + // faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2alpha.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4 [deprecated = true]; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2alpha.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2alpha.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must not be larger than max. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than min. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2alpha.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2alpha.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2alpha.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2alpha.PriceInfo.price]. If set, + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] + // should be greater than or equal to + // [price][google.cloud.retail.v2alpha.PriceInfo.price], otherwise an + // INVALID_ARGUMENT error is thrown. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] - + // [cost][google.cloud.retail.v2alpha.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is only used for + // search after + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2alpha.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2alpha.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2alpha.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2alpha.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2alpha.PriceInfo.price] is + // always effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2alpha.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2alpha.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2alpha.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2alpha.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2alpha.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2alpha.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/completion_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/completion_service.proto new file mode 100644 index 00000000000..9f399d2233b --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/completion_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2alpha.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail: + // This option requires enabling auto-learning function first. See + // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2alpha.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. It requires + // [UserEvent.product_details][google.cloud.retail.v2alpha.UserEvent.product_details] + // is imported properly. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2alpha.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2alpha.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2alpha.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // + // * They are ordered from latest to oldest. + // + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2alpha.CompleteQueryRequest.query] + // case insensitively. + // + // * They are transformed to lower case. + // + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control.proto new file mode 100644 index 00000000000..cdd683d573e --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control.proto @@ -0,0 +1,92 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures dynamic serving time metadata that is used to pre and post +// process search/recommendation model results. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + SearchRequest.FacetSpec facet_spec = 3; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/controls/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of serving configuration ids that that are associated + // with this control. Note the association is managed via the ServingConfig, + // this is an output only denormalizeed view. Assumed to be in the same + // catalog. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the serving config is used + // for. Currently we support setting only one type of solution at creation + // time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // SOLUTION_TYPE_SEARCH. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Specifies the use case for the control. + // Affects what condition fields can be set. + // Only settable by search controls. + // Will default to SEARCH_SOLUTION_USE_CASE_SEARCH if not specified. + // Currently only allow one search_solution_use_case per control. + repeated SearchSolutionUseCase search_solution_use_case = 7 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control_service.proto new file mode 100644 index 00000000000..d69201a3d18 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/control_service.proto @@ -0,0 +1,184 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2alpha.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls linked to this catalog. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2alpha.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2alpha.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/export_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/export_config.proto new file mode 100644 index 00000000000..dd907d1ea91 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/export_config.proto @@ -0,0 +1,95 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Output result. +message OutputResult { + // Export result in BigQuery. + repeated BigQueryOutputResult bigquery_result = 1; +} + +// A BigQuery output result. +message BigQueryOutputResult { + // The ID of a BigQuery Dataset. + string dataset_id = 1; + + // The ID of a BigQuery Table. + string table_id = 2; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/import_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/import_config.proto new file mode 100644 index 00000000000..319edb1eacb --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/import_config.proto @@ -0,0 +1,413 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Google Cloud Storage location for input content. +// format. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * 'control' (default): One JSON + // [Control][google.cloud.retail.v2alpha.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * 'catalog_attribute' (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2alpha.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2alpha.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: This feature is in private preview. Please contact the + // support team for importing Google Analytics 4 events. + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2alpha.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors will be written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + // + // Can only be set while using + // [BigQuerySource][google.cloud.retail.v2alpha.BigQuerySource]. And the + // BigQuery dataset must be created in the data location "us (multiple + // regions in United States)", otherwise a PERMISSION_DENIED error is + // thrown. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported 'products' to update. If + // not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + // to be within the same project as + // [ImportProductsRequest.parent][google.cloud.retail.v2alpha.ImportProductsRequest.parent]. + // Make sure that both + // `cloud-retail-customer-data-access@system.gserviceaccount.com` and + // `service-@gcp-sa-retail.iam.gserviceaccount.com` + // have the `pubsub.topics.publish` IAM permission on the topic. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + string notification_pubsub_topic = 7; + + // If true, will perform the FULL import even if it would delete a large + // proportion of the products in the default branch, which could potentially + // cause outages if you have live predict/search traffic. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + bool skip_default_branch_protection = 8; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2alpha.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This will be +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification will be sent to + // specified Pub/Sub topic. The message data will be JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. +// If the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2alpha.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model.proto new file mode 100644 index 00000000000..5f4ead9f7d2 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model.proto @@ -0,0 +1,432 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ModelProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Metadata that describes the training and serving parameters of a +// [Model][google.cloud.retail.v2alpha.Model]. A +// [Model][google.cloud.retail.v2alpha.Model] can be associated with a +// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and then queried +// through the Predict api. +message Model { + option (google.api.resource) = { + type: "retail.googleapis.com/Model" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }; + + // The PageOptimizationConfig for model training. + // + // This determines how many panels to optimize for, and which serving + // configurations to consider for each panel. + // The purpose of this model is to optimize which + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to show on which + // panels in way that optimizes the visitors shopping journey. + message PageOptimizationConfig { + // A candidate to consider for a given panel. Currently only + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] are valid + // candidates. + message Candidate { + oneof candidate { + // This has to be a valid + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] + // identifier. e.g. for a ServingConfig with full name: + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/my_candidate_config` + // this would be 'my_candidate_config' + string serving_config_id = 1; + } + } + + // An individual panel with a list of + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] to consider + // for it. + message Panel { + // Optional. The name to display for the panel. + string display_name = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The candidates to consider on the panel. + // + // Limit = 10. + repeated Candidate candidates = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The default candidate (in case the model fails at serving + // time, we can fall back to the default). + Candidate default_candidate = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // Restrictions of expected returned results. + enum Restriction { + // Unspecified value for restriction. + RESTRICTION_UNSPECIFIED = 0; + + // Allow any [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to + // be show on any number of panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity, + // pdp_cvr_no_diversity + // + // `Restriction` = NO_RESTRICTION + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: [] + NO_RESTRICTION = 1; + + // Do not allow the same + // [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] to + // be shown on multiple panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = UNIQUE_SERVING_CONFIG_RESTRICTION + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity_low) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + UNIQUE_SERVING_CONFIG_RESTRICTION = 2; + + // Do not allow multiple + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same + // [Model.name][google.cloud.retail.v2alpha.Model.name] to be show on on + // different panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = UNIQUE_MODEL_RESTRICTION + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + UNIQUE_MODEL_RESTRICTION = 3; + + // Do not allow multiple + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same + // [Model.type][google.cloud.retail.v2alpha.Model.type] to be shown on + // different panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = UNIQUE_MODEL_RESTRICTION + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity) + UNIQUE_MODEL_TYPE_RESTRICTION = 4; + } + + // Required. The type of [UserEvent][google.cloud.retail.v2alpha.UserEvent] + // this page optimization is shown for. + // + // Each page has an associated event type - this will be the + // corresponding event type for the page that the page optimization + // model is used on. + // + // Supported types: + // + // * `add-to-cart`: Products being added to cart. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed + // * `category-page-view`: Homepage viewed + // * `shopping-cart-page-view`: User viewing a shopping cart. + // + // `home-page-view` only allows models with type `recommended-for-you`. + // All other page_optimization_event_type allow all + // [Model.types][google.cloud.retail.v2alpha.Model.type]. + string page_optimization_event_type = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. A list of panel configurations. + // + // Limit = 5. + repeated Panel panels = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. How to restrict results across panels e.g. can the same + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] be shown on + // multiple panels at once. + // + // If unspecified, default to `UNIQUE_MODEL_RESTRICTION`. + Restriction restriction = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Represents an ordered combination of valid serving configs, which + // / may be used for PAGE_OPTIMIZATION recommendations. + message ServingConfigList { + // Optional. A set of valid serving configs that may be used for + // PAGE_OPTIMIZATION. + repeated string serving_config_ids = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // The serving state of the model. + enum ServingState { + // Unspecified serving state. + SERVING_STATE_UNSPECIFIED = 0; + + // The model is not serving. + INACTIVE = 1; + + // The model is serving and can be queried. + ACTIVE = 2; + + // The model is trained on tuned hyperparameters, and can be + // queried. + TUNED = 3; + } + + // The training state of the model. + enum TrainingState { + // Unspecified training state. + TRAINING_STATE_UNSPECIFIED = 0; + + // The model training is paused. + PAUSED = 1; + + // The model is training. + TRAINING = 2; + } + + // Describes whether periodic tuning is enabled for this model + // or not. Periodic tuning is scheduled at most every three months. You can + // start a tuning process manually by using the ModelTune + // method, which starts a tuning process immediately and resets the quarterly + // schedule. Enabling or disabling periodic tuning does not affect any + // current tuning processes. + enum PeriodicTuningState { + // Unspecified default value - should never be explicitly set. + PERIODIC_TUNING_STATE_UNSPECIFIED = 0; + + // The model has periodic tuning disabled. Tuning + // can be reenabled by calling the EnableModelPeriodicTuning + // method or by calling the TuneModel method. + PERIODIC_TUNING_DISABLED = 1; + + // The model cannot be tuned with periodic tuning OR the + // TuneModel method. Hide the options in customer UI and + // reject any requests through the backend self serve API. + ALL_TUNING_DISABLED = 3; + + // The model has periodic tuning enabled. Tuning + // can be disabled by calling the DisableModelPeriodicTuning + // method. + PERIODIC_TUNING_ENABLED = 2; + } + + // Describes whether this model have sufficient training data + // to be continuously trained. + enum DataState { + // Unspecified default value - should never be explicitly set. + DATA_STATE_UNSPECIFIED = 0; + + // The model has sufficient training data. + DATA_OK = 1; + + // The model does not have sufficient training data. Error + // messages can be queried via Stackdriver. + DATA_ERROR = 2; + } + + // Training configuration specific to a + // [Model.type][google.cloud.retail.v2alpha.Model.type] - currently, only for + // page optimization. + oneof training_config { + // Optional. The page optimization config. + PageOptimizationConfig page_optimization_config = 17 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Required. The fully qualified resource name of the model. + // + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + // catalog_id has char limit of 50. + // recommendation_model_id has char limit of 40. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The display name of the model. + // + // Should be human readable, used to display Recommendation Models in the + // Retail Cloud Cosole Dashboard. UTF-8 encoded string with limit of 1024 + // characters. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The training state that the model is in (e.g. + // TRAINING or PAUSED). + // + // Since part of the cost of running the service + // is frequency of training - this can be used to determine when to train + // model in order to control cost. If not specified: the default value for + // CreateModel method is TRAINING. the default value for + // UpdateModel method is to keep the state the same as before. + TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The serving state of the model: ACTIVE, NOT_ACTIVE. + ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was created at. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was last updated. E.g. + // if a Recommendation Model was paused - this would be the time the pause was + // initiated. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The type of model e.g. `home-page`. + // + // Currently supported values: `recommended-for-you`, `others-you-may-like`, + // `frequently-bought-together`, `page-optimization`, 'similar-items', + // 'buy-it-again', `recently-viewed`(readonly value). + string type = 7 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optimization objective e.g. `cvr`. + // + // Currently supported + // values: `ctr`, `cvr`, `revenue-per-order`. + // + // If not specified, we choose default based on model type. + // Default depends on type of recommendation: + // + // `recommended-for-you` => `ctr` + // + // `others-you-may-like` => `ctr` + // + // `frequently-bought-together` => `revenue_per_order` + string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The state of periodic tuning. + // + // The period we use is 3 months - to do a + // one-off tune earlier use the TuneModel method. Default value + // is PERIODIC_TUNING_ENABLED. + PeriodicTuningState periodic_tuning_state = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the latest successful tune finished. + google.protobuf.Timestamp last_tune_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The tune operation associated with the model. + // + // Can be used to determine if there is an ongoing tune for this + // recommendation. Empty field implies no tune is goig on. + string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of data requirements for this model: DATA_OK and + // DATA_ERROR. + // + // Recommendation model cannot be trained if the data is in + // DATA_ERROR state. Recommendation model can have DATA_ERROR state even if + // serving state is ACTIVE: models were trained successfully before, but + // cannot be refreshed because model no longer has sufficient + // data for training. + DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If RECOMMENDATIONS_FILTERING_ENABLED, recommendation filtering by + // attributes is enabled for the model. + RecommendationsFilteringOption filtering_option = 18 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of valid serving configs associated with the + // PageOptimizationConfig. + repeated ServingConfigList serving_config_lists = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model_service.proto new file mode 100644 index 00000000000..30690f538f5 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/model_service.proto @@ -0,0 +1,241 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ModelServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for performing CRUD operations on models. +// Recommendation models contain all the metadata necessary to generate a set of +// models for the Predict() api. A model is queried +// indirectly via a ServingConfig, which associates a model with a +// given Placement (e.g. Frequently Bought Together on Home Page). +// +// This service allows customers to e.g.: +// +// * Initiate training of a model. +// * Pause training of an existing model. +// * List all the available models along with their metadata. +// * Control their tuning schedule. +service ModelService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new model. + rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" + body: "model" + }; + option (google.api.method_signature) = "parent,model"; + option (google.longrunning.operation_info) = { + response_type: "Model" + metadata_type: "CreateModelMetadata" + }; + } + + // Pauses the training of an existing model. + rpc PauseModel(PauseModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resumes the training of an existing model. + rpc ResumeModel(ResumeModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an existing model. + rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the models linked to this event store. + rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" + }; + option (google.api.method_signature) = "parent"; + } + + // Update of model metadata. Only fields that + // currently can be updated are: filtering_option, periodic_tuning_state. + // If other values are provided, this API method will ignore them. + rpc UpdateModel(UpdateModelRequest) returns (Model) { + option (google.api.http) = { + patch: "/v2alpha/{model.name=projects/*/locations/*/catalogs/*/models/*}" + body: "model" + }; + option (google.api.method_signature) = "model,update_mask"; + } + + // Tunes an existing model. + rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:tune" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "TuneModelResponse" + metadata_type: "TuneModelMetadata" + }; + } +} + +// Request for creating a model. +message CreateModelRequest { + // Required. The parent resource under which to create the model. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The payload of the [Model] to create. + Model model = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Whether to run a dry_run to validate the request (without + // actually creating the model). + bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating an existing model. +message UpdateModelRequest { + // Required. The body of the updated [Model]. + Model model = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided 'model' to + // update. If not set, will by default update all fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for pausing training of a model. +message PauseModelRequest { + // Required. The name of the model to pause. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for resuming training of a model. +message ResumeModelRequest { + // Required. The name of the model to resume. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing models associated with a resource. +message ListModelsRequest { + // Required. The parent for which to list models. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListModels` + // call. Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a model. +message DeleteModelRequest { + // Required. The resource name of the [Model] to delete. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Response to a ListModelRequest. +message ListModelsResponse { + // List of Models. + repeated Model models = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request to manually start a tuning process now (instead of waiting for +// the periodically scheduled tuning to happen). +message TuneModelRequest { + // Required. The resource name of the model to tune. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Metadata associated with a create operation. +message CreateModelMetadata { + // The resource name of the model that this create applies to. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string model = 1; +} + +// Metadata associated with a tune operation. +message TuneModelMetadata { + // The resource name of the model that this tune applies to. + // Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + string model = 1; +} + +// Response associated with a tune operation. +message TuneModelResponse {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/prediction_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/prediction_service.proto new file mode 100644 index 00000000000..b76aed50b11 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/prediction_service.proto @@ -0,0 +1,223 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + additional_bindings { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Managing serving configurations] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + // + // Don't set + // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id] to the + // same fixed ID for different users. If you are trying to receive + // non-personalized recommendations (not recommended; this can negatively + // impact model performance), instead set + // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id] to + // a random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return per page. Set this property + // to the number of prediction results needed. If zero, the service will + // choose a reasonable default. The maximum allowed value is 100. Values + // above 100 will be coerced to 100. + int32 page_size = 3; + + // This field is not used for now; leave it unset. + string page_token = 4 [deprecated = true]; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Is set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Is set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product.proto new file mode 100644 index 00000000000..f4826f1bdd0 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product.proto @@ -0,0 +1,567 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2alpha.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after [expire_time][google.cloud.retail.v2alpha.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2alpha.Product.available_time] and + // [publish_time][google.cloud.retail.v2alpha.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2alpha.Product.ttl]. + // The derived + // [expire_time][google.cloud.retail.v2alpha.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2alpha.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2alpha.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2alpha.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2alpha.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2alpha.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2alpha.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2alpha.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2alpha.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2alpha.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2alpha.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2alpha.Product.id] of the collection members + // when [type][google.cloud.retail.v2alpha.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2alpha.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] otherwise + // and INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] otherwise an + // INVALID_ARGUMENT error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2alpha.Product] can include text in + // different languages, but duplicating + // [Product][google.cloud.retail.v2alpha.Product]s to provide text in multiple + // languages can result in degraded model performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2alpha.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2alpha.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2alpha.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2alpha.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2alpha.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2alpha.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2alpha.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2alpha.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2alpha.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2alpha.Product.type]s: + // + // * [audience][google.cloud.retail.v2alpha.Product.audience] + // * [availability][google.cloud.retail.v2alpha.Product.availability] + // * [brands][google.cloud.retail.v2alpha.Product.brands] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // * [conditions][google.cloud.retail.v2alpha.Product.conditions] + // * [gtin][google.cloud.retail.v2alpha.Product.gtin] + // * [materials][google.cloud.retail.v2alpha.Product.materials] + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [patterns][google.cloud.retail.v2alpha.Product.patterns] + // * [price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [rating][google.cloud.retail.v2alpha.Product.rating] + // * [sizes][google.cloud.retail.v2alpha.Product.sizes] + // * [title][google.cloud.retail.v2alpha.Product.title] + // * [uri][google.cloud.retail.v2alpha.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2alpha.Product.categories] + // * [description][google.cloud.retail.v2alpha.Product.description] + // * [images][google.cloud.retail.v2alpha.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2alpha.Product.images] + // + // To mark [attributes][google.cloud.retail.v2alpha.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2alpha.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2alpha.Product.name] + // * [color_info][google.cloud.retail.v2alpha.Product.color_info] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] can increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2alpha.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product_service.proto new file mode 100644 index 00000000000..1a5f702bb05 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/product_service.proto @@ -0,0 +1,932 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting [Product][google.cloud.retail.v2alpha.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2alpha.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2alpha.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2alpha.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2alpha.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2alpha.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Permanently deletes all selected + // [Product][google.cloud.retail.v2alpha.Product]s under a branch. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed offline. Depending on the number of + // [Product][google.cloud.retail.v2alpha.Product]s, this operation could take + // hours to complete. Before the operation completes, some + // [Product][google.cloud.retail.v2alpha.Product]s may still be returned by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, + // this operation could take hours to complete. To get a sample of + // [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set + // [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] + // to false. + rpc PurgeProducts(PurgeProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeProductsMetadata" + }; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. + // + // Request processing may be synchronous. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], + // the specified inventory field value(s) will overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update time for the specified inventory fields will be overwritten to the + // time of the + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // or + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], + // then any pre-existing inventory information for this product will be used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], + // then any existing inventory information will be preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2alpha.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2alpha.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2alpha.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2alpha.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for +// [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] +// method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2alpha.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2alpha.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2alpha.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2alpha.Product]s with the same + // [parent][google.cloud.retail.v2alpha.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] +// method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2alpha.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] +// method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + // + // The attribute key can be updated by setting the mask path as + // "attributes.${key_name}". If a key name is present in the mask but not in + // the patching product from the request, this key will be deleted after the + // update. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, a new [Product][google.cloud.retail.v2alpha.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for +// [ProductService.DeleteProduct][google.cloud.retail.v2alpha.ProductService.DeleteProduct] +// method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2alpha.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] with more than one + // [variants][google.cloud.retail.v2alpha.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2alpha.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2alpha.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to 100. The maximum allowed value is 1000. + // Values above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2alpha.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2alpha.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2alpha.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2alpha.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2alpha.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2alpha.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2alpha.Product.name] + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // * [Product.title][google.cloud.retail.v2alpha.Product.title] + // * [Product.uri][google.cloud.retail.v2alpha.Product.uri] + // * [Product.images][google.cloud.retail.v2alpha.Product.images] + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.brands][google.cloud.retail.v2alpha.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2alpha.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; + + // If true and + // [page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] is + // empty, + // [ListProductsResponse.total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // is set to the total count of matched items irrespective of pagination. + // + // Notice that setting this field to true affects the performance. + bool require_total_size = 6; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2alpha.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; + + // The total count of matched [Product][google.cloud.retail.v2alpha.Product]s + // irrespective of pagination. The total number of + // [Product][google.cloud.retail.v2alpha.Product]s returned by pagination may + // be less than the + // [total_size][google.cloud.retail.v2alpha.ListProductsResponse.total_size] + // that matches. + // + // This field is ignored if + // [ListProductsRequest.require_total_size][google.cloud.retail.v2alpha.ListProductsRequest.require_total_size] + // is not set or + // [ListProductsRequest.page_token][google.cloud.retail.v2alpha.ListProductsRequest.page_token] + // is not empty. + int32 total_size = 3; +} + +// Request message for +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] +// method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask]. + // + // If + // [SetInventoryRequest.inventory.name][google.cloud.retail.v2alpha.Product.name] + // is empty or invalid, an INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2alpha.Product] named in + // [Product.name][google.cloud.retail.v2alpha.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2alpha.Product] to update has + // existing inventory information, the provided inventory information will be + // merged while respecting the last update time for each inventory field, + // using the provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2alpha.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // * [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2alpha.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2alpha.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2alpha.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] with + // name [Product.name][google.cloud.retail.v2alpha.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2alpha.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2alpha.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2alpha.Product], regardless of whether or + // not it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2alpha.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2alpha.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2alpha.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2alpha.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/promotion.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/promotion.proto new file mode 100644 index 00000000000..879449a42bb --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/purge_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/purge_config.proto new file mode 100644 index 00000000000..d05376b6e32 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/purge_config.proto @@ -0,0 +1,174 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Metadata related to the progress of the PurgeProducts operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeProductsMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were deleted successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; +} + +// Request message for PurgeProducts method. +message PurgeProductsRequest { + // Required. The resource name of the branch under which the products are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The filter string to specify the products to be deleted with a + // length limit of 5,000 characters. + // + // Empty string filter is not allowed. "*" implies delete all items in a + // branch. + // + // The eligible fields for filtering are: + // + // * `availability`: Double quoted + // [Product.availability][google.cloud.retail.v2alpha.Product.availability] + // string. + // * `create_time` : in ISO 8601 "zulu" format. + // + // Supported syntax: + // + // * Comparators (">", "<", ">=", "<=", "="). + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" + // * availability = "IN_STOCK" + // + // * Conjunctions ("AND") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + // + // * Disjunctions ("OR") + // Examples: + // * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + // + // * Can support nested queries. + // Examples: + // * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + // OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + // + // * Filter Limits: + // * Filter should not contain more than 6 conditions. + // * Max nesting depth should not exceed 2 levels. + // + // Examples queries: + // * Delete back order products created before a timestamp. + // create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any products. + bool force = 3; +} + +// Response of the PurgeProductsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeProductsResponse { + // The total count of products purged as a result of the operation. + int64 purge_count = 1; + + // A sample of the product names that will be deleted. + // Only populated if `force` is set to false. A max of 100 names will be + // returned and the names are chosen at random. + repeated string purge_sample = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2alpha.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/search_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/search_service.proto new file mode 100644 index 00000000000..24bfa34aacd --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/search_service.proto @@ -0,0 +1,937 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Please enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Please enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + additional_bindings { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search" + body: "*" + } + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2alpha.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on predefined textual fields, custom textual + // attributes and fulfillments. Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2alpha.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.value] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match the query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // + // By default, + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 products with the color facet "Red" + // and 200 products with the color facet "Blue". A query containing the + // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.key] + // would by default return only "Red" products in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue products available, "Blue" would not be shown as an + // available facet value. + // + // If "colorFamilies" is listed in "excludedFilterKeys", then the query + // returns the facet values "Red" with count 100 and "Blue" with count + // 200, because the "colorFamilies" key is now excluded from the filter. + // Because this field doesn't affect search results, the search results + // are still correctly filtered to return only "Red" products. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 20. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. In this case, server behavior + // defaults to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Google Retail Search will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.retail.v2alpha.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by Google Retail Search. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The relevance threshold of the search results. The higher relevance + // threshold is, the higher relevant results are shown and the less number of + // results are returned. + enum RelevanceThreshold { + // Default value. In this case, server behavior defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH]. + RELEVANCE_THRESHOLD_UNSPECIFIED = 0; + + // High relevance threshold. + HIGH = 1; + + // Medium relevance threshold. + MEDIUM = 2; + + // Low relevance threshold. + LOW = 3; + + // Lowest relevance threshold. + LOWEST = 4; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both [SearchResponse.SearchResult] and + // [SearchResponse.Facet] will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only [SearchResponse.SearchResult] will be returned. + // [SearchResponse.Facet] will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of + // [SearchRequest.facet_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2alpha.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet] will be returned. [SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + // + // If this field is empty, the request is considered a category browsing + // request and returned results are based on + // [filter][google.cloud.retail.v2alpha.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2alpha.SearchRequest.page_categories]. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2alpha.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2alpha.Product]s to + // return. If unspecified, defaults to a reasonable value. The maximum allowed + // value is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2alpha.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the + // [Product][google.cloud.retail.v2alpha.Product]s deemed by the API as + // relevant) in search results. This field is only considered if + // [page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] is + // unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2alpha.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2alpha.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The relevance threshold of the search results. + // + // Defaults to + // [RelevanceThreshold.HIGH][google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH], + // which means only the most relevant results are shown, and the least number + // of results are returned. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + RelevanceThreshold relevance_threshold = 15; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s or + // [LocalInventory][google.cloud.retail.v2alpha.LocalInventory]s are merged + // and de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.local_inventories.attributes][google.cloud.retail.v2alpha.LocalInventory.attributes] + // map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2alpha.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids] + // for + // [FulfillmentInfo.type][google.cloud.retail.v2alpha.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + PersonalizationSpec personalization_spec = 32; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 34; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + optional SpellCorrectionSpec spell_correction_spec = 35; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2alpha.Product.id] of the searched + // [Product][google.cloud.retail.v2alpha.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2alpha.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2alpha.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2alpha.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2alpha.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2alpha.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2alpha.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2alpha.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2alpha.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2alpha.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2alpha.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2alpha.Product] attributes. Notice that + // the rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2alpha.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + + // The minimum value in the + // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2alpha.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2alpha.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query is used for search. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2alpha.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config.proto new file mode 100644 index 00000000000..d0524012454 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config.proto @@ -0,0 +1,248 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +// The ServingConfig is passed in the search and predict request and together +// with the Catalog.default_branch, generates results. +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/servingConfig/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * 'no-price-reranking' + // * 'low-price-raranking' + // * 'medium-price-reranking' + // * 'high-price-reranking' + // + // If not specified, we choose default based on model type. Default value: + // 'no-price-reranking'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2alpha.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2alpha.Catalog] as the + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2alpha.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2alpha.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // 'medium-diversity' or 'high-diversity'. Currently supported values: + // + // * 'no-diversity' + // * 'low-diversity' + // * 'medium-diversity' + // * 'high-diversity' + // * 'auto-diversity' + // + // If not specified, we choose default based on recommendation model + // type. Default value: 'no-diversity'. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // Whether to add additional category filters on the 'similar-items' model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * 'no-category-match': No additional filtering of original results from + // the model and the customer's filters. + // * 'relaxed-category-match': Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2alpha.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config_service.proto new file mode 100644 index 00000000000..311126510e2 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/serving_config_service.proto @@ -0,0 +1,241 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2alpha/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in + // a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a + // FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event.proto new file mode 100644 index 00000000000..ca25f3003fe --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event.proto @@ -0,0 +1,347 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2alpha/common.proto"; +import "google/cloud/retail/v2alpha/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2alpha.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2alpha.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is optional except for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2alpha.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2alpha.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See + // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, please replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2alpha.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2alpha.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event_service.proto new file mode 100644 index 00000000000..35fe33f4bae --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/user_event_service.proto @@ -0,0 +1,189 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2alpha; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/cloud/retail/v2alpha/import_config.proto"; +import "google/cloud/retail/v2alpha/purge_config.proto"; +import "google/cloud/retail/v2alpha/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2alpha"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2alpha"; +option ruby_package = "Google::Cloud::Retail::V2alpha"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // Operation.response is of type ImportResponse. Note that it is + // possible for a subset of the items to be successfully inserted. + // Operation.metadata is of type ImportMetadata. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2alpha.ImportMetadata" + }; + } + + // Starts a user event rejoin operation with latest product catalog. Events + // will not be annotated with detailed product information if product is + // missing from the catalog at the time the user event is ingested, and these + // events are stored as unjoined events with a limited usage on training and + // serving. This method can be used to start a join operation on specified + // events with latest version of product catalog. It can also be used to + // correct events joined with the wrong product catalog. A rejoin operation + // can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // UserEventRejoinScope to UNJOINED_EVENTS. + // If the rejoining aims at correcting product catalog information in joined + // events, set UserEventRejoinScope to JOINED_EVENTS. + // If all events needs to be rejoined, set UserEventRejoinScope to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + // invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for RejoinUserEvents method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for RejoinUserEvents method. +message RejoinUserEventsMetadata {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog.proto new file mode 100644 index 00000000000..c95e3ac9340 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog.proto @@ -0,0 +1,436 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures what level the product should be uploaded with regards to +// how users will be send events and how predictions will be made. +message ProductLevelConfig { + // The type of [Product][google.cloud.retail.v2beta.Product]s allowed to be + // ingested into the catalog. Acceptable values are: + // + // * `primary` (default): You can ingest + // [Product][google.cloud.retail.v2beta.Product]s of all types. When + // ingesting a [Product][google.cloud.retail.v2beta.Product], its type will + // default to + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // if unset. + // * `variant` (incompatible with Retail Search): You can only + // ingest + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. This means + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // cannot be empty. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `variant` and + // [merchant_center_product_id_field][google.cloud.retail.v2beta.ProductLevelConfig.merchant_center_product_id_field] + // is `itemGroupId`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string ingestion_product_type = 1; + + // Which field of [Merchant Center + // Product](/bigquery-transfer/docs/merchant-center-products-schema) should be + // imported as [Product.id][google.cloud.retail.v2beta.Product.id]. Acceptable + // values are: + // + // * `offerId` (default): Import `offerId` as the product ID. + // * `itemGroupId`: Import `itemGroupId` as the product ID. Notice that Retail + // API will choose one item from the ones with the same `itemGroupId`, and + // use it to represent the item group. + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // If this field is `itemGroupId` and + // [ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // is `variant`, an INVALID_ARGUMENT error is returned. + // + // See [Product + // levels](https://cloud.google.com/retail/docs/catalog#product-levels) + // for more details. + string merchant_center_product_id_field = 2; +} + +// Catalog level attribute config for an attribute. For example, if customers +// want to enable/disable facet for a specific attribute. +message CatalogAttribute { + // The type of an attribute. + enum AttributeType { + // The type of the attribute is unknown. + // + // Used when type cannot be derived from attribute that is not + // [in_use][google.cloud.retail.v2beta.CatalogAttribute.in_use]. + UNKNOWN = 0; + + // Textual attribute. + TEXTUAL = 1; + + // Numerical attribute. + NUMERICAL = 2; + } + + // The status of the indexable option of a catalog attribute. + enum IndexableOption { + // Value used when unset. Defaults to + // [INDEXABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.IndexableOption.INDEXABLE_ENABLED]. + INDEXABLE_OPTION_UNSPECIFIED = 0; + + // Indexable option enabled for an attribute. + INDEXABLE_ENABLED = 1; + + // Indexable option disabled for an attribute. + INDEXABLE_DISABLED = 2; + } + + // The status of the dynamic facetable option of a catalog attribute. + enum DynamicFacetableOption { + // Value used when unset. Defaults to + // [DYNAMIC_FACETABLE_ENABLED][google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption.DYNAMIC_FACETABLE_ENABLED]. + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0; + + // Dynamic facetable option enabled for an attribute. + DYNAMIC_FACETABLE_ENABLED = 1; + + // Dynamic facetable option disabled for an attribute. + DYNAMIC_FACETABLE_DISABLED = 2; + } + + // The status of the searchable option of a catalog attribute. + enum SearchableOption { + // Value used when unset. Defaults to + // [SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.SearchableOption.SEARCHABLE_DISABLED]. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // The status of the exact-searchable option of a catalog attribute. + enum ExactSearchableOption { + // Value used when unset. Defaults to + // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. + EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Exact searchable option enabled for an attribute. + EXACT_SEARCHABLE_ENABLED = 1; + + // Exact searchable option disabled for an attribute. + EXACT_SEARCHABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Indicates whether this attribute has been used by any + // products. `True` if at least one + // [Product][google.cloud.retail.v2beta.Product] is using this attribute in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + // Otherwise, this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] can be + // pre-loaded by using + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][], or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. + // + // Only pre-loaded + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are + // neither in use by products nor predefined can be deleted. + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s that are + // either in use by products or are predefined cannot be deleted; however, + // their configuration properties will reset to default values upon removal + // request. + // + // After catalog changes, it takes about 10 minutes for this field to update. + bool in_use = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The type of this attribute. This is derived from the attribute + // in [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if INDEXABLE_ENABLED attribute values + // are indexed so that it can be filtered, faceted, or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + IndexableOption indexable_option = 5; + + // If DYNAMIC_FACETABLE_ENABLED, attribute values are available for dynamic + // facet. Could only be DYNAMIC_FACETABLE_DISABLED if + // [CatalogAttribute.indexable_option][google.cloud.retail.v2beta.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if SEARCHABLE_ENABLED, attribute values + // are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If SEARCHABLE_ENABLED but attribute type is numerical, attribute values + // will not be searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], as + // there are no text values associated to numerical attributes. + SearchableOption searchable_option = 7; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, + // attribute values are filterable for recommendations. + // This option works for categorical features only, + // does not work for numerical features, inventory filtering. + RecommendationsFilteringOption recommendations_filtering_option = 8; + + // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. + // This property only applies to textual custom attributes and requires + // indexable set to enabled to enable exact-searchable. + ExactSearchableOption exact_searchable_option = 11; +} + +// Catalog level attribute config. +message AttributesConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/AttributesConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }; + + // Required. Immutable. The fully qualified resource name of the attribute + // config. Format: `projects/*/locations/*/catalogs/*/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Enable attribute(s) config at catalog level. + // For example, indexable, dynamic_facetable, or searchable for each + // attribute. + // + // The key is catalog attribute's name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // + // The maximum number of catalog attributes allowed in a request is 1000. + map catalog_attributes = 2; + + // Output only. The + // [AttributeConfigLevel][google.cloud.retail.v2beta.AttributeConfigLevel] + // used for this catalog. + AttributeConfigLevel attribute_config_level = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Catalog level autocomplete config for customers to customize autocomplete +// feature's settings. +message CompletionConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/CompletionConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }; + + // Required. Immutable. Fully qualified name + // `projects/*/locations/*/catalogs/*/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the matching order for autocomplete suggestions, e.g., a query + // consisting of 'sh' with 'out-of-order' specified would suggest "women's + // shoes", whereas a query of 'red s' with 'exact-prefix' specified would + // suggest "red shoes". Currently supported values: + // + // * 'out-of-order' + // * 'exact-prefix' + // + // Default value: 'exact-prefix'. + string matching_order = 2; + + // The maximum number of autocomplete suggestions returned per term. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + int32 max_suggestions = 3; + + // The minimum number of characters needed to be typed in order to get + // suggestions. Default value is 2. If left unset or set to 0, then will + // fallback to default value. + // + // Value range is 1 to 20. + int32 min_prefix_length = 4; + + // If set to true, the auto learning function is enabled. Auto learning uses + // user data to generate suggestions using ML techniques. Default value is + // false. Only after enabling auto learning can users use `cloud-retail` + // data in + // [CompleteQueryRequest][google.cloud.retail.v2beta.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The source data for the latest import of the autocomplete + // suggestion phrases. + CompletionDataInputConfig suggestions_input_config = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest suggestion terms + // list import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_suggestions_import_operation = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest denylist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_denylist_import_operation = 8 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the LRO corresponding to the latest allowlist import. + // + // Can use [GetOperation][google.longrunning.Operations.GetOperation] API to + // retrieve the latest state of the Long Running Operation. + string last_allowlist_import_operation = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Represents a link between a Merchant Center account and a branch. +// Once a link is established, products from the linked merchant center account +// will be streamed to the linked branch. +message MerchantCenterLink { + // Required. The linked [Merchant center account + // id](https://developers.google.com/shopping-content/guides/accountstatuses). + // The account must be a standalone account or a sub-account of a MCA. + int64 merchant_center_account_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch id (e.g. 0/1/2) within this catalog that products from + // merchant_center_account_id are streamed to. When updating this field, an + // empty value will use the currently configured default branch. However, + // changing the default branch later on won't change the linked branch here. + // + // A single branch id can only have one linked merchant center account id. + string branch_id = 2; + + // String representing the destination to import for, all if left empty. + // List of possible values is given in [Included + // destination](https://support.google.com/merchants/answer/7501026). + // List of allowed string values: + // "Shopping_ads", "Buy_on_google_listings", "Display_ads", "Local_inventory + // _ads", "Free_listings", "Free_local_listings" + // NOTE: The string values are case sensitive. + repeated string destinations = 3; + + // Region code of offers to accept. 2-letter Uppercase ISO 3166-1 alpha-2 + // code. List of values can be found + // [here](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) + // under the `region` tag. If left blank no region filtering will be + // performed. + // + // Example value: `US`. + string region_code = 4; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // ISO 639-1. + // + // This specifies the language of offers in Merchant Center that will be + // accepted. If empty no language filtering will be performed. + // + // Example value: `en`. + string language_code = 5; +} + +// Configures Merchant Center linking. +// Links contained in the config will be used to sync data from a Merchant +// Center account to a Cloud Retail branch. +message MerchantCenterLinkingConfig { + // Links between Merchant Center accounts and branches. + repeated MerchantCenterLink links = 1; +} + +// The catalog configuration. +message Catalog { + option (google.api.resource) = { + type: "retail.googleapis.com/Catalog" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}" + }; + + // Required. Immutable. The fully qualified resource name of the catalog. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. Immutable. The catalog display name. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Required. The product level configuration. + ProductLevelConfig product_level_config = 4 + [(google.api.field_behavior) = REQUIRED]; + + // The Merchant Center linking configuration. + // Once a link is added, the data stream from Merchant Center to Cloud Retail + // will be enabled automatically. The requester must have access to the + // merchant center account in order to make changes to this field. + MerchantCenterLinkingConfig merchant_center_linking_config = 6; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog_service.proto new file mode 100644 index 00000000000..7001c211324 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/catalog_service.proto @@ -0,0 +1,522 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/catalog.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CatalogServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for managing catalog configuration. +service CatalogService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated + // with the project. + rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*}/catalogs" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s. + rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) { + option (google.api.http) = { + patch: "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}" + body: "catalog" + }; + option (google.api.method_signature) = "catalog,update_mask"; + } + + // Set a specified branch id as default branch. API methods such as + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // will treat requests using "default_branch" to the actual branch id set as + // default. + // + // For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as + // default, setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent + // to setting + // [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to + // `projects/*/locations/*/catalogs/*/branches/1`. + // + // Using multiple branches can be useful when developers would like + // to have a staging branch to test and verify for future usage. When it + // becomes ready, developers switch on the staging branch using this API while + // keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` + // as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] + // to route the traffic to this staging branch. + // + // CAUTION: If you have live predict/search traffic, switching the default + // branch could potentially cause outages if the ID space of the new branch is + // very different from the old one. + // + // More specifically: + // + // * PredictionService will only return product IDs from branch {newBranch}. + // * SearchService will only return product IDs from branch {newBranch} + // (if branch is not explicitly set). + // * UserEventService will only join events with products from branch + // {newBranch}. + rpc SetDefaultBranch(SetDefaultBranchRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch" + body: "*" + }; + option (google.api.method_signature) = "catalog"; + } + + // Get which branch is currently default branch set by + // [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] + // method under a specified parent catalog. + rpc GetDefaultBranch(GetDefaultBranchRequest) + returns (GetDefaultBranchResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + }; + option (google.api.method_signature) = "catalog"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}" + body: "completion_config" + }; + option (google.api.method_signature) = "completion_config,update_mask"; + } + + // Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // The catalog attributes in the request will be updated in the catalog, or + // inserted if they do not exist. Existing catalog attributes not included in + // the request will remain unchanged. Attributes that are assigned to + // products, but do not exist at the catalog level, are always included in the + // response. The product attribute is assigned default values for missing + // catalog attribute fields, e.g., searchable and dynamic facetable options. + rpc UpdateAttributesConfig(UpdateAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + patch: "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}" + body: "attributes_config" + }; + option (google.api.method_signature) = "attributes_config,update_mask"; + } + + // Adds the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // add already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Removes all specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + rpc BatchRemoveCatalogAttributes(BatchRemoveCatalogAttributesRequest) + returns (BatchRemoveCatalogAttributesResponse) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating + // the catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// Request for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsRequest { + // Required. The account resource name with an associated location. + // + // If the caller does not have permission to list + // [Catalog][google.cloud.retail.v2beta.Catalog]s under this location, + // regardless of whether or not this location exists, a PERMISSION_DENIED + // error is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Maximum number of [Catalog][google.cloud.retail.v2beta.Catalog]s to return. + // If unspecified, defaults to 50. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 2; + + // A page token + // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token], + // received from a previous + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; +} + +// Response for +// [CatalogService.ListCatalogs][google.cloud.retail.v2beta.CatalogService.ListCatalogs] +// method. +message ListCatalogsResponse { + // All the customer's [Catalog][google.cloud.retail.v2beta.Catalog]s. + repeated Catalog catalogs = 1; + + // A token that can be sent as + // [ListCatalogsRequest.page_token][google.cloud.retail.v2beta.ListCatalogsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request for +// [CatalogService.UpdateCatalog][google.cloud.retail.v2beta.CatalogService.UpdateCatalog] +// method. +message UpdateCatalogRequest { + // Required. The [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If the caller does not have permission to update the + // [Catalog][google.cloud.retail.v2beta.Catalog], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Catalog][google.cloud.retail.v2beta.Catalog] to update does not + // exist, a NOT_FOUND error is returned. + Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Catalog][google.cloud.retail.v2beta.Catalog] to update. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message to set a specified branch as new default_branch. +message SetDefaultBranchRequest { + // Full resource name of the catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // The final component of the resource name of a branch. + // + // This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + // error is returned. + // + // If there are no sufficient active products in the targeted branch and + // [force][google.cloud.retail.v2beta.SetDefaultBranchRequest.force] is not + // set, a FAILED_PRECONDITION error is returned. + string branch_id = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Some note on this request, this can be retrieved by + // [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch] + // before next valid default branch set occurs. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string note = 3; + + // If set to true, it permits switching to a branch with + // [branch_id][google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id] + // even if it has no sufficient active products. + bool force = 4; +} + +// Request message to show which branch is currently the default branch. +message GetDefaultBranchRequest { + // The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response message of +// [CatalogService.GetDefaultBranch][google.cloud.retail.v2beta.CatalogService.GetDefaultBranch]. +message GetDefaultBranchResponse { + // Full resource name of the branch id currently set as default branch. + string branch = 1 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // The time when this branch is set to default. + google.protobuf.Timestamp set_time = 2; + + // This corresponds to + // [SetDefaultBranchRequest.note][google.cloud.retail.v2beta.SetDefaultBranchRequest.note] + // field, when this branch was set as default. + string note = 3; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2beta.CatalogService.GetCompletionConfig] +// method. +message GetCompletionConfigRequest { + // Required. Full CompletionConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/CompletionConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateCompletionConfig][google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to + // update does not exist, a NOT_FOUND error is returned. + CompletionConfig completion_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig] to update. + // The following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2beta.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2beta.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2beta.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2beta.CatalogService.GetAttributesConfig] +// method. +message GetAttributesConfigRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; +} + +// Request for +// [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] to update. + // The following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2beta.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute] +// method. +message AddCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute] +// method. +message RemoveCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name key of the + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes] +// method. +message BatchRemoveCatalogAttributesRequest { + // Required. The attributes config resource shared by all catalog attributes + // being deleted. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The attribute name keys of the + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s to delete. + // A maximum of 1000 catalog attributes can be deleted in a batch. + repeated string attribute_keys = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response of the +// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes]. +message BatchRemoveCatalogAttributesResponse { + // Catalog attributes that were deleted. Only attributes that are not [in + // use][CatalogAttribute.in_use] by products can be deleted. + repeated string deleted_catalog_attributes = 1; + + // Catalog attributes that were reset. Attributes that are [in + // use][CatalogAttribute.in_use] by products cannot be deleted, however their + // configuration properties will reset to default values upon removal request. + repeated string reset_catalog_attributes = 2; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute] +// method. +message ReplaceCatalogAttributeRequest { + // Required. Full AttributesConfig resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + string attributes_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/AttributesConfig" + } + ]; + + // Required. The updated + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to update. + // The following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/common.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/common.proto new file mode 100644 index 00000000000..fd1247636b4 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/common.proto @@ -0,0 +1,792 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. In this case, server behavior defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2beta.AttributeConfigLevel.CATALOG_LEVEL_ATTRIBUTE_CONFIG]. + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0; + + // At this level, we honor the attribute configurations set in + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes]. + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1; + + // At this level, we honor the attribute configurations set in + // [CatalogConfig.attribute_configs][]. + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2; +} + +// The type of solution. +enum SolutionType { + // Default value. + SOLUTION_TYPE_UNSPECIFIED = 0; + + // Used for Recommendations AI. + SOLUTION_TYPE_RECOMMENDATION = 1; + + // Used for Retail Search. + SOLUTION_TYPE_SEARCH = 2; +} + +// If filtering for recommendations is enabled. +enum RecommendationsFilteringOption { + // Value used when unset. + // In this case, server behavior defaults to + // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2beta.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; + + // Recommendation filtering is disabled. + RECOMMENDATIONS_FILTERING_DISABLED = 1; + + // Recommendation filtering is enabled. + RECOMMENDATIONS_FILTERING_ENABLED = 3; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2beta.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2beta.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_BROWSE = 2; +} + +// Metadata that is used to define a condition that triggers an action. +// A valid condition must specify at least one of 'query_terms' or +// 'products_filter'. If multiple fields are specified, the condition is met if +// all the fields are satisfied e.g. if a set of query terms and product_filter +// are set, then only items matching the product_filter for requests with a +// query matching the query terms wil get boosted. +message Condition { + // Query terms that we want to match on. + message QueryTerm { + // The value of the term to match on. + // Value cannot be empty. + // Value can have at most 3 terms if specified as a partial match. Each + // space separated string is considered as one term. + // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms + // and not allowed for a partial match. + string value = 1; + + // Whether this is supposed to be a full or partial match. + bool full_match = 2; + } + + // Used for time-dependent conditions. + // Example: Want to have rule applied for week long sale. + message TimeRange { + // Start of time range. Range is inclusive. + google.protobuf.Timestamp start_time = 1; + + // End of time range. Range is inclusive. + google.protobuf.Timestamp end_time = 2; + } + + // A list (up to 10 entries) of terms to match the query on. If not + // specified, match all queries. + // If many query terms are specified, the condition + // is matched if any of the terms is a match (i.e. using the OR operator). + repeated QueryTerm query_terms = 1; + + // Range of time(s) specifying when Condition is active. + // Condition true if any time range matches. + repeated TimeRange active_time_range = 3; +} + +// A rule is a condition-action pair +// +// * A condition defines when a rule is to be triggered. +// * An action specifies what occurs on that trigger. +// Currently rules only work for [controls][google.cloud.retail.v2beta.Control] +// with +// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. +message Rule { + // A boost action to apply to results matching condition specified above. + message BoostAction { + // Strength of the condition boost, which must be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 1; + + // The filter can have a max size of 5000 characters. + // An expression which specifies which products to apply an action to. + // The syntax and supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string products_filter = 2; + } + + // * Rule Condition: + // - No + // [Condition.query_terms][google.cloud.retail.v2beta.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2beta.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are applied to the + // retrieved products, in addition to any filters already provided with the + // SearchRequest. The AND operator is used to combine the query's existing + // filters with the filter rule(s). NOTE: May result in 0 results when + // filters conflict. + // * Action Result: Filters the returned objects to be ONLY those that passed + // the filter. + message FilterAction { + // A filter to apply on the matching condition results. Supported features: + // + // * [filter][google.cloud.retail.v2beta.Rule.FilterAction.filter] must be + // set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter]. + // See more + // details at the Retail Search + // [user guide](/retail/search/docs/filter-and-order#filter). + // * To filter products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue":
+ // *(id: ANY("product_1", "product_2"))
* + // *AND
* + // *(colorFamilies: ANY("Red", "Blue"))
* + string filter = 1; + } + + // Redirects a shopper to a specific page. + // + // * Rule Condition: + // - Must specify + // [Condition.query_terms][google.cloud.retail.v2beta.Condition.query_terms]. + // * Action Input: Request Query + // * Action Result: Redirects shopper to provided uri. + message RedirectAction { + // URL must have length equal or less than 2000 characters. + string redirect_uri = 1; + } + + // Creates a set of terms that will be treated as synonyms of each other. + // Example: synonyms of "sneakers" and "shoes". + // * "sneakers" will use a synonym of "shoes". + // * "shoes" will use a synonym of "sneakers". + message TwowaySynonymsAction { + // Defines a set of synonyms. + // Can specify up to 100 synonyms. + // Must specify at least 2 synonyms. + repeated string synonyms = 1; + } + + // Maps a set of terms to a set of synonyms. + // Set of synonyms will be treated as synonyms of each query term only. + // `query_terms` will not be treated as synonyms of each other. + // Example: "sneakers" will use a synonym of "shoes". + // "shoes" will not use a synonym of "sneakers". + message OnewaySynonymsAction { + // Terms from the search query. + // Will treat synonyms as their synonyms. + // Not themselves synonyms of the synonyms. + // Can specify up to 100 terms. + repeated string query_terms = 3; + + // Defines a set of synonyms. + // Cannot contain duplicates. + // Can specify up to 100 synonyms. + repeated string synonyms = 4; + + // Will be [deprecated = true] post migration; + repeated string oneway_terms = 2; + } + + // Prevents `query_term` from being associated with specified terms during + // search. + // Example: Don't associate "gShoe" and "cheap". + message DoNotAssociateAction { + // Terms from the search query. + // Will not consider do_not_associate_terms for search if in search query. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Cannot contain duplicates or the query term. + // Can specify up to 100 terms. + repeated string do_not_associate_terms = 3; + + // Will be [deprecated = true] post migration; + repeated string terms = 1; + } + + // Replaces a term in the query. Multiple replacement candidates can be + // specified. All `query_terms` will be replaced with the replacement term. + // Example: Replace "gShoe" with "google shoe". + message ReplacementAction { + // Terms from the search query. + // Will be replaced by replacement term. + // Can specify up to 100 terms. + repeated string query_terms = 2; + + // Term that will be used for replacement. + string replacement_term = 3; + + // Will be [deprecated = true] post migration; + string term = 1; + } + + // Prevents a term in the query from being used in search. + // Example: Don't search for "shoddy". + message IgnoreAction { + // Terms to ignore in the search query. + repeated string ignore_terms = 1; + } + + // An action must be provided. + oneof action { + // A boost action. + BoostAction boost_action = 2; + + // Redirects a shopper to a specific page. + RedirectAction redirect_action = 3; + + // Treats specific term as a synonym with a group of terms. + // Group of terms will not be treated as synonyms with the specific term. + OnewaySynonymsAction oneway_synonyms_action = 6; + + // Prevents term from being associated with other terms. + DoNotAssociateAction do_not_associate_action = 7; + + // Replaces specific terms in the query. + ReplacementAction replacement_action = 8; + + // Ignores specific terms from query during search. + IgnoreAction ignore_action = 9; + + // Filters results. + FilterAction filter_action = 10; + + // Treats a set of terms as synonyms of one another. + TwowaySynonymsAction twoway_synonyms_action = 11; + } + + // Required. The condition that triggers the rule. + // If the condition is empty, the rule will always apply. + Condition condition = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// An intended audience of the [Product][google.cloud.retail.v2beta.Product] for +// whom it's sold. +message Audience { + // The genders of the audience. Strongly encouraged to use the standard + // values: "male", "female", "unisex". + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [gender](https://support.google.com/merchants/answer/6324479). Schema.org + // property + // [Product.audience.suggestedGender](https://schema.org/suggestedGender). + repeated string genders = 1; + + // The age groups of the audience. Strongly encouraged to use the standard + // values: "newborn" (up to 3 months old), "infant" (3–12 months old), + // "toddler" (1–5 years old), "kids" (5–13 years old), "adult" (typically + // teens or older). + // + // At most 5 values are allowed. Each value must be a UTF-8 encoded string + // with a length limit of 128 characters. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Google Merchant Center property + // [age_group](https://support.google.com/merchants/answer/6324463). + // Schema.org property + // [Product.audience.suggestedMinAge](https://schema.org/suggestedMinAge) and + // [Product.audience.suggestedMaxAge](https://schema.org/suggestedMaxAge). + repeated string age_groups = 2; +} + +// The color information of a [Product][google.cloud.retail.v2beta.Product]. +message ColorInfo { + // The standard color families. Strongly recommended to use the following + // standard color groups: "Red", "Pink", "Orange", "Yellow", "Purple", + // "Green", "Cyan", "Blue", "Brown", "White", "Gray", "Black" and + // "Mixed". Normally it is expected to have only 1 color family. May consider + // using single "Mixed" instead of multiple values. + // + // A maximum of 5 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string color_families = 1; + + // The color display names, which may be different from standard color family + // names, such as the color aliases used in the website frontend. Normally + // it is expected to have only 1 color. May consider using single "Mixed" + // instead of multiple values. + // + // A maximum of 25 colors are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + repeated string colors = 2; +} + +// A custom attribute that is not explicitly modeled in +// [Product][google.cloud.retail.v2beta.Product]. +message CustomAttribute { + // The textual values of this custom attribute. For example, `["yellow", + // "green"]` when the key is "color". + // + // Empty string is not allowed. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated string text = 1; + + // The numerical values of this custom attribute. For example, `[2.3, 15.4]` + // when the key is "lengths_cm". + // + // Exactly one of [text][google.cloud.retail.v2beta.CustomAttribute.text] or + // [numbers][google.cloud.retail.v2beta.CustomAttribute.numbers] should be + // set. Otherwise, an INVALID_ARGUMENT error is returned. + repeated double numbers = 2; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is set to the + // deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about + // product-level attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are searchable by text queries in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // Only set if type [text][google.cloud.retail.v2beta.CustomAttribute.text] is + // set. Otherwise, a INVALID_ARGUMENT error is returned. + optional bool searchable = 3 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.Catalog] is set to the + // deprecated 'PRODUCT_LEVEL_ATTRIBUTE_CONFIG' mode. For information about + // product-level attribute configuration, see [Configuration + // modes](https://cloud.google.com/retail/docs/attribute-config#config-modes). + // If true, custom attribute values are indexed, so that they can be filtered, + // faceted or boosted in + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This field is ignored in a + // [UserEvent][google.cloud.retail.v2beta.UserEvent]. + // + // See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter], + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] + // for more details. + optional bool indexable = 4 [deprecated = true]; +} + +// Fulfillment information, such as the store IDs for in-store pickup or region +// IDs for different shipping methods. +message FulfillmentInfo { + // The fulfillment type, including commonly used types (such as pickup in + // store and same day delivery), and custom types. Customers have to map + // custom types to their display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + string type = 1; + + // The IDs for this [type][google.cloud.retail.v2beta.FulfillmentInfo.type], + // such as the store IDs for + // [FulfillmentInfo.type.pickup-in-store][google.cloud.retail.v2beta.FulfillmentInfo.type] + // or the region IDs for + // [FulfillmentInfo.type.same-day-delivery][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // + // A maximum of 3000 values are allowed. Each value must be a string with a + // length limit of 30 characters, matching the pattern `[a-zA-Z0-9_-]+`, such + // as "store1" or "REGION-2". Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string place_ids = 2; +} + +// [Product][google.cloud.retail.v2beta.Product] image. Recommendations AI and +// Retail Search do not use product images to improve prediction and search +// results. However, product images can be returned in results, and are shown in +// prediction or search previews in the console. +message Image { + // Required. URI of the image. + // + // This field must be a valid UTF-8 encoded URI with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + string uri = 1 [(google.api.field_behavior) = REQUIRED]; + + // Height of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 height = 2; + + // Width of the image in number of pixels. + // + // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 width = 3; +} + +// A floating point interval. +message Interval { + // The lower bound of the interval. If neither of the min fields are set, then + // the lower bound is negative infinity. + // + // This field must not be larger than max. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof min { + // Inclusive lower bound. + double minimum = 1; + + // Exclusive lower bound. + double exclusive_minimum = 2; + } + + // The upper bound of the interval. If neither of the max fields are set, then + // the upper bound is positive infinity. + // + // This field must be not smaller than min. + // Otherwise, an INVALID_ARGUMENT error is returned. + oneof max { + // Inclusive upper bound. + double maximum = 3; + + // Exclusive upper bound. + double exclusive_maximum = 4; + } +} + +// The price information of a [Product][google.cloud.retail.v2beta.Product]. +message PriceInfo { + // The price range of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + message PriceRange { + // The inclusive + // [Product.pricing_info.price][google.cloud.retail.v2beta.PriceInfo.price] + // interval of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval price = 1; + + // The inclusive + // [Product.pricing_info.original_price][google.cloud.retail.v2beta.PriceInfo.original_price] + // internal of all + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] having the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id]. + Interval original_price = 2; + } + + // The 3-letter currency code defined in [ISO + // 4217](https://www.iso.org/iso-4217-currency-codes.html). + // + // If this field is an unrecognizable currency code, an INVALID_ARGUMENT + // error is returned. + // + // The [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [Product.primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // must share the same + // [currency_code][google.cloud.retail.v2beta.PriceInfo.currency_code]. + // Otherwise, a FAILED_PRECONDITION error is returned. + string currency_code = 1; + + // Price of the product. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). Schema.org + // property [Offer.price](https://schema.org/price). + float price = 2; + + // Price of the product without any discount. If zero, by default set to be + // the [price][google.cloud.retail.v2beta.PriceInfo.price]. If set, + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] + // should be greater than or equal to + // [price][google.cloud.retail.v2beta.PriceInfo.price], otherwise an + // INVALID_ARGUMENT error is thrown. + float original_price = 3; + + // The costs associated with the sale of a particular product. Used for gross + // profit reporting. + // + // * Profit = [price][google.cloud.retail.v2beta.PriceInfo.price] - + // [cost][google.cloud.retail.v2beta.PriceInfo.cost] + // + // Google Merchant Center property + // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895). + float cost = 4; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // starts to be effective. This can be set as a future timestamp, and the + // [price][google.cloud.retail.v2beta.PriceInfo.price] is only used for search + // after + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // If so, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used before + // [price_effective_time][google.cloud.retail.v2beta.PriceInfo.price_effective_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_effective_time = 5; + + // The timestamp when the [price][google.cloud.retail.v2beta.PriceInfo.price] + // stops to be effective. The + // [price][google.cloud.retail.v2beta.PriceInfo.price] is used for search + // before + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // If this field is set, the + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] must + // be set and + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] is + // used after + // [price_expire_time][google.cloud.retail.v2beta.PriceInfo.price_expire_time]. + // + // Do not set if [price][google.cloud.retail.v2beta.PriceInfo.price] is always + // effective because it will cause additional latency during search. + google.protobuf.Timestamp price_expire_time = 6; + + // Output only. The price range of all the child + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s grouped together on the + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Only populated for + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + PriceRange price_range = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The rating of a [Product][google.cloud.retail.v2beta.Product]. +message Rating { + // The total number of ratings. This value is independent of the value of + // [rating_histogram][google.cloud.retail.v2beta.Rating.rating_histogram]. + // + // This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is + // returned. + int32 rating_count = 1; + + // The average rating of the [Product][google.cloud.retail.v2beta.Product]. + // + // The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is + // returned. + float average_rating = 2; + + // List of rating counts per rating value (index = rating - 1). The list is + // empty if there is no rating. If the list is non-empty, its size is + // always 5. Otherwise, an INVALID_ARGUMENT error is returned. + // + // For example, [41, 14, 13, 47, 303]. It means that the + // [Product][google.cloud.retail.v2beta.Product] got 41 ratings with 1 star, + // 14 ratings with 2 star, and so on. + repeated int32 rating_histogram = 3; +} + +// Information of an end user. +message UserInfo { + // Highly recommended for logged-in users. Unique identifier for logged-in + // user, such as a user name. Don't set for anonymous users. + // + // Always use a hashed value for this ID. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded + // model quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string user_id = 1; + + // The end user's IP address. This field is used to extract location + // information for personalization. + // + // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6 + // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This should not be set when: + // + // * setting + // [SearchRequest.user_info][google.cloud.retail.v2beta.SearchRequest.user_info]. + // * using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string ip_address = 2; + + // User agent as included in the HTTP header. Required for getting + // [SearchResponse.sponsored_results][google.cloud.retail.v2beta.SearchResponse.sponsored_results]. + // + // The field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This should not be set when using the client side event reporting with + // GTM or JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent] + // or if + // [direct_user_request][google.cloud.retail.v2beta.UserInfo.direct_user_request] + // is set. + string user_agent = 3; + + // True if the request is made directly from the end user, in which case the + // [ip_address][google.cloud.retail.v2beta.UserInfo.ip_address] and + // [user_agent][google.cloud.retail.v2beta.UserInfo.user_agent] can be + // populated from the HTTP request. This flag should be set only if the API + // request is made directly from the end user such as a mobile app (and not if + // a gateway or a server is processing and pushing the user events). + // + // This should not be set when using the JavaScript tag in + // [UserEventService.CollectUserEvent][google.cloud.retail.v2beta.UserEventService.CollectUserEvent]. + bool direct_user_request = 4; +} + +// The inventory information at a place (e.g. a store) identified +// by a place ID. +message LocalInventory { + // The place ID for the current set of inventory information. + string place_id = 1; + + // Product price and cost information. + // + // Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 2; + + // Additional local inventory attributes, for example, store name, promotion + // tags, etc. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * At most 30 attributes are allowed. + // * The key must be a UTF-8 encoded string with a length limit of 32 + // characters. + // * The key must match the pattern: `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, + // key0LikeThis or KEY_1_LIKE_THIS. + // * The attribute values must be of the same type (text or number). + // * Only 1 value is allowed for each attribute. + // * For text values, the length limit is 256 UTF-8 characters. + // * The attribute does not support search. The `searchable` field should be + // unset or set to false. + // * The max summed total bytes of custom attribute keys and values per + // product is 5MiB. + map attributes = 3; + + // Input only. Supported fulfillment types. Valid fulfillment type values + // include commonly used types (such as pickup in store and same day + // delivery), and custom types. Customers have to map custom types to their + // display names before rendering UI. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // All the elements must be distinct. Otherwise, an INVALID_ARGUMENT error is + // returned. + repeated string fulfillment_types = 4 + [(google.api.field_behavior) = INPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/completion_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/completion_service.proto new file mode 100644 index 00000000000..4db036647f9 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/completion_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "CompletionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Auto-completion service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// Enable Retail Search on Cloud Console before using this feature. +service CompletionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Completes the specified prefix with keyword suggestions. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc CompleteQuery(CompleteQueryRequest) returns (CompleteQueryResponse) { + option (google.api.http) = { + get: "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }; + } + + // Bulk import of processed completion dataset. + // + // Request processing is asynchronous. Partial updating is not supported. + // + // The operation is successfully finished only after the imported suggestions + // are indexed successfully and ready for serving. The process takes hours. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc ImportCompletionData(ImportCompletionDataRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportCompletionDataResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } +} + +// Auto-complete parameters. +message CompleteQueryRequest { + // Required. Catalog for which the completion is performed. + // + // Full resource name of catalog, such as + // `projects/*/locations/global/catalogs/default_catalog`. + string catalog = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The query used to generate suggestions. + // + // The maximum number of allowed characters is 255. + string query = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required field. A unique identifier for tracking visitors. For example, + // this could be implemented with an HTTP cookie, which should be able to + // uniquely identify a visitor on a single device. This unique identifier + // should not change if the visitor logs in or out of the website. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 7; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // The language filters applied to the output suggestions. If set, it should + // contain the language of the query. If not set, suggestions are returned + // without considering language restrictions. This is the BCP-47 language + // code, such as "en-US" or "sr-Latn". For more information, see [Tags for + // Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + // number of language codes is 3. + repeated string language_codes = 3; + + // The device type context for completion suggestions. + // It is useful to apply different suggestions on different device types, e.g. + // `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + // types. + // + // Supported formats: + // + // * `UNKNOWN_DEVICE_TYPE` + // + // * `DESKTOP` + // + // * `MOBILE` + // + // * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + string device_type = 4; + + // Determines which dataset to use for fetching completion. "user-data" will + // use the imported dataset through + // [CompletionService.ImportCompletionData][google.cloud.retail.v2beta.CompletionService.ImportCompletionData]. + // "cloud-retail" will use the dataset generated by cloud retail based on user + // events. If leave empty, it will use the "user-data". + // + // Current supported values: + // + // * user-data + // + // * cloud-retail: + // This option requires enabling auto-learning function first. See + // [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + string dataset = 6; + + // Completion max suggestions. If left unset or set to 0, then will fallback + // to the configured value + // [CompletionConfig.max_suggestions][google.cloud.retail.v2beta.CompletionConfig.max_suggestions]. + // + // The maximum allowed max suggestions is 20. If it is set higher, it will be + // capped by 20. + int32 max_suggestions = 5; +} + +// Response of the auto-complete query. +message CompleteQueryResponse { + // Resource that represents completion results. + message CompletionResult { + // The suggestion for the query. + string suggestion = 1; + + // Custom attributes for the suggestion term. + // + // * For "user-data", the attributes are additional custom attributes + // ingested through BigQuery. + // + // * For "cloud-retail", the attributes are product attributes generated + // by Cloud Retail. It requires + // [UserEvent.product_details][google.cloud.retail.v2beta.UserEvent.product_details] + // is imported properly. + map attributes = 2; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Results of the matching suggestions. The result list is ordered and the + // first result is top suggestion. + repeated CompletionResult completion_results = 1; + + // A unique complete token. This should be included in the + // [UserEvent.completion_detail][google.cloud.retail.v2beta.UserEvent.completion_detail] + // for search events resulting from this completion, which enables accurate + // attribution of complete model performance. + string attribution_token = 2; + + // Matched recent searches of this user. The maximum number of recent searches + // is 10. This field is a restricted feature. Contact Retail Search support + // team if you are interested in enabling it. + // + // This feature is only available when + // [CompleteQueryRequest.visitor_id][google.cloud.retail.v2beta.CompleteQueryRequest.visitor_id] + // field is set and [UserEvent][google.cloud.retail.v2beta.UserEvent] is + // imported. The recent searches satisfy the follow rules: + // + // * They are ordered from latest to oldest. + // + // * They are matched with + // [CompleteQueryRequest.query][google.cloud.retail.v2beta.CompleteQueryRequest.query] + // case insensitively. + // + // * They are transformed to lower case. + // + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control.proto new file mode 100644 index 00000000000..238f0f5fe69 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control.proto @@ -0,0 +1,100 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures dynamic metadata that can be linked to a +// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and affect search +// or recommendation results at serving time. +message Control { + option (google.api.resource) = { + type: "retail.googleapis.com/Control" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }; + + // The behavior/type of the control + // + // A behavior/type must be specified on creation. Type cannot be changed once + // specified (e.g. A Rule control will always be a Rule control.). An + // INVALID_ARGUMENT will be returned if either condition is violated. + oneof control { + // A facet specification to perform faceted search. + // + // Note that this field is deprecated and will throw NOT_IMPLEMENTED if + // used for creating a control. + SearchRequest.FacetSpec facet_spec = 3 [deprecated = true]; + + // A rule control - a condition-action pair. + // Enacts a set action when the condition is triggered. + // For example: Boost "gShoe" when query full matches "Running Shoes". + Rule rule = 4; + } + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/controls/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable control display name. Used in Retail UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is thrown. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Output only. List of [serving + // configuration][google.cloud.retail.v2beta.ServingConfig] ids that are + // associated with this control in the same + // [Catalog][google.cloud.retail.v2beta.Catalog]. + // + // Note the association is managed via the + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig], this is an + // output only denormalized view. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the control is used for. + // Currently we support setting only one type of solution at creation time. + // + // Only `SOLUTION_TYPE_SEARCH` value is supported at the moment. + // If no solution type is provided at creation time, will default to + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Specifies the use case for the control. + // Affects what condition fields can be set. + // Only settable by search controls. + // Will default to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2beta.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH] + // if not specified. Currently only allow one search_solution_use_case per + // control. + repeated SearchSolutionUseCase search_solution_use_case = 7; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control_service.proto new file mode 100644 index 00000000000..a0a9d2e732f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/control_service.proto @@ -0,0 +1,185 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying Control. +service ControlService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to create already + // exists, an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + body: "control" + }; + option (google.api.method_signature) = "parent,control,control_id"; + } + + // Deletes a Control. + // + // If the [Control][google.cloud.retail.v2beta.Control] to delete does not + // exist, a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2beta.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2beta.Control] to update does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}" + body: "control" + }; + option (google.api.method_signature) = "control,update_mask"; + } + + // Gets a Control. + rpc GetControl(GetControlRequest) returns (Control) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls by their parent + // [Catalog][google.cloud.retail.v2beta.Catalog]. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request for CreateControl method. +message CreateControlRequest { + // Required. Full resource name of parent catalog. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The Control to create. + Control control = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the Control, which will become the final + // component of the Control's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string control_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateControl method. +message UpdateControlRequest { + // Required. The Control to update. + Control control = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Control][google.cloud.retail.v2beta.Control] to update. The following are + // NOT supported: + // + // * [Control.name][google.cloud.retail.v2beta.Control.name] + // + // If not set or empty, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteControl method. +message DeleteControlRequest { + // Required. The resource name of the Control to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for GetControl method. +message GetControlRequest { + // Required. The resource name of the Control to get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Control" } + ]; +} + +// Request for ListControls method. +message ListControlsRequest { + // Required. The catalog resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListControls` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListControlsRequest.filter] is unset. + // * List controls that are used in a single ServingConfig: + // 'serving_config = "boosted_home_page_cvr"' + string filter = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListControls method. +message ListControlsResponse { + // All the Controls for a given catalog. + repeated Control controls = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/export_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/export_config.proto new file mode 100644 index 00000000000..de24f41907a --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/export_config.proto @@ -0,0 +1,97 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ExportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configuration of destination for Export related errors. +message ExportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage path for import errors. This must be an empty, + // existing Cloud Storage bucket. Export errors will be written to a file in + // this bucket, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Metadata related to the progress of the Export operation. This is +// returned by the google.longrunning.Operation.metadata field. +message ExportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; +} + +// Response of the ExportProductsRequest. If the long running +// operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Response of the ExportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ExportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Output result. +message OutputResult { + // Export result in BigQuery. + repeated BigQueryOutputResult bigquery_result = 1; +} + +// A BigQuery output result. +message BigQueryOutputResult { + // The ID of a BigQuery Dataset. + string dataset_id = 1; + + // The ID of a BigQuery Table. + string table_id = 2; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/import_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/import_config.proto new file mode 100644 index 00000000000..e544f6471a0 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/import_config.proto @@ -0,0 +1,386 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/date.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ImportConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Google Cloud Storage location for input content. +message GcsSource { + // Required. Google Cloud Storage URIs to input files. URI can be up to + // 2000 characters long. URIs can match the full object path (for example, + // `gs://bucket/directory/object.json`) or a pattern matching one or more + // files, such as `gs://bucket/directory/*.json`. A request can + // contain at most 100 files, and each file can be up to 2 GB. See + // [Importing product + // information](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog) + // for the expected file format and setup instructions. + repeated string input_uris = 1 [(google.api.field_behavior) = REQUIRED]; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: Using + // https://support.google.com/analytics/answer/3437719. + // + // Supported values for control imports: + // + // * `control` (default): One JSON + // [Control][google.cloud.retail.v2beta.Control] per line. + // + // Supported values for catalog attribute imports: + // + // * `catalog_attribute` (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] per line. + string data_schema = 2; +} + +// BigQuery source import data from. +message BigQuerySource { + // BigQuery table partition info. Leave this empty if the BigQuery table + // is not partitioned. + oneof partition { + // BigQuery time partitioned table's _PARTITIONDATE in YYYY-MM-DD format. + // + // Only supported in + // [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. + google.type.Date partition_date = 6; + } + + // The project ID (can be project # or ID) that the BigQuery source is in with + // a length limit of 128 characters. If not specified, inherits the project + // ID from the parent request. + string project_id = 5; + + // Required. The BigQuery data set to copy the data from with a length limit + // of 1,024 characters. + string dataset_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The BigQuery table to copy the data from with a length limit of + // 1,024 characters. + string table_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Intermediate Cloud Storage directory used for the import with a length + // limit of 2,000 characters. Can be specified if one wants to have the + // BigQuery export to a specific Cloud Storage directory. + string gcs_staging_dir = 3; + + // The schema to use when parsing the data from the source. + // + // Supported values for product imports: + // + // * `product` (default): One JSON + // [Product][google.cloud.retail.v2beta.Product] per line. Each product must + // have a valid [Product.id][google.cloud.retail.v2beta.Product.id]. + // * `product_merchant_center`: See [Importing catalog data from Merchant + // Center](https://cloud.google.com/retail/recommendations-ai/docs/upload-catalog#mc). + // + // Supported values for user events imports: + // + // * `user_event` (default): One JSON + // [UserEvent][google.cloud.retail.v2beta.UserEvent] per line. + // * `user_event_ga360`: + // The schema is available here: + // https://support.google.com/analytics/answer/3437719. + // * `user_event_ga4`: + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for auto-completion imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + string data_schema = 4; +} + +// The inline source for the input config for ImportProducts method. +message ProductInlineSource { + // Required. A list of products to update/create. Each product must have a + // valid [Product.id][google.cloud.retail.v2beta.Product.id]. Recommended max + // of 100 items. + repeated Product products = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The inline source for the input config for ImportUserEvents method. +message UserEventInlineSource { + // Required. A list of user events to import. Recommended max of 10k items. + repeated UserEvent user_events = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configuration of destination for Import related errors. +message ImportErrorsConfig { + // Required. Errors destination. + oneof destination { + // Google Cloud Storage prefix for import errors. This must be an empty, + // existing Cloud Storage directory. Import errors are written to + // sharded files in this directory, one per line, as a JSON-encoded + // `google.rpc.Status` message. + string gcs_prefix = 1; + } +} + +// Request message for Import methods. +message ImportProductsRequest { + // Indicates how imported products are reconciled with the existing products + // created or imported before. + enum ReconciliationMode { + // Defaults to INCREMENTAL. + RECONCILIATION_MODE_UNSPECIFIED = 0; + + // Inserts new products or updates existing products. + INCREMENTAL = 1; + + // Calculates diff and replaces the entire product dataset. Existing + // products may be deleted if they are not present in the source location. + FULL = 2; + } + + // Required. + // `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + // + // If no updateMask is specified, requires products.create permission. + // If updateMask is specified, requires products.update permission. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Deprecated. This field has no effect. + string request_id = 6 [deprecated = true]; + + // Required. The desired input location of the data. + ProductInputConfig input_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. + ImportErrorsConfig errors_config = 3; + + // Indicates which fields in the provided imported `products` to update. If + // not set, all fields are updated. + google.protobuf.FieldMask update_mask = 4; + + // The mode of reconciliation between existing products and the products to be + // imported. Defaults to + // [ReconciliationMode.INCREMENTAL][google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL]. + ReconciliationMode reconciliation_mode = 5; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + // to be within the same project as + // [ImportProductsRequest.parent][google.cloud.retail.v2beta.ImportProductsRequest.parent]. + // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + // `pubsub.topics.publish` IAM permission on the topic. + string notification_pubsub_topic = 7; +} + +// Request message for the ImportUserEvents request. +message ImportUserEventsRequest { + // Required. `projects/1234/locations/global/catalogs/default_catalog` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + UserEventInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // The desired location of errors incurred during the Import. Cannot be set + // for inline user event imports. + ImportErrorsConfig errors_config = 3; +} + +// Request message for ImportCompletionData methods. +message ImportCompletionDataRequest { + // Required. The catalog which the suggestions dataset belongs to. + // + // Format: `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The desired input location of the data. + CompletionDataInputConfig input_config = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 3; +} + +// The input config source for products. +message ProductInputConfig { + // Required. The source of the input. + oneof source { + // The Inline source for the input content for products. + ProductInlineSource product_inline_source = 1; + + // Google Cloud Storage location for the input content. + GcsSource gcs_source = 2; + + // BigQuery input source. + BigQuerySource big_query_source = 3; + } +} + +// The input config source for user events. +message UserEventInputConfig { + // The source of the input. + oneof source { + // Required. The Inline source for the input content for UserEvents. + UserEventInlineSource user_event_inline_source = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. Google Cloud Storage location for the input content. + GcsSource gcs_source = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. BigQuery input source. + BigQuerySource big_query_source = 3 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// The input config source for completion data. +message CompletionDataInputConfig { + // The source of the input. + // + // Supported + // [BigQuerySource.data_schema][google.cloud.retail.v2beta.BigQuerySource.data_schema] + // values for suggestions imports: + // + // * `suggestions` (default): One JSON completion suggestion per line. + // * `denylist`: One JSON deny suggestion per line. + // * `allowlist`: One JSON allow suggestion per line. + oneof source { + // Required. BigQuery input source. + // + // Add the IAM permission "BigQuery Data Viewer" for + // cloud-retail-customer-data-access@system.gserviceaccount.com before + // using this feature otherwise an error is thrown. + BigQuerySource big_query_source = 1 + [(google.api.field_behavior) = REQUIRED]; + } +} + +// Metadata related to the progress of the Import operation. This is +// returned by the google.longrunning.Operation.metadata field. +message ImportMetadata { + // Operation create time. + google.protobuf.Timestamp create_time = 1; + + // Operation last update time. If the operation is done, this is also the + // finish time. + google.protobuf.Timestamp update_time = 2; + + // Count of entries that were processed successfully. + int64 success_count = 3; + + // Count of entries that encountered errors while processing. + int64 failure_count = 4; + + // Deprecated. This field is never set. + string request_id = 5 [deprecated = true]; + + // Pub/Sub topic for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; +} + +// Response of the +// [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. If +// the long running operation is done, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportProductsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors in the request if set. + ImportErrorsConfig errors_config = 2; +} + +// Response of the ImportUserEventsRequest. If the long running +// operation was successful, then this message is returned by the +// google.longrunning.Operations.response field if the operation was successful. +message ImportUserEventsResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; + + // Echoes the destination for the complete errors if this field was set in + // the request. + ImportErrorsConfig errors_config = 2; + + // Aggregated statistics of user event import status. + UserEventImportSummary import_summary = 3; +} + +// A summary of import result. The UserEventImportSummary summarizes +// the import status for user events. +message UserEventImportSummary { + // Count of user events imported with complete existing catalog information. + int64 joined_events_count = 1; + + // Count of user events imported, but with catalog information not found + // in the imported catalog. + int64 unjoined_events_count = 2; +} + +// Response of the +// [ImportCompletionDataRequest][google.cloud.retail.v2beta.ImportCompletionDataRequest]. +// If the long running operation is done, this message is returned by the +// google.longrunning.Operations.response field if the operation is successful. +message ImportCompletionDataResponse { + // A sample of errors encountered while processing the request. + repeated google.rpc.Status error_samples = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model.proto new file mode 100644 index 00000000000..ea4bd30c6c9 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model.proto @@ -0,0 +1,238 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ModelProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Metadata that describes the training and serving parameters of a +// [Model][google.cloud.retail.v2beta.Model]. A +// [Model][google.cloud.retail.v2beta.Model] can be associated with a +// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and then queried +// through the Predict API. +message Model { + option (google.api.resource) = { + type: "retail.googleapis.com/Model" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }; + + // Represents an ordered combination of valid serving configs, which + // can be used for `PAGE_OPTIMIZATION` recommendations. + message ServingConfigList { + // Optional. A set of valid serving configs that may be used for + // `PAGE_OPTIMIZATION`. + repeated string serving_config_ids = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // The serving state of the model. + enum ServingState { + // Unspecified serving state. + SERVING_STATE_UNSPECIFIED = 0; + + // The model is not serving. + INACTIVE = 1; + + // The model is serving and can be queried. + ACTIVE = 2; + + // The model is trained on tuned hyperparameters and can be + // queried. + TUNED = 3; + } + + // The training state of the model. + enum TrainingState { + // Unspecified training state. + TRAINING_STATE_UNSPECIFIED = 0; + + // The model training is paused. + PAUSED = 1; + + // The model is training. + TRAINING = 2; + } + + // Describes whether periodic tuning is enabled for this model + // or not. Periodic tuning is scheduled at most every three months. You can + // start a tuning process manually by using the `TuneModel` + // method, which starts a tuning process immediately and resets the quarterly + // schedule. Enabling or disabling periodic tuning does not affect any + // current tuning processes. + enum PeriodicTuningState { + // Unspecified default value, should never be explicitly set. + PERIODIC_TUNING_STATE_UNSPECIFIED = 0; + + // The model has periodic tuning disabled. Tuning + // can be reenabled by calling the `EnableModelPeriodicTuning` + // method or by calling the `TuneModel` method. + PERIODIC_TUNING_DISABLED = 1; + + // The model cannot be tuned with periodic tuning OR the + // `TuneModel` method. Hide the options in customer UI and + // reject any requests through the backend self serve API. + ALL_TUNING_DISABLED = 3; + + // The model has periodic tuning enabled. Tuning + // can be disabled by calling the `DisableModelPeriodicTuning` + // method. + PERIODIC_TUNING_ENABLED = 2; + } + + // Describes whether this model have sufficient training data + // to be continuously trained. + enum DataState { + // Unspecified default value, should never be explicitly set. + DATA_STATE_UNSPECIFIED = 0; + + // The model has sufficient training data. + DATA_OK = 1; + + // The model does not have sufficient training data. Error + // messages can be queried via Stackdriver. + DATA_ERROR = 2; + } + + // Required. The fully qualified resource name of the model. + // + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + // catalog_id has char limit of 50. + // recommendation_model_id has char limit of 40. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The display name of the model. + // + // Should be human readable, used to display Recommendation Models in the + // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 + // characters. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The training state that the model is in (e.g. + // `TRAINING` or `PAUSED`). + // + // Since part of the cost of running the service + // is frequency of training - this can be used to determine when to train + // model in order to control cost. If not specified: the default value for + // `CreateModel` method is `TRAINING`. The default value for + // `UpdateModel` method is to keep the state the same as before. + TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. + ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was created at. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was last updated. E.g. + // if a Recommendation Model was paused - this would be the time the pause was + // initiated. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The type of model e.g. `home-page`. + // + // Currently supported values: `recommended-for-you`, `others-you-may-like`, + // `frequently-bought-together`, `page-optimization`, `similar-items`, + // `buy-it-again`, and `recently-viewed`(readonly value). + // + // This field together with + // [optimization_objective][google.cloud.retail.v2beta.Model.optimization_objective] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string type = 7 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optimization objective e.g. `cvr`. + // + // Currently supported + // values: `ctr`, `cvr`, `revenue-per-order`. + // + // If not specified, we choose default based on model type. + // Default depends on type of recommendation: + // + // `recommended-for-you` => `ctr` + // + // `others-you-may-like` => `ctr` + // + // `frequently-bought-together` => `revenue_per_order` + // + // This field together with + // [optimization_objective][google.cloud.retail.v2beta.Model.type] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The state of periodic tuning. + // + // The period we use is 3 months - to do a + // one-off tune earlier use the `TuneModel` method. Default value + // is `PERIODIC_TUNING_ENABLED`. + PeriodicTuningState periodic_tuning_state = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the latest successful tune finished. + google.protobuf.Timestamp last_tune_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The tune operation associated with the model. + // + // Can be used to determine if there is an ongoing tune for this + // recommendation. Empty field implies no tune is goig on. + string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of data requirements for this model: `DATA_OK` and + // `DATA_ERROR`. + // + // Recommendation model cannot be trained if the data is in + // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even + // if serving state is `ACTIVE`: models were trained successfully before, but + // cannot be refreshed because model no longer has sufficient + // data for training. + DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering + // by attributes is enabled for the model. + RecommendationsFilteringOption filtering_option = 18 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of valid serving configs associated with the + // PageOptimizationConfig. + repeated ServingConfigList serving_config_lists = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model_service.proto new file mode 100644 index 00000000000..3a9a3c5a360 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/model_service.proto @@ -0,0 +1,244 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ModelServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for performing CRUD operations on models. +// Recommendation models contain all the metadata necessary to generate a set of +// models for the `Predict()` API. A model is queried +// indirectly via a ServingConfig, which associates a model with a +// given Placement (e.g. Frequently Bought Together on Home Page). +// +// This service allows you to do the following: +// +// * Initiate training of a model. +// * Pause training of an existing model. +// * List all the available models along with their metadata. +// * Control their tuning schedule. +service ModelService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new model. + rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" + body: "model" + }; + option (google.api.method_signature) = "parent,model"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.Model" + metadata_type: "google.cloud.retail.v2beta.CreateModelMetadata" + }; + } + + // Pauses the training of an existing model. + rpc PauseModel(PauseModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resumes the training of an existing model. + rpc ResumeModel(ResumeModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an existing model. + rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the models linked to this event store. + rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" + }; + option (google.api.method_signature) = "parent"; + } + + // Update of model metadata. Only fields that + // currently can be updated are: `filtering_option` and + // `periodic_tuning_state`. + // If other values are provided, this API method ignores them. + rpc UpdateModel(UpdateModelRequest) returns (Model) { + option (google.api.http) = { + patch: "/v2beta/{model.name=projects/*/locations/*/catalogs/*/models/*}" + body: "model" + }; + option (google.api.method_signature) = "model,update_mask"; + } + + // Tunes an existing model. + rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:tune" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.TuneModelResponse" + metadata_type: "google.cloud.retail.v2beta.TuneModelMetadata" + }; + } +} + +// Request for creating a model. +message CreateModelRequest { + // Required. The parent resource under which to create the model. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The payload of the [Model][google.cloud.retail.v2beta.Model] to + // create. + Model model = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Whether to run a dry run to validate the request (without + // actually creating the model). + bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating an existing model. +message UpdateModelRequest { + // Required. The body of the updated + // [Model][google.cloud.retail.v2beta.Model]. + Model model = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided 'model' to + // update. If not set, by default updates all fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for pausing training of a model. +message PauseModelRequest { + // Required. The name of the model to pause. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for resuming training of a model. +message ResumeModelRequest { + // Required. The name of the model to resume. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing models associated with a resource. +message ListModelsRequest { + // Required. The parent for which to list models. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 50. Max allowed value is 1000. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListModels` + // call. Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a model. +message DeleteModelRequest { + // Required. The resource name of the + // [Model][google.cloud.retail.v2beta.Model] to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Response to a ListModelRequest. +message ListModelsResponse { + // List of Models. + repeated Model models = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request to manually start a tuning process now (instead of waiting for +// the periodically scheduled tuning to happen). +message TuneModelRequest { + // Required. The resource name of the model to tune. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Metadata associated with a create operation. +message CreateModelMetadata { + // The resource name of the model that this create applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Metadata associated with a tune operation. +message TuneModelMetadata { + // The resource name of the model that this tune applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Response associated with a tune operation. +message TuneModelResponse {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/prediction_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/prediction_service.proto new file mode 100644 index 00000000000..1ac3026d63f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/prediction_service.proto @@ -0,0 +1,224 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PredictionServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for making recommendation prediction. +service PredictionService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Makes a recommendation prediction. + rpc Predict(PredictRequest) returns (PredictResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict" + body: "*" + additional_bindings { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Managing serving configurations] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Context about the user, what they are looking at and what action + // they took to trigger the predict request. Note that this user event detail + // won't be ingested to userEvent logs. Thus, a separate userEvent write + // request is required for event logging. + // + // Don't set + // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id] to the same + // fixed ID for different users. If you are trying to receive non-personalized + // recommendations (not recommended; this can negatively impact model + // performance), instead set + // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id] to + // a random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return. Set this property to the number of + // prediction results needed. If zero, the service will choose a reasonable + // default. The maximum allowed value is 100. Values above 100 will be coerced + // to 100. + int32 page_size = 3; + + // This field is not used; leave it unset. + string page_token = 4 [deprecated = true]; + + // Filter for restricting prediction results with a length limit of 5,000 + // characters. Accepts values for tags and the `filterOutOfStockItems` flag. + // + // * Tag expressions. Restricts predictions to products that match all of the + // specified tags. Boolean operators `OR` and `NOT` are supported if the + // expression is enclosed in parentheses, and must be separated from the + // tag values by a space. `-"tagA"` is also supported and is equivalent to + // `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + // with a size limit of 1,000 characters. + // + // Note: "Recently viewed" models don't support tag filtering at the + // moment. + // + // * filterOutOfStockItems. Restricts predictions to products that do not + // have a + // stockState value of OUT_OF_STOCK. + // + // Examples: + // + // * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + // * filterOutOfStockItems tag=(-"promotional") + // * filterOutOfStockItems + // + // If your filter blocks all prediction results, the API will return generic + // (unfiltered) popular products. If you only want results strictly matching + // the filters, set `strictFiltering` to True in `PredictRequest.params` to + // receive empty results instead. + // Note that the API will never return items with storageStatus of "EXPIRED" + // or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + string filter = 5; + + // Use validate only mode for this prediction query. If set to true, a + // dummy model will be used that returns arbitrary products. + // Note that the validate only mode should only be used for testing the API, + // or if the model is not ready. + bool validate_only = 6; + + // Additional domain specific parameters for the predictions. + // + // Allowed values: + // + // * `returnProduct`: Boolean. If set to true, the associated product + // object will be returned in the `results.metadata` field in the + // prediction response. + // * `returnScore`: Boolean. If set to true, the prediction 'score' + // corresponding to each returned product will be set in the + // `results.metadata` field in the prediction response. The given + // 'score' indicates the probability of an product being clicked/purchased + // given the user's context and history. + // * `strictFiltering`: Boolean. True by default. If set to false, the service + // will return generic (unfiltered) popular products instead of empty if + // your filter blocks all prediction results. + // * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-price-reranking', 'low-price-reranking', + // 'medium-price-reranking', 'high-price-reranking'}. This gives + // request-level control and adjusts prediction results based on product + // price. + // * `diversityLevel`: String. Default empty. If set to be non-empty, then + // it needs to be one of {'no-diversity', 'low-diversity', + // 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + // request-level control and adjusts prediction results based on product + // category. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + map params = 7; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 8; +} + +// Response message for predict method. +message PredictResponse { + // PredictionResult represents the recommendation prediction results. + message PredictionResult { + // ID of the recommended product + string id = 1; + + // Additional product metadata / annotations. + // + // Possible values: + // + // * `product`: JSON representation of the product. Is set if + // `returnProduct` is set to true in `PredictRequest.params`. + // * `score`: Prediction score in double value. Is set if + // `returnScore` is set to true in `PredictRequest.params`. + map metadata = 2; + } + + // A list of recommended products. The order represents the ranking (from the + // most relevant product to the least). + repeated PredictionResult results = 1; + + // A unique attribution token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // recommendation, which enables accurate attribution of recommendation model + // performance. + string attribution_token = 2; + + // IDs of products in the request that were missing from the inventory. + repeated string missing_ids = 3; + + // True if the validateOnly property was set in the request. + bool validate_only = 4; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product.proto new file mode 100644 index 00000000000..8b10090136f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product.proto @@ -0,0 +1,577 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/promotion.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Branch" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" +}; + +// Product captures all metadata information of items to be recommended or +// searched. +message Product { + option (google.api.resource) = { + type: "retail.googleapis.com/Product" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }; + + // The type of this product. + enum Type { + // Default value. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + TYPE_UNSPECIFIED = 0; + + // The primary type. + // + // As the primary unit for predicting, indexing and search serving, a + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] is grouped with multiple + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + PRIMARY = 1; + + // The variant type. + // + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s usually share some common + // attributes on the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, but they have variant + // attributes like different colors, sizes and prices, etc. + VARIANT = 2; + + // The collection type. Collection products are bundled + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s that are sold together, + // such as a jewelry set with necklaces, earrings and rings, etc. + COLLECTION = 3; + } + + // Product availability. If this field is unspecified, the product is + // assumed to be in stock. + enum Availability { + // Default product availability. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK] + // if unset. + AVAILABILITY_UNSPECIFIED = 0; + + // Product in stock. + IN_STOCK = 1; + + // Product out of stock. + OUT_OF_STOCK = 2; + + // Product that is in pre-order state. + PREORDER = 3; + + // Product that is back-ordered (i.e. temporarily out of stock). + BACKORDER = 4; + } + + oneof expiration { + // The timestamp when this product becomes unavailable for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // If it is set, the [Product][google.cloud.retail.v2beta.Product] is not + // available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after [expire_time][google.cloud.retail.v2beta.Product.expire_time]. + // However, the product can still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] must be + // later than + // [available_time][google.cloud.retail.v2beta.Product.available_time] and + // [publish_time][google.cloud.retail.v2beta.Product.publish_time], + // otherwise an INVALID_ARGUMENT error is thrown. + // + // Corresponding properties: Google Merchant Center property + // [expiration_date](https://support.google.com/merchants/answer/6324499). + google.protobuf.Timestamp expire_time = 16; + + // Input only. The TTL (time to live) of the product. + // + // If it is set, it must be a non-negative value, and + // [expire_time][google.cloud.retail.v2beta.Product.expire_time] is set as + // current timestamp plus [ttl][google.cloud.retail.v2beta.Product.ttl]. The + // derived [expire_time][google.cloud.retail.v2beta.Product.expire_time] is + // returned in the output and [ttl][google.cloud.retail.v2beta.Product.ttl] + // is left blank when retrieving the + // [Product][google.cloud.retail.v2beta.Product]. + // + // If it is set, the product is not available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // after current timestamp plus + // [ttl][google.cloud.retail.v2beta.Product.ttl]. However, the product can + // still be retrieved by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // and + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + google.protobuf.Duration ttl = 17 + [(google.api.field_behavior) = INPUT_ONLY]; + } + + // Immutable. Full resource name of the product, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/product_id`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. [Product][google.cloud.retail.v2beta.Product] identifier, which + // is the final component of [name][google.cloud.retail.v2beta.Product.name]. + // For example, this field is "id_1", if + // [name][google.cloud.retail.v2beta.Product.name] is + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/id_1`. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [id](https://support.google.com/merchants/answer/6324405). Schema.org + // property [Product.sku](https://schema.org/sku). + string id = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The type of the product. Default to + // [Catalog.product_level_config.ingestion_product_type][google.cloud.retail.v2beta.ProductLevelConfig.ingestion_product_type] + // if unset. + Type type = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Variant group identifier. Must be an + // [id][google.cloud.retail.v2beta.Product.id], with the same parent branch + // with this product. Otherwise, an error is thrown. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s, this field can only be + // empty or set to the same value as + // [id][google.cloud.retail.v2beta.Product.id]. + // + // For VARIANT [Product][google.cloud.retail.v2beta.Product]s, this field + // cannot be empty. A maximum of 2,000 products are allowed to share the same + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [item_group_id](https://support.google.com/merchants/answer/6324507). + // Schema.org property + // [Product.inProductGroupWithID](https://schema.org/inProductGroupWithID). + string primary_product_id = 4; + + // The [id][google.cloud.retail.v2beta.Product.id] of the collection members + // when [type][google.cloud.retail.v2beta.Product.type] is + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]. + // + // Non-existent product ids are allowed. + // The [type][google.cloud.retail.v2beta.Product.type] of the members must be + // either [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] or + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] otherwise + // an INVALID_ARGUMENT error is thrown. Should not set it for other types. A + // maximum of 1000 values are allowed. Otherwise, an INVALID_ARGUMENT error is + // return. + repeated string collection_member_ids = 5; + + // The Global Trade Item Number (GTIN) of the product. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This field must be a Unigram. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Corresponding properties: Google Merchant Center property + // [gtin](https://support.google.com/merchants/answer/6324461). + // Schema.org property + // [Product.isbn](https://schema.org/isbn), + // [Product.gtin8](https://schema.org/gtin8), + // [Product.gtin12](https://schema.org/gtin12), + // [Product.gtin13](https://schema.org/gtin13), or + // [Product.gtin14](https://schema.org/gtin14). + // + // If the value is not a valid GTIN, an INVALID_ARGUMENT error is returned. + string gtin = 6; + + // Product categories. This field is repeated for supporting one product + // belonging to several parallel categories. Strongly recommended using the + // full path for better search / recommendation quality. + // + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, replace it with + // other character(s). + // + // For example, if a shoes product belongs to both + // ["Shoes & Accessories" -> "Shoes"] and + // ["Sports & Fitness" -> "Athletic Clothing" -> "Shoes"], it could be + // represented as: + // + // "categories": [ + // "Shoes & Accessories > Shoes", + // "Sports & Fitness > Athletic Clothing > Shoes" + // ] + // + // Must be set for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] otherwise an INVALID_ARGUMENT + // error is returned. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 5,000 characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [google_product_category][mc_google_product_category]. Schema.org property + // [Product.category] (https://schema.org/category). + // + // [mc_google_product_category]: + // https://support.google.com/merchants/answer/6324436 + repeated string categories = 7; + + // Required. Product title. + // + // This field must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [title](https://support.google.com/merchants/answer/6324415). Schema.org + // property [Product.name](https://schema.org/name). + string title = 8 [(google.api.field_behavior) = REQUIRED]; + + // The brands of the product. + // + // A maximum of 30 brands are allowed. Each brand must be a UTF-8 encoded + // string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [brand](https://support.google.com/merchants/answer/6324351). Schema.org + // property [Product.brand](https://schema.org/brand). + repeated string brands = 9; + + // Product description. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [description](https://support.google.com/merchants/answer/6324468). + // Schema.org property [Product.description](https://schema.org/description). + string description = 10; + + // Language of the title/description and other string attributes. Use language + // tags defined by [BCP 47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + // + // For product prediction, this field is ignored and the model automatically + // detects the text language. The + // [Product][google.cloud.retail.v2beta.Product] can include text in different + // languages, but duplicating [Product][google.cloud.retail.v2beta.Product]s + // to provide text in multiple languages can result in degraded model + // performance. + // + // For product search this field is in use. It defaults to "en-US" if unset. + string language_code = 11; + + // Highly encouraged. Extra product attributes to be included. For example, + // for products, this could include the store name, vendor, style, color, etc. + // These are very strong signals for recommendation model, thus we highly + // recommend providing the attributes here. + // + // Features that can take on one of a limited number of possible values. Two + // types of features can be set are: + // + // Textual features. some examples would be the brand/maker of a product, or + // country of a customer. Numerical features. Some examples would be the + // height/weight of a product, or age of a customer. + // + // For example: `{ "vendor": {"text": ["vendor123", "vendor456"]}, + // "lengths_cm": {"numbers":[2.3, 15.4]}, "heights_cm": {"numbers":[8.1, 6.4]} + // }`. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * Max entries count: 200. + // * The key must be a UTF-8 encoded string with a length limit of 128 + // characters. + // * For indexable attribute, the key must match the pattern: + // `[a-zA-Z0-9][a-zA-Z0-9_]*`. For example, `key0LikeThis` or + // `KEY_1_LIKE_THIS`. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a non-empty UTF-8 encoded string with a + // length limit of 256 characters. + // * For number attributes, at most 400 values are allowed. + map attributes = 12; + + // Custom tags associated with the product. + // + // At most 250 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. This value must be a UTF-8 + // encoded string with a length limit of 1,000 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // This tag can be used for filtering recommendation results by passing the + // tag as part of the + // [PredictRequest.filter][google.cloud.retail.v2beta.PredictRequest.filter]. + // + // Corresponding properties: Google Merchant Center property + // [custom_label_0–4](https://support.google.com/merchants/answer/6324473). + repeated string tags = 13; + + // Product price and cost information. + // + // Corresponding properties: Google Merchant Center property + // [price](https://support.google.com/merchants/answer/6324371). + PriceInfo price_info = 14; + + // The rating of this product. + Rating rating = 15; + + // The timestamp when this [Product][google.cloud.retail.v2beta.Product] + // becomes available for + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + google.protobuf.Timestamp available_time = 18; + + // The online availability of the + // [Product][google.cloud.retail.v2beta.Product]. Default to + // [Availability.IN_STOCK][google.cloud.retail.v2beta.Product.Availability.IN_STOCK]. + // + // Corresponding properties: Google Merchant Center property + // [availability](https://support.google.com/merchants/answer/6324448). + // Schema.org property [Offer.availability](https://schema.org/availability). + Availability availability = 19; + + // The available quantity of the item. + google.protobuf.Int32Value available_quantity = 20; + + // Fulfillment information, such as the store IDs for in-store pickup or + // region IDs for different shipping methods. + // + // All the elements must have distinct + // [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated FulfillmentInfo fulfillment_info = 21; + + // Canonical URL directly linking to the product detail page. + // + // It is strongly recommended to provide a valid uri for the product, + // otherwise the service performance could be significantly degraded. + // + // This field must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [link](https://support.google.com/merchants/answer/6324416). Schema.org + // property [Offer.url](https://schema.org/url). + string uri = 22; + + // Product images for the product. We highly recommend putting the main + // image first. + // + // A maximum of 300 images are allowed. + // + // Corresponding properties: Google Merchant Center property + // [image_link](https://support.google.com/merchants/answer/6324350). + // Schema.org property [Product.image](https://schema.org/image). + repeated Image images = 23; + + // The target group associated with a given audience (e.g. male, veterans, + // car owners, musicians, etc.) of the product. + Audience audience = 24; + + // The color of the product. + // + // Corresponding properties: Google Merchant Center property + // [color](https://support.google.com/merchants/answer/6324487). Schema.org + // property [Product.color](https://schema.org/color). + ColorInfo color_info = 25; + + // The size of the product. To represent different size systems or size types, + // consider using this format: [[[size_system:]size_type:]size_value]. + // + // For example, in "US:MENS:M", "US" represents size system; "MENS" represents + // size type; "M" represents size value. In "GIRLS:27", size system is empty; + // "GIRLS" represents size type; "27" represents size value. In "32 inches", + // both size system and size type are empty, while size value is "32 inches". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [size](https://support.google.com/merchants/answer/6324492), + // [size_type](https://support.google.com/merchants/answer/6324497), and + // [size_system](https://support.google.com/merchants/answer/6324502). + // Schema.org property [Product.size](https://schema.org/size). + repeated string sizes = 26; + + // The material of the product. For example, "leather", "wooden". + // + // A maximum of 20 values are allowed. Each value must be a UTF-8 encoded + // string with a length limit of 200 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [material](https://support.google.com/merchants/answer/6324410). Schema.org + // property [Product.material](https://schema.org/material). + repeated string materials = 27; + + // The pattern or graphic print of the product. For example, "striped", "polka + // dot", "paisley". + // + // A maximum of 20 values are allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [pattern](https://support.google.com/merchants/answer/6324483). Schema.org + // property [Product.pattern](https://schema.org/pattern). + repeated string patterns = 28; + + // The condition of the product. Strongly encouraged to use the standard + // values: "new", "refurbished", "used". + // + // A maximum of 1 value is allowed per + // [Product][google.cloud.retail.v2beta.Product]. Each value must be a UTF-8 + // encoded string with a length limit of 128 characters. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // Corresponding properties: Google Merchant Center property + // [condition](https://support.google.com/merchants/answer/6324469). + // Schema.org property + // [Offer.itemCondition](https://schema.org/itemCondition). + repeated string conditions = 29; + + // The promotions applied to the product. A maximum of 10 values are allowed + // per [Product][google.cloud.retail.v2beta.Product]. Only + // [Promotion.promotion_id][google.cloud.retail.v2beta.Promotion.promotion_id] + // will be used, other fields will be ignored if set. + repeated Promotion promotions = 34; + + // The timestamp when the product is published by the retailer for the first + // time, which indicates the freshness of the products. Note that this field + // is different from + // [available_time][google.cloud.retail.v2beta.Product.available_time], given + // it purely describes product freshness regardless of when it is available on + // search and recommendation. + google.protobuf.Timestamp publish_time = 33; + + // Indicates which fields in the + // [Product][google.cloud.retail.v2beta.Product]s are returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse]. + // + // Supported fields for all [type][google.cloud.retail.v2beta.Product.type]s: + // + // * [audience][google.cloud.retail.v2beta.Product.audience] + // * [availability][google.cloud.retail.v2beta.Product.availability] + // * [brands][google.cloud.retail.v2beta.Product.brands] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // * [conditions][google.cloud.retail.v2beta.Product.conditions] + // * [gtin][google.cloud.retail.v2beta.Product.gtin] + // * [materials][google.cloud.retail.v2beta.Product.materials] + // * [name][google.cloud.retail.v2beta.Product.name] + // * [patterns][google.cloud.retail.v2beta.Product.patterns] + // * [price_info][google.cloud.retail.v2beta.Product.price_info] + // * [rating][google.cloud.retail.v2beta.Product.rating] + // * [sizes][google.cloud.retail.v2beta.Product.sizes] + // * [title][google.cloud.retail.v2beta.Product.title] + // * [uri][google.cloud.retail.v2beta.Product.uri] + // + // Supported fields only for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION]: + // + // * [categories][google.cloud.retail.v2beta.Product.categories] + // * [description][google.cloud.retail.v2beta.Product.description] + // * [images][google.cloud.retail.v2beta.Product.images] + // + // Supported fields only for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]: + // + // * Only the first image in + // [images][google.cloud.retail.v2beta.Product.images] + // + // To mark [attributes][google.cloud.retail.v2beta.Product.attributes] as + // retrievable, include paths of the form "attributes.key" where "key" is the + // key of a custom attribute, as specified in + // [attributes][google.cloud.retail.v2beta.Product.attributes]. + // + // For [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], the + // following fields are always returned in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // + // For [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT], the + // following fields are always returned in by default: + // + // * [name][google.cloud.retail.v2beta.Product.name] + // * [color_info][google.cloud.retail.v2beta.Product.color_info] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] can increase + // response payload size and serving latency. + google.protobuf.FieldMask retrievable_fields = 30; + + // Output only. Product variants grouped together on primary product which + // share similar product attributes. It's automatically grouped by + // [primary_product_id][google.cloud.retail.v2beta.Product.primary_product_id] + // for all the product variants. Only populated for + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]s. + // + // Note: This field is OUTPUT_ONLY for + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct]. + // Do not set this field in API requests. + repeated Product variants = 31 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A list of local inventories specific to different places. + // + // This is only available for users who have Retail Search enabled, and it can + // be managed by + // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] + // and + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] + // APIs. + repeated LocalInventory local_inventories = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product_service.proto new file mode 100644 index 00000000000..0c09943324d --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/product_service.proto @@ -0,0 +1,924 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ProductServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting [Product][google.cloud.retail.v2beta.Product] +// information of the customer's website. +service ProductService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a [Product][google.cloud.retail.v2beta.Product]. + rpc CreateProduct(CreateProductRequest) returns (Product) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + body: "product" + }; + option (google.api.method_signature) = "parent,product,product_id"; + } + + // Gets a [Product][google.cloud.retail.v2beta.Product]. + rpc GetProduct(GetProductRequest) returns (Product) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a list of [Product][google.cloud.retail.v2beta.Product]s. + rpc ListProducts(ListProductsRequest) returns (ListProductsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a [Product][google.cloud.retail.v2beta.Product]. + rpc UpdateProduct(UpdateProductRequest) returns (Product) { + option (google.api.http) = { + patch: "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + body: "product" + }; + option (google.api.method_signature) = "product,update_mask"; + } + + // Deletes a [Product][google.cloud.retail.v2beta.Product]. + rpc DeleteProduct(DeleteProductRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. + // + // Request processing may be synchronous. + // Non-existing items are created. + // + // Note that it is possible for a subset of the + // [Product][google.cloud.retail.v2beta.Product]s to be successfully updated. + rpc ImportProducts(ImportProductsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportProductsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Updates inventory information for a + // [Product][google.cloud.retail.v2beta.Product] while respecting the last + // update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update is enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], + // the specified inventory field value(s) overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update times for the specified inventory fields are overwritten by the + // times of the + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // or + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // request. + // + // If no inventory fields are set in + // [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], + // then any pre-existing inventory information for this product is used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], + // then any existing inventory information is preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. + // + // The returned [Operation][google.longrunning.Operation]s is obsolete after + // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] + // API returns `NOT_FOUND` afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates are not marked as [done][google.longrunning.Operation.done] until + // they are obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc SetInventory(SetInventoryRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory" + body: "*" + }; + option (google.api.method_signature) = "inventory,set_mask"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.SetInventoryResponse" + metadata_type: "google.cloud.retail.v2beta.SetInventoryMetadata" + }; + } + + // Incrementally adds place IDs to + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the added place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc AddFulfillmentPlaces(AddFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" + }; + } + + // Incrementally removes place IDs from a + // [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // fulfillment information. If the request is valid, the update will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, the removed place IDs are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc RemoveFulfillmentPlaces(RemoveFulfillmentPlacesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" + }; + } + + // Updates local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places, while + // respecting the last update timestamps of each inventory field. + // + // This process is asynchronous and does not require the + // [Product][google.cloud.retail.v2beta.Product] to exist before updating + // inventory information. If the request is valid, the update will be enqueued + // and processed downstream. As a consequence, when a response is returned, + // updates are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc AddLocalInventories(AddLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.AddLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" + }; + } + + // Remove local inventory information for a + // [Product][google.cloud.retail.v2beta.Product] at a list of places at a + // removal timestamp. + // + // This process is asynchronous. If the request is valid, the removal will be + // enqueued and processed downstream. As a consequence, when a response is + // returned, removals are not immediately manifested in the + // [Product][google.cloud.retail.v2beta.Product] queried by + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc RemoveLocalInventories(RemoveLocalInventoriesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories" + body: "*" + }; + option (google.api.method_signature) = "product"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse" + metadata_type: "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" + }; + } +} + +// Request message for +// [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] +// method. +message CreateProductRequest { + // Required. The parent catalog resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Required. The [Product][google.cloud.retail.v2beta.Product] to create. + Product product = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the + // [Product][google.cloud.retail.v2beta.Product], which will become the final + // component of the [Product.name][google.cloud.retail.v2beta.Product.name]. + // + // If the caller does not have permission to create the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // This field must be unique among all + // [Product][google.cloud.retail.v2beta.Product]s with the same + // [parent][google.cloud.retail.v2beta.CreateProductRequest.parent]. + // Otherwise, an ALREADY_EXISTS error is returned. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string product_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for +// [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] +// method. +message GetProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the requested [Product][google.cloud.retail.v2beta.Product] does not + // exist, a NOT_FOUND error is returned. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] +// method. +message UpdateProductRequest { + // Required. The product to update/create. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // exist and + // [allow_missing][google.cloud.retail.v2beta.UpdateProductRequest.allow_missing] + // is not set, a NOT_FOUND error is returned. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. The immutable and + // output only fields are NOT supported. If not set, all supported fields (the + // fields that are neither immutable nor output only) are updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + // + // The attribute key can be updated by setting the mask path as + // "attributes.${key_name}". If a key name is present in the mask but not in + // the patching product from the request, this key will be deleted after the + // update. + google.protobuf.FieldMask update_mask = 2; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, a new [Product][google.cloud.retail.v2beta.Product] will be + // created. In this situation, `update_mask` is ignored. + bool allow_missing = 3; +} + +// Request message for +// [ProductService.DeleteProduct][google.cloud.retail.v2beta.ProductService.DeleteProduct] +// method. +message DeleteProductRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to delete the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to delete does not + // exist, a NOT_FOUND error is returned. + // + // The [Product][google.cloud.retail.v2beta.Product] to delete can neither be + // a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] member nor a + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] with more than one + // [variants][google.cloud.retail.v2beta.Product.Type.VARIANT]. Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // All inventory information for the named + // [Product][google.cloud.retail.v2beta.Product] will be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; +} + +// Request message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsRequest { + // Required. The parent branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. Use + // `default_branch` as the branch ID, to list products under the default + // branch. + // + // If the caller does not have permission to list + // [Product][google.cloud.retail.v2beta.Product]s under this branch, + // regardless of whether or not this branch exists, a PERMISSION_DENIED error + // is returned. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to 100. The maximum allowed value is 1000. Values + // above 1000 will be coerced to 1000. + // + // If this field is negative, an INVALID_ARGUMENT error is returned. + int32 page_size = 2; + + // A page token + // [ListProductsResponse.next_page_token][google.cloud.retail.v2beta.ListProductsResponse.next_page_token], + // received from a previous + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 3; + + // A filter to apply on the list results. Supported features: + // + // * List all the products under the parent branch if + // [filter][google.cloud.retail.v2beta.ListProductsRequest.filter] is unset. + // * List + // [Product.Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s sharing the same + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product]. For example: + // `primary_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s bundled in a + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product]. + // For example: + // `collection_product_id = "some_product_id"` + // * List [Product][google.cloud.retail.v2beta.Product]s with a partibular + // type. For example: + // `type = "PRIMARY"` + // `type = "VARIANT"` + // `type = "COLLECTION"` + // + // If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + // + // If the specified + // [Product.Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] + // [Product][google.cloud.retail.v2beta.Product] or + // [Product.Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION] + // [Product][google.cloud.retail.v2beta.Product] does not exist, a NOT_FOUND + // error is returned. + string filter = 4; + + // The fields of [Product][google.cloud.retail.v2beta.Product] to return in + // the responses. If not set or empty, the following fields are returned: + // + // * [Product.name][google.cloud.retail.v2beta.Product.name] + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // * [Product.title][google.cloud.retail.v2beta.Product.title] + // * [Product.uri][google.cloud.retail.v2beta.Product.uri] + // * [Product.images][google.cloud.retail.v2beta.Product.images] + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.brands][google.cloud.retail.v2beta.Product.brands] + // + // If "*" is provided, all fields are returned. + // [Product.name][google.cloud.retail.v2beta.Product.name] is always returned + // no matter what mask is set. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned. + google.protobuf.FieldMask read_mask = 5; +} + +// Response message for +// [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] +// method. +message ListProductsResponse { + // The [Product][google.cloud.retail.v2beta.Product]s. + repeated Product products = 1; + + // A token that can be sent as + // [ListProductsRequest.page_token][google.cloud.retail.v2beta.ListProductsRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 2; +} + +// Request message for +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] +// method. +message SetInventoryRequest { + // Required. The inventory information to update. The allowable fields to + // update are: + // + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // The updated inventory fields must be specified in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask]. + // + // If + // [SetInventoryRequest.inventory.name][google.cloud.retail.v2beta.Product.name] + // is empty or invalid, an INVALID_ARGUMENT error is returned. + // + // If the caller does not have permission to update the + // [Product][google.cloud.retail.v2beta.Product] named in + // [Product.name][google.cloud.retail.v2beta.Product.name], regardless of + // whether or not it exists, a PERMISSION_DENIED error is returned. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update does not + // have existing inventory information, the provided inventory information + // will be inserted. + // + // If the [Product][google.cloud.retail.v2beta.Product] to update has existing + // inventory information, the provided inventory information will be merged + // while respecting the last update time for each inventory field, using the + // provided or default value for + // [SetInventoryRequest.set_time][google.cloud.retail.v2beta.SetInventoryRequest.set_time]. + // + // The caller can replace place IDs for a subset of fulfillment types in the + // following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types and corresponding place IDs + // to update in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // + // The caller can clear all place IDs from a subset of fulfillment types in + // the following ways: + // + // * Adds "fulfillment_info" in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask] + // * Specifies only the desired fulfillment types to clear in + // [SetInventoryRequest.inventory.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // + // The last update time is recorded for the following inventory fields: + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // * [Product.availability][google.cloud.retail.v2beta.Product.availability] + // * [Product.available_quantity][google.cloud.retail.v2beta.Product.available_quantity] + // * [Product.fulfillment_info][google.cloud.retail.v2beta.Product.fulfillment_info] + // + // If a full overwrite of inventory information while ignoring timestamps is + // needed, + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // should be invoked instead. + Product inventory = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided + // [Product][google.cloud.retail.v2beta.Product] to update. + // + // At least one field must be provided. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask set_mask = 2; + + // The time when the request is issued, used to prevent + // out-of-order updates on inventory fields with the last update time + // recorded. If not provided, the internal system time will be used. + google.protobuf.Timestamp set_time = 3; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] with + // name [Product.name][google.cloud.retail.v2beta.Product.name] is not found, + // the inventory update will still be processed and retained for at most 1 day + // until the [Product][google.cloud.retail.v2beta.Product] is created. If set + // to false, a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 4; +} + +// Metadata related to the progress of the SetInventory operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type], such + // as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery" to be added for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type]. + // Duplicate IDs will be automatically ignored. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + // + // If the total number of place IDs exceeds 2000 for this + // [type][google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type] after + // adding, then the update will be rejected. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the AddFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesMetadata {} + +// Response of the AddFulfillmentPlacesRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of inventory information at difference places. Each place + // is identified by its place ID. At most 3000 inventories are allowed per + // request. + repeated LocalInventory local_inventories = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which inventory fields in the provided list of + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory] to update. The + // field is updated to the provided value. + // + // If a field is set while the place does not have a previous local inventory, + // the local inventory at that store is created. + // + // If a field is set while the value of that field is not provided, the + // original field value, if it exists, is deleted. + // + // If the mask is not set or set with empty paths, all inventory fields will + // be updated. + // + // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + // is returned and the entire update will be ignored. + google.protobuf.FieldMask add_mask = 4; + + // The time when the inventory updates are issued. Used to prevent + // out-of-order updates on local inventory fields. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp add_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory will still be processed and retained for at + // most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 6; +} + +// Metadata related to the progress of the AddLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. A list of place IDs to have their inventory deleted. + // At most 3000 place IDs are allowed per request. + repeated string place_ids = 2 [(google.api.field_behavior) = REQUIRED]; + + // The time when the inventory deletions are issued. Used to prevent + // out-of-order updates and deletions on local inventory fields. If not + // provided, the internal system time will be used. + google.protobuf.Timestamp remove_time = 5; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the local inventory removal request will still be processed and + // retained for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 3; +} + +// Metadata related to the progress of the RemoveLocalInventories operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesRequest { + // Required. Full resource name of + // [Product][google.cloud.retail.v2beta.Product], such as + // `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + // + // If the caller does not have permission to access the + // [Product][google.cloud.retail.v2beta.Product], regardless of whether or not + // it exists, a PERMISSION_DENIED error is returned. + string product = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Product" } + ]; + + // Required. The fulfillment type, including commonly used types (such as + // pickup in store and same day delivery), and custom types. + // + // Supported values: + // + // * "pickup-in-store" + // * "ship-to-store" + // * "same-day-delivery" + // * "next-day-delivery" + // * "custom-type-1" + // * "custom-type-2" + // * "custom-type-3" + // * "custom-type-4" + // * "custom-type-5" + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + // + // This field directly corresponds to + // [Product.fulfillment_info.type][google.cloud.retail.v2beta.FulfillmentInfo.type]. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The IDs for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type], + // such as the store IDs for "pickup-in-store" or the region IDs for + // "same-day-delivery", to be removed for this + // [type][google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type]. + // + // At least 1 value is required, and a maximum of 2000 values are allowed. + // Each value must be a string with a length limit of 10 characters, matching + // the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + // INVALID_ARGUMENT error is returned. + repeated string place_ids = 3 [(google.api.field_behavior) = REQUIRED]; + + // The time when the fulfillment updates are issued, used to prevent + // out-of-order updates on fulfillment information. If not provided, the + // internal system time will be used. + google.protobuf.Timestamp remove_time = 4; + + // If set to true, and the [Product][google.cloud.retail.v2beta.Product] is + // not found, the fulfillment information will still be processed and retained + // for at most 1 day and processed once the + // [Product][google.cloud.retail.v2beta.Product] is created. If set to false, + // a NOT_FOUND error is returned if the + // [Product][google.cloud.retail.v2beta.Product] is not found. + bool allow_missing = 5; +} + +// Metadata related to the progress of the RemoveFulfillmentPlaces operation. +// Currently empty because there is no meaningful metadata populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/promotion.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/promotion.proto new file mode 100644 index 00000000000..5346f14d363 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/promotion.proto @@ -0,0 +1,40 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PromotionProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Promotion information. +message Promotion { + // ID of the promotion. For example, "free gift". + // + // The value must be a UTF-8 encoded string with a length limit of 128 + // characters, and match the pattern: `[a-zA-Z][a-zA-Z0-9_]*`. For example, + // id0LikeThis or ID_1_LIKE_THIS. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Google Merchant Center property + // [promotion](https://support.google.com/merchants/answer/7050148). + string promotion_id = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/purge_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/purge_config.proto new file mode 100644 index 00000000000..25502cd7d16 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/purge_config.proto @@ -0,0 +1,83 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "PurgeConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Metadata related to the progress of the Purge operation. +// This will be returned by the google.longrunning.Operation.metadata field. +message PurgeMetadata {} + +// Request message for PurgeUserEvents method. +message PurgeUserEventsRequest { + // Required. The resource name of the catalog under which the events are + // created. The format is + // `projects/${projectId}/locations/global/catalogs/${catalogId}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The filter string to specify the events to be deleted with a + // length limit of 5,000 characters. Empty string filter is not allowed. The + // eligible fields for filtering are: + // + // * `eventType`: Double quoted + // [UserEvent.event_type][google.cloud.retail.v2beta.UserEvent.event_type] + // string. + // * `eventTime`: in ISO 8601 "zulu" format. + // * `visitorId`: Double quoted string. Specifying this will delete all + // events associated with a visitor. + // * `userId`: Double quoted string. Specifying this will delete all events + // associated with a user. + // + // Examples: + // + // * Deleting all events in a time range: + // `eventTime > "2012-04-23T18:25:43.511Z" + // eventTime < "2012-04-23T18:30:43.511Z"` + // * Deleting specific eventType in time range: + // `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + // * Deleting all events for a specific visitor: + // `visitorId = "visitor1024"` + // + // The filtering fields are assumed to have an implicit AND. + string filter = 2 [(google.api.field_behavior) = REQUIRED]; + + // Actually perform the purge. + // If `force` is set to false, the method will return the expected purge count + // without deleting any user events. + bool force = 3; +} + +// Response of the PurgeUserEventsRequest. If the long running operation is +// successfully done, then this message is returned by the +// google.longrunning.Operations.response field. +message PurgeUserEventsResponse { + // The total count of events purged as a result of the operation. + int64 purged_events_count = 1; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/search_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/search_service.proto new file mode 100644 index 00000000000..5a1004410e6 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/search_service.proto @@ -0,0 +1,929 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "SearchServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// Enable Retail Search on Cloud Console before using this feature. +service SearchService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Performs a search. + // + // This feature is only available for users who have Retail Search enabled. + // Enable Retail Search on Cloud Console before using this feature. + rpc Search(SearchRequest) returns (SearchResponse) { + option (google.api.http) = { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search" + body: "*" + additional_bindings { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search" + body: "*" + } + }; + } +} + +// Request message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchRequest { + // A facet specification to perform faceted search. + message FacetSpec { + // Specifies how a facet is computed. + message FacetKey { + // Required. Supported textual and numerical facet keys in + // [Product][google.cloud.retail.v2beta.Product] object, over which the + // facet values are computed. Facet key is case-sensitive. + // + // Allowed facet keys when + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is not specified: + // + // * textual_field = + // * "brands" + // * "categories" + // * "genders" + // * "ageGroups" + // * "availability" + // * "colorFamilies" + // * "colors" + // * "sizes" + // * "materials" + // * "patterns" + // * "conditions" + // * "attributes.key" + // * "pickupInStore" + // * "shipToStore" + // * "sameDayDelivery" + // * "nextDayDelivery" + // * "customFulfillment1" + // * "customFulfillment2" + // * "customFulfillment3" + // * "customFulfillment4" + // * "customFulfillment5" + // * "inventory(place_id,attributes.key)" + // + // * numerical_field = + // * "price" + // * "discount" + // * "rating" + // * "ratingCount" + // * "attributes.key" + // * "inventory(place_id,price)" + // * "inventory(place_id,original_price)" + // * "inventory(place_id,attributes.key)" + string key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Set only if values should be bucketized into intervals. Must be set + // for facets with numerical values. Must not be set for facet with text + // values. Maximum number of intervals is 30. + repeated Interval intervals = 2; + + // Only get facet for the given restricted values. For example, when using + // "pickupInStore" as key and set restricted values to + // ["store123", "store456"], only facets for "store123" and "store456" are + // returned. Only supported on predefined textual fields, custom textual + // attributes and fulfillments. Maximum is 20. + // + // Must be set for the fulfillment facet keys: + // + // * pickupInStore + // + // * shipToStore + // + // * sameDayDelivery + // + // * nextDayDelivery + // + // * customFulfillment1 + // + // * customFulfillment2 + // + // * customFulfillment3 + // + // * customFulfillment4 + // + // * customFulfillment5 + repeated string restricted_values = 3; + + // Only get facet values that start with the given string prefix. For + // example, suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "prefixes" to "Women", the + // "categories" facet will give only "Women > Shoe" and "Women > Dress". + // Only supported on textual fields. Maximum is 10. + repeated string prefixes = 8; + + // Only get facet values that contains the given strings. For example, + // suppose "categories" has three values "Women > Shoe", + // "Women > Dress" and "Men > Shoe". If set "contains" to "Shoe", the + // "categories" facet will give only "Women > Shoe" and "Men > Shoe". + // Only supported on textual fields. Maximum is 10. + repeated string contains = 9; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2beta.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] + // descending. + // Only applies to textual facets. + // + // If not set, textual values are sorted in [natural + // order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical + // intervals are sorted in the order given by + // [FacetSpec.FacetKey.intervals][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals]; + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // are sorted in the order given by + // [FacetSpec.FacetKey.restricted_values][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restricted_values]. + string order_by = 4; + + // The query that is used to compute facet for the given facet key. + // When provided, it will override the default behavior of facet + // computation. The query syntax is the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. Notice that there is no limitation + // on + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // when query is specified. + // + // In the response, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match the query. + // + // For example, you can set a customized facet for "shipToStore", + // where + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is "customizedShipToStore", and + // [FacetKey.query][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.query] + // is "availability: ANY(\"IN_STOCK\") AND shipToStore: ANY(\"123\")". + // Then the facet will count the products that are both in stock and ship + // to store "123". + string query = 5; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // Required. The facet key specification. + FacetKey facet_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Maximum of facet values that should be returned for this facet. If + // unspecified, defaults to 20. The maximum allowed value is 300. Values + // above 300 will be coerced to 300. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 limit = 2; + + // List of keys to exclude when faceting. + // + // + // By default, + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // is not excluded from the filter unless it is listed in this field. + // + // Listing a facet key in this field allows its values to appear as facet + // results, even when they are filtered out of search results. Using this + // field does not affect what search results are returned. + // + // For example, suppose there are 100 products with the color facet "Red" + // and 200 products with the color facet "Blue". A query containing the + // filter "colorFamilies:ANY("Red")" and having "colorFamilies" as + // [FacetKey.key][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.key] + // would by default return only "Red" products in the search results, and + // also return "Red" with count 100 as the only color facet. Although there + // are also blue products available, "Blue" would not be shown as an + // available facet value. + // + // If "colorFamilies" is listed in "excludedFilterKeys", then the query + // returns the facet values "Red" with count 100 and "Blue" with count + // 200, because the "colorFamilies" key is now excluded from the filter. + // Because this field doesn't affect search results, the search results + // are still correctly filtered to return only "Red" products. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated string excluded_filter_keys = 3; + + // Enables dynamic position for this facet. If set to true, the position of + // this facet among all facets in the response is determined by Google + // Retail Search. It will be ordered together with dynamic facets if dynamic + // facets is enabled. If set to false, the position of this facet in the + // response will be the same as in the request, and it will be ranked before + // the facets with dynamic position enable and all dynamic facets. + // + // For example, you may always want to have rating facet returned in + // the response, but it's not necessarily to always display the rating facet + // at the top. In that case, you can set enable_dynamic_position to true so + // that the position of rating facet in response will be determined by + // Google Retail Search. + // + // Another example, assuming you have the following facets in the request: + // + // * "rating", enable_dynamic_position = true + // + // * "price", enable_dynamic_position = false + // + // * "brands", enable_dynamic_position = false + // + // And also you have a dynamic facets enable, which will generate a facet + // 'gender'. Then the final order of the facets in the response can be + // ("price", "brands", "rating", "gender") or ("price", "brands", "gender", + // "rating") depends on how Google Retail Search orders "gender" and + // "rating" facets. However, notice that "price" and "brands" will always be + // ranked at 1st and 2nd position since their enable_dynamic_position are + // false. + bool enable_dynamic_position = 4; + } + + // The specifications of dynamically generated facets. + message DynamicFacetSpec { + // Enum to control DynamicFacet mode + enum Mode { + // Default value. + MODE_UNSPECIFIED = 0; + + // Disable Dynamic Facet. + DISABLED = 1; + + // Automatic mode built by Google Retail Search. + ENABLED = 2; + } + + // Mode of the DynamicFacet feature. + // Defaults to + // [Mode.DISABLED][google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode.DISABLED] + // if it's unset. + Mode mode = 1; + } + + // Boost specification to boost certain items. + message BoostSpec { + // Boost applies to products which match a condition. + message ConditionBoostSpec { + // An expression which specifies a boost condition. The syntax and + // supported fields are the same as a filter expression. See + // [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for detail syntax and limitations. + // + // Examples: + // + // * To boost products with product ID "product_1" or "product_2", and + // color + // "Red" or "Blue": + // * (id: ANY("product_1", "product_2")) AND (colorFamilies: + // ANY("Red","Blue")) + string condition = 1; + + // Strength of the condition boost, which should be in [-1, 1]. Negative + // boost means demotion. Default is 0.0. + // + // Setting to 1.0 gives the item a big promotion. However, it does not + // necessarily mean that the boosted item will be the top result at all + // times, nor that other items will be excluded. Results could still be + // shown even when none of them matches the condition. And results that + // are significantly more relevant to the search query can still trump + // your heavily favored but irrelevant items. + // + // Setting to -1.0 gives the item a big demotion. However, results that + // are deeply relevant might still be shown. The item will have an + // upstream battle to get a fairly high ranking, but it is not blocked out + // completely. + // + // Setting to 0.0 means no boost applied. The boosting condition is + // ignored. + float boost = 2; + } + + // Condition boost specifications. If a product matches multiple conditions + // in the specifictions, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 20. + repeated ConditionBoostSpec condition_boost_specs = 1; + + // Whether to skip boostspec validation. If this field is set to true, + // invalid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will be ignored and valid + // [BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // will still be applied. + optional bool skip_boost_spec_validation = 2; + } + + // Specification to determine under which conditions query expansion should + // occur. + message QueryExpansionSpec { + // Enum describing under which condition query expansion should occur. + enum Condition { + // Unspecified query expansion condition. In this case, server behavior + // defaults to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + CONDITION_UNSPECIFIED = 0; + + // Disabled query expansion. Only the exact search query is used, even if + // [SearchResponse.total_size][google.cloud.retail.v2beta.SearchResponse.total_size] + // is zero. + DISABLED = 1; + + // Automatic query expansion built by Google Retail Search. + AUTO = 3; + } + + // The condition under which query expansion should occur. Default to + // [Condition.DISABLED][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition.DISABLED]. + Condition condition = 1; + + // Whether to pin unexpanded results. If this field is set to true, + // unexpanded products are always at the top of the search results, followed + // by the expanded results. + bool pin_unexpanded_results = 2; + } + + // The specification for personalization. + message PersonalizationSpec { + // The personalization mode of each search request. + enum Mode { + // Default value. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization based on quality of user + // event data. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The specification for query spell correction. + message SpellCorrectionSpec { + // Enum describing under which mode spell correction should occur. + enum Mode { + // Unspecified spell correction mode. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Google Retail Search will try to find a spell suggestion if there + // is any and put in the + // [SearchResponse.corrected_query][google.cloud.retail.v2beta.SearchResponse.corrected_query]. + // The spell suggestion will not be used as the search query. + SUGGESTION_ONLY = 1; + + // Automatic spell correction built by Google Retail Search. Search will + // be based on the corrected query if found. + AUTO = 2; + } + + // The mode under which spell correction should take effect to + // replace the original search query. Default to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode.AUTO]. + Mode mode = 1; + } + + // The search mode of each search request. + enum SearchMode { + // Default value. In this case both product search and faceted search will + // be performed. Both + // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // and + // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] + // will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only + // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // will be returned. + // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] + // will not be returned, even if + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // or + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // is set. + PRODUCT_SEARCH_ONLY = 1; + + // Only faceted search will be performed. The product search will be + // disabled. + // + // When in this mode, one or both of + // [SearchRequest.facet_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // and + // [SearchRequest.dynamic_facet_spec][google.cloud.retail.v2beta.SearchRequest.dynamic_facet_spec] + // should be set. Otherwise, an INVALID_ARGUMENT error is returned. Only + // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] + // will be returned. + // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving configuration name and the set + // of models that will be used to make the search. + string placement = 1 [(google.api.field_behavior) = REQUIRED]; + + // The branch resource name, such as + // `projects/*/locations/global/catalogs/default_catalog/branches/0`. + // + // Use "default_branch" as the branch ID or leave this field empty, to search + // products under the default branch. + string branch = 2 [ + (google.api.resource_reference) = { type: "retail.googleapis.com/Branch" } + ]; + + // Raw search query. + // + // If this field is empty, the request is considered a category browsing + // request and returned results are based on + // [filter][google.cloud.retail.v2beta.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2beta.SearchRequest.page_categories]. + string query = 3; + + // Required. A unique identifier for tracking visitors. For example, this + // could be implemented with an HTTP cookie, which should be able to uniquely + // identify a visitor on a single device. This unique identifier should not + // change if the visitor logs in or out of the website. + // + // This should be the same identifier as + // [UserEvent.visitor_id][google.cloud.retail.v2beta.UserEvent.visitor_id]. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string visitor_id = 4 [(google.api.field_behavior) = REQUIRED]; + + // User information. + UserInfo user_info = 5; + + // Maximum number of [Product][google.cloud.retail.v2beta.Product]s to return. + // If unspecified, defaults to a reasonable value. The maximum allowed value + // is 120. Values above 120 will be coerced to 120. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 page_size = 7; + + // A page token + // [SearchResponse.next_page_token][google.cloud.retail.v2beta.SearchResponse.next_page_token], + // received from a previous + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // call. Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] + // must match the call that provided the page token. Otherwise, an + // INVALID_ARGUMENT error is returned. + string page_token = 8; + + // A 0-indexed integer that specifies the current offset (that is, starting + // result location, amongst the [Product][google.cloud.retail.v2beta.Product]s + // deemed by the API as relevant) in search results. This field is only + // considered if + // [page_token][google.cloud.retail.v2beta.SearchRequest.page_token] is unset. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + int32 offset = 9; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. Filter + // expression is case-sensitive. See more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string filter = 10; + + // The default filter that is applied when a user performs a search without + // checking any filters on the search page. + // + // The filter applied to every search request when quality improvement such as + // query expansion is needed. For example, if a query does not have enough + // results, an expanded query with + // [SearchRequest.canonical_filter][google.cloud.retail.v2beta.SearchRequest.canonical_filter] + // will be returned as a supplement of the original query. This field is + // strongly recommended to achieve high search quality. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for more details about filter syntax. + string canonical_filter = 28; + + // The order in which products are returned. Products can be ordered by + // a field in an [Product][google.cloud.retail.v2beta.Product] object. Leave + // it unset if ordered by relevance. OrderBy expression is case-sensitive. See + // more details at this [user + // guide](https://cloud.google.com/retail/docs/filter-and-order#order). + // + // If this field is unrecognizable, an INVALID_ARGUMENT is returned. + string order_by = 11; + + // Facet specifications for faceted search. If empty, no facets are returned. + // + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + repeated FacetSpec facet_specs = 12; + + // Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + // to enable dynamic facets. Do not set this field. + // + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + DynamicFacetSpec dynamic_facet_spec = 21 [deprecated = true]; + + // Boost specification to boost certain products. See more details at this + // [user guide](https://cloud.google.com/retail/docs/boosting). + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + BoostSpec boost_spec = 13; + + // The query expansion specification that specifies the conditions under which + // query expansion will occur. See more details at this [user + // guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + QueryExpansionSpec query_expansion_spec = 14; + + // The keys to fetch and rollup the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s attributes, + // [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo] or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s attributes. + // The attributes from all the matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s or + // [LocalInventory][google.cloud.retail.v2beta.LocalInventory]s are merged and + // de-duplicated. Notice that rollup attributes will lead to extra query + // latency. Maximum number of keys is 30. + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], a + // fulfillment type and a fulfillment ID must be provided in the format of + // "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + // "pickupInStore" is fulfillment type and "store123" is the store ID. + // + // Supported keys are: + // + // * colorFamilies + // * price + // * originalPrice + // * discount + // * variantId + // * inventory(place_id,price) + // * inventory(place_id,original_price) + // * inventory(place_id,attributes.key), where key is any key in the + // [Product.local_inventories.attributes][google.cloud.retail.v2beta.LocalInventory.attributes] + // map. + // * attributes.key, where key is any key in the + // [Product.attributes][google.cloud.retail.v2beta.Product.attributes] map. + // * pickupInStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "pickup-in-store". + // * shipToStore.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "ship-to-store". + // * sameDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "same-day-delivery". + // * nextDayDelivery.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "next-day-delivery". + // * customFulfillment1.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-1". + // * customFulfillment2.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-2". + // * customFulfillment3.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-3". + // * customFulfillment4.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-4". + // * customFulfillment5.id, where id is any + // [FulfillmentInfo.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids] + // for [FulfillmentInfo.type][google.cloud.retail.v2beta.FulfillmentInfo.type] + // "custom-type-5". + // + // If this field is set to an invalid value other than these, an + // INVALID_ARGUMENT error is returned. + repeated string variant_rollup_keys = 17; + + // The categories associated with a category page. Required for category + // navigation queries to achieve good search quality. The format should be + // the same as + // [UserEvent.page_categories][google.cloud.retail.v2beta.UserEvent.page_categories]; + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + repeated string page_categories = 23; + + // The search mode of the search request. If not specified, a single search + // request triggers both product search and faceted search. + SearchMode search_mode = 31; + + // The specification for personalization. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. + PersonalizationSpec personalization_spec = 32; + + // The labels applied to a resource must meet the following requirements: + // + // * Each resource can have multiple labels, up to a maximum of 64. + // * Each label must be a key-value pair. + // * Keys have a minimum length of 1 character and a maximum length of 63 + // characters and cannot be empty. Values can be empty and have a maximum + // length of 63 characters. + // * Keys and values can contain only lowercase letters, numeric characters, + // underscores, and dashes. All characters must use UTF-8 encoding, and + // international characters are allowed. + // * The key portion of a label must be unique. However, you can use the same + // key with multiple resources. + // * Keys must start with a lowercase letter or international character. + // + // See [Google Cloud + // Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + // for more details. + map labels = 34; + + // The spell correction specification that specifies the mode under + // which spell correction will take effect. + optional SpellCorrectionSpec spell_correction_spec = 35; +} + +// Response message for +// [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search] +// method. +message SearchResponse { + // Represents the search results. + message SearchResult { + // [Product.id][google.cloud.retail.v2beta.Product.id] of the searched + // [Product][google.cloud.retail.v2beta.Product]. + string id = 1; + + // The product data snippet in the search response. Only + // [Product.name][google.cloud.retail.v2beta.Product.name] is guaranteed to + // be populated. + // + // [Product.variants][google.cloud.retail.v2beta.Product.variants] contains + // the product variants that match the search query. If there are multiple + // product variants matching the query, top 5 most relevant product variants + // are returned and ordered by relevancy. + // + // If relevancy can be deternmined, use + // [matching_variant_fields][google.cloud.retail.v2beta.SearchResponse.SearchResult.matching_variant_fields] + // to look up matched product variants fields. If relevancy cannot be + // determined, e.g. when searching "shoe" all products in a shoe product can + // be a match, 5 product variants are returned but order is meaningless. + Product product = 2; + + // The count of matched + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product]s. + int32 matching_variant_count = 3; + + // If a [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] matches the search query, + // this map indicates which [Product][google.cloud.retail.v2beta.Product] + // fields are matched. The key is the + // [Product.name][google.cloud.retail.v2beta.Product.name], the value is a + // field mask of the matched [Product][google.cloud.retail.v2beta.Product] + // fields. If matched attributes cannot be determined, this map will be + // empty. + // + // For example, a key "sku1" with field mask + // "products.color_info" indicates there is a match between + // "sku1" [ColorInfo][google.cloud.retail.v2beta.ColorInfo] and the query. + map matching_variant_fields = 4; + + // The rollup matching + // [variant][google.cloud.retail.v2beta.Product.Type.VARIANT] + // [Product][google.cloud.retail.v2beta.Product] attributes. The key is one + // of the + // [SearchRequest.variant_rollup_keys][google.cloud.retail.v2beta.SearchRequest.variant_rollup_keys]. + // The values are the merged and de-duplicated + // [Product][google.cloud.retail.v2beta.Product] attributes. Notice that the + // rollup values are respect filter. For example, when filtering by + // "colorFamilies:ANY(\"red\")" and rollup "colorFamilies", only "red" is + // returned. + // + // For textual and numerical attributes, the rollup values is a list of + // string or double values with type + // [google.protobuf.ListValue][google.protobuf.ListValue]. For example, if + // there are two variants with colors "red" and "blue", the rollup values + // are + // + // { key: "colorFamilies" + // value { + // list_value { + // values { string_value: "red" } + // values { string_value: "blue" } + // } + // } + // } + // + // For [FulfillmentInfo][google.cloud.retail.v2beta.FulfillmentInfo], the + // rollup values is a double value with type + // [google.protobuf.Value][google.protobuf.Value]. For example, + // `{key: "pickupInStore.store1" value { number_value: 10 }}` means a there + // are 10 variants in this product are available in the store "store1". + map variant_rollup_values = 5; + + // Specifies previous events related to this product for this user based on + // [UserEvent][google.cloud.retail.v2beta.UserEvent] with same + // [SearchRequest.visitor_id][google.cloud.retail.v2beta.SearchRequest.visitor_id] + // or [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id]. + // + // This is set only when + // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.mode] + // is + // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + // + // Possible values: + // + // * `purchased`: Indicates that this product has been purchased before. + repeated string personal_labels = 7; + } + + // A facet result. + message Facet { + // A facet value which contains value names and their count. + message FacetValue { + // A facet value which contains values. + oneof facet_value { + // Text value of a facet, such as "Black" for facet "colorFamilies". + string value = 1; + + // Interval value for a facet, such as [10, 20) for facet "price". + Interval interval = 2; + } + + // Number of items that have this facet value. + int64 count = 3; + + // The minimum value in the + // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // The key for this facet. E.g., "colorFamilies" or "price" or + // "attributes.attr1". + string key = 1; + + // The facet values for this field. + repeated FacetValue values = 2; + + // Whether the facet is dynamically generated. + bool dynamic_facet = 3; + } + + // Information describing query expansion including whether expansion has + // occurred. + message QueryExpansionInfo { + // Bool describing whether query expansion has occurred. + bool expanded_query = 1; + + // Number of pinned results. This field will only be set when expansion + // happens and + // [SearchRequest.QueryExpansionSpec.pin_unexpanded_results][google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.pin_unexpanded_results] + // is set to true. + int64 pinned_result_count = 2; + } + + // A list of matched items. The order represents the ranking. + repeated SearchResult results = 1; + + // Results of facets requested by user. + repeated Facet facets = 2; + + // The estimated total count of matched items irrespective of pagination. The + // count of [results][google.cloud.retail.v2beta.SearchResponse.results] + // returned by pagination may be less than the + // [total_size][google.cloud.retail.v2beta.SearchResponse.total_size] that + // matches. + int32 total_size = 3; + + // Contains the spell corrected query, if found. If the spell correction type + // is AUTOMATIC, then the search results are based on corrected_query. + // Otherwise the original query is used for search. + string corrected_query = 4; + + // A unique search token. This should be included in the + // [UserEvent][google.cloud.retail.v2beta.UserEvent] logs resulting from this + // search, which enables accurate attribution of search model performance. + string attribution_token = 5; + + // A token that can be sent as + // [SearchRequest.page_token][google.cloud.retail.v2beta.SearchRequest.page_token] + // to retrieve the next page. If this field is omitted, there are no + // subsequent pages. + string next_page_token = 6; + + // Query expansion information for the returned results. + QueryExpansionInfo query_expansion_info = 7; + + // The URI of a customer-defined redirect page. If redirect action is + // triggered, no search is performed, and only + // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // are set in the response. + string redirect_uri = 10; + + // The fully qualified resource name of applied + // [controls](https://cloud.google.com/retail/docs/serving-control-rules). + repeated string applied_controls = 12; + + // The invalid + // [SearchRequest.BoostSpec.condition_boost_specs][google.cloud.retail.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config.proto new file mode 100644 index 00000000000..35d1cf85353 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config.proto @@ -0,0 +1,280 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Configures metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // What type of diversity - data or rule based. + // If none is specified, default to rule based. + enum DiversityType { + // Default value. + DIVERSITY_TYPE_UNSPECIFIED = 0; + + // Rule based diversity. + RULE_BASED_DIVERSITY = 2; + + // Data driven diversity. + DATA_DRIVEN_DIVERSITY = 3; + } + + // Immutable. Fully qualified name + // `projects/*/locations/global/catalogs/*/servingConfig/*` + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. The human readable serving config display name. Used in Retail + // UI. + // + // This field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // The id of the model in the same + // [Catalog][google.cloud.retail.v2beta.Catalog] to use at serving time. + // Currently only RecommendationModels are supported: + // https://cloud.google.com/retail/recommendations-ai/docs/create-models + // Can be changed but only to a compatible model (e.g. + // others-you-may-like CTR to others-you-may-like CVR). + // + // Required when + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string model_id = 3; + + // How much price ranking we want in serving results. + // Price reranking causes product items with a similar + // recommendation probability to be ordered by price, with the + // highest-priced items first. This setting could result in a decrease in + // click-through and conversion rates. + // Allowed values are: + // + // * `no-price-reranking` + // * `low-price-raranking` + // * `medium-price-reranking` + // * `high-price-reranking` + // + // If not specified, we choose default based on model type. Default value: + // `no-price-reranking`. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string price_reranking_level = 4; + + // Facet specifications for faceted search. If empty, no facets are returned. + // The ids refer to the ids of [Control][google.cloud.retail.v2beta.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2beta.Catalog] as the + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]. + // A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + // is returned. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string facet_control_ids = 5; + + // The specification for dynamically generated facets. Notice that only + // textual facets can be dynamically generated. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + SearchRequest.DynamicFacetSpec dynamic_facet_spec = 6; + + // Condition boost specifications. If a product matches multiple conditions + // in the specifications, boost scores from these specifications are all + // applied and combined in a non-linear way. Maximum number of + // specifications is 100. + // + // Notice that if both + // [ServingConfig.boost_control_ids][google.cloud.retail.v2beta.ServingConfig.boost_control_ids] + // and + // [SearchRequest.boost_spec][google.cloud.retail.v2beta.SearchRequest.boost_spec] + // are set, the boost conditions from both places are evaluated. If a search + // request matches multiple boost conditions, the final boost score is equal + // to the sum of the boost scores from all matched boost conditions. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string boost_control_ids = 7; + + // Condition filter specifications. If a product matches multiple conditions + // in the specifications, filters from these specifications are all + // applied and combined via the AND operator. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string filter_control_ids = 9; + + // Condition redirect specifications. Only the first triggered redirect action + // is applied, even if multiple apply. Maximum number of specifications is + // 1000. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string redirect_control_ids = 10; + + // Condition synonyms specifications. If multiple syonyms conditions match, + // all matching synonyms control in the list will execute. Order of controls + // in the list will not matter. Maximum number of specifications is + // 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string twoway_synonyms_control_ids = 18; + + // Condition oneway synonyms specifications. If multiple oneway synonyms + // conditions match, all matching oneway synonyms controls in the list will + // execute. Order of controls in the list will not matter. Maximum number of + // specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string oneway_synonyms_control_ids = 12; + + // Condition do not associate specifications. If multiple do not associate + // conditions match, all matching do not associate controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string do_not_associate_control_ids = 13; + + // Condition replacement specifications. + // - Applied according to the order in the list. + // - A previously replaced term can not be re-replaced. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string replacement_control_ids = 14; + + // Condition ignore specifications. If multiple ignore + // conditions match, all matching ignore controls in the list will + // execute. + // - Order does not matter. + // - Maximum number of specifications is 100. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated string ignore_control_ids = 15; + + // How much diversity to use in recommendation model results e.g. + // `medium-diversity` or `high-diversity`. Currently supported values: + // + // * `no-diversity` + // * `low-diversity` + // * `medium-diversity` + // * `high-diversity` + // * `auto-diversity` + // + // If not specified, we choose default based on recommendation model + // type. Default value: `no-diversity`. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // What kind of diversity to use - data driven or rule based. + DiversityType diversity_type = 20; + + // Whether to add additional category filters on the `similar-items` model. + // If not specified, we enable it by default. + // Allowed values are: + // + // * `no-category-match`: No additional filtering of original results from + // the model and the customer's filters. + // * `relaxed-category-match`: Only keep results with categories that match + // at least one item categories in the PredictRequests's context item. + // * If customer also sends filters in the PredictRequest, then the results + // will satisfy both conditions (user given and category match). + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // The specification for personalization spec. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2beta.ServingConfig.solution_types] + // is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. + SearchRequest.PersonalizationSpec personalization_spec = 21; + + // Required. Immutable. Specifies the solution types that a serving config can + // be associated with. Currently we support setting only one type of solution. + repeated SolutionType solution_types = 19 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config_service.proto new file mode 100644 index 00000000000..46bdcd9b04f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/serving_config_service.proto @@ -0,0 +1,240 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for modifying ServingConfig. +service ServingConfigService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ServingConfig. + // + // A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s + // are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise + // a FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + body: "serving_config" + }; + option (google.api.method_signature) = + "parent,serving_config,serving_config_id"; + } + + // Deletes a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc DeleteServingConfig(DeleteServingConfigRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + body: "serving_config" + }; + option (google.api.method_signature) = "serving_config,update_mask"; + } + + // Gets a ServingConfig. + // + // Returns a NotFound error if the ServingConfig does not exist. + rpc GetServingConfig(GetServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all ServingConfigs linked to this catalog. + rpc ListServingConfigs(ListServingConfigsRequest) + returns (ListServingConfigsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a Control on the specified ServingConfig. + // The control is added in the last position of the list of controls + // it belongs to (e.g. if it's a facet spec control it will be applied + // in the last position of servingConfig.facetSpecIds) + // Returns a ALREADY_EXISTS error if the control has already been applied. + // Returns a FAILED_PRECONDITION error if the addition could exceed maximum + // number of control allowed for that type of control. + rpc AddControl(AddControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } + + // Disables a Control on the specified ServingConfig. + // The control is removed from the ServingConfig. + // Returns a NOT_FOUND error if the Control is not enabled for the + // ServingConfig. + rpc RemoveControl(RemoveControlRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl" + body: "*" + }; + option (google.api.method_signature) = "serving_config"; + } +} + +// Request for CreateServingConfig method. +message CreateServingConfigRequest { + // Required. Full resource name of parent. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The ServingConfig to create. + ServingConfig serving_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the ServingConfig, which will become the final + // component of the ServingConfig's resource name. + // + // This value should be 4-63 characters, and valid characters + // are /[a-z][0-9]-_/. + string serving_config_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for UpdateServingConfig method. +message UpdateServingConfigRequest { + // Required. The ServingConfig to update. + ServingConfig serving_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2beta.ServingConfig.name] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for DeleteServingConfig method. +message DeleteServingConfigRequest { + // Required. The resource name of the ServingConfig to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for GetServingConfig method. +message GetServingConfigRequest { + // Required. The resource name of the ServingConfig to get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; +} + +// Request for ListServingConfigs method. +message ListServingConfigsRequest { + // Required. The catalog resource name. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Optional. Maximum number of results to return. If unspecified, defaults + // to 100. If a value greater than 100 is provided, at most 100 results are + // returned. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListServingConfigs` call. + // Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Response for ListServingConfigs method. +message ListServingConfigsResponse { + // All the ServingConfigs for a given catalog. + repeated ServingConfig serving_configs = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request for AddControl method. +message AddControlRequest { + // Required. The source ServingConfig resource name . Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config - if id is not found a NOT_FOUND error is returned. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for RemoveControl method. +message RemoveControlRequest { + // Required. The source ServingConfig resource name . Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + string serving_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + } + ]; + + // Required. The id of the control to apply. Assumed to be in the same catalog + // as the serving config. + string control_id = 2 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event.proto new file mode 100644 index 00000000000..3d88483e79f --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event.proto @@ -0,0 +1,345 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/field_behavior.proto"; +import "google/cloud/retail/v2beta/common.proto"; +import "google/cloud/retail/v2beta/product.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// UserEvent captures all metadata information Retail API needs to know about +// how end users interact with customers' website. +message UserEvent { + // Required. User event type. Allowed values are: + // + // * `add-to-cart`: Products being added to cart. + // * `category-page-view`: Special pages such as sale or promotion pages + // viewed. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed. + // * `promotion-offered`: Promotion is offered to a user. + // * `promotion-not-offered`: Promotion is not offered to a user. + // * `purchase-complete`: User finishing a purchase. + // * `search`: Product search. + // * `shopping-cart-page-view`: User viewing a shopping cart. + string event_type = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A unique identifier for tracking visitors. + // + // For example, this could be implemented with an HTTP cookie, which should be + // able to uniquely identify a visitor on a single device. This unique + // identifier should not change if the visitor log in/out of the website. + // + // Don't set the field to the same fixed ID for different users. This mixes + // the event history of those users together, which results in degraded model + // quality. + // + // The field must be a UTF-8 encoded string with a length limit of 128 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // The field should not contain PII or user-data. We recommend to use Google + // Analytics [Client + // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) + // for this field. + string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // A unique identifier for tracking a visitor session with a length limit of + // 128 bytes. A session is an aggregation of an end user behavior in a time + // span. + // + // A general guideline to populate the sesion_id: + // 1. If user has no activity for 30 min, a new session_id should be assigned. + // 2. The session_id should be unique across users, suggest use uuid or add + // visitor_id as prefix. + string session_id = 21; + + // Only required for + // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] + // method. Timestamp of when the user event happened. + google.protobuf.Timestamp event_time = 3; + + // A list of identifiers for the independent experiment groups this user event + // belongs to. This is used to distinguish between user events associated with + // different experiment setups (e.g. using Retail API, using different + // recommendation models). + repeated string experiment_ids = 4; + + // Highly recommended for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // This field enables accurate attribution of recommendation model + // performance. + // + // The value must be a valid + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // for user events that are the result of + // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. + // The value must be a valid + // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] + // for user events that are the result of + // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. + // + // This token enables us to accurately attribute page view or purchase back to + // the event and the particular predict response containing this + // clicked/purchased product. If user clicks on product K in the + // recommendation results, pass + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // as a URL parameter to product K's page. When recording events on product + // K's page, log the + // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] + // to this field. + string attribution_token = 5; + + // The main product details related to the event. + // + // This field is optional except for the following event types: + // + // * `add-to-cart` + // * `detail-page-view` + // * `purchase-complete` + // + // In a `search` event, this field represents the products returned to the end + // user on the current page (the end user may have not finished browsing the + // whole page yet). When a new page is returned to the end user, after + // pagination/filtering/ordering even for the same query, a new `search` event + // with different + // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is + // desired. The end user may have not finished browsing the whole page yet. + repeated ProductDetail product_details = 6; + + // The main auto-completion details related to the event. + // + // This field should be set for `search` event when autocomplete function is + // enabled and the user clicks a suggestion for search. + CompletionDetail completion_detail = 22; + + // Extra user event features to include in the recommendation model. + // + // If you provide custom attributes for ingested user events, also include + // them in the user events that you associate with prediction requests. Custom + // attribute formatting must be consistent between imported events and events + // provided with prediction requests. This lets the Retail API use + // those custom attributes when training models and serving predictions, which + // helps improve recommendation quality. + // + // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT + // error is returned: + // + // * The key must be a UTF-8 encoded string with a length limit of 5,000 + // characters. + // * For text attributes, at most 400 values are allowed. Empty values are not + // allowed. Each value must be a UTF-8 encoded string with a length limit of + // 256 characters. + // * For number attributes, at most 400 values are allowed. + // + // For product recommendations, an example of extra user information is + // traffic_channel, which is how a user arrives at the site. Users can arrive + // at the site by coming to the site directly, coming through Google + // search, or in other ways. + map attributes = 7; + + // The ID or name of the associated shopping cart. This ID is used + // to associate multiple items added or present in the cart before purchase. + // + // This can only be set for `add-to-cart`, `purchase-complete`, or + // `shopping-cart-page-view` events. + string cart_id = 8; + + // A transaction represents the entire purchase transaction. + // + // Required for `purchase-complete` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + PurchaseTransaction purchase_transaction = 9; + + // The user's search query. + // + // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] + // for definition. + // + // The value must be a UTF-8 encoded string with a length limit of 5,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + string search_query = 10; + + // The filter syntax consists of an expression language for constructing a + // predicate from one or more fields of the products being filtered. + // + // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + string filter = 16; + + // The order in which products are returned. + // + // See + // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] + // for definition and syntax. + // + // The value must be a UTF-8 encoded string with a length limit of 1,000 + // characters. Otherwise, an INVALID_ARGUMENT error is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + string order_by = 17; + + // An integer that specifies the current offset for pagination (the 0-indexed + // starting location, amongst the products deemed by the API as relevant). + // + // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] + // for definition. + // + // If this field is negative, an INVALID_ARGUMENT is returned. + // + // This can only be set for `search` events. Other event types should not set + // this field. Otherwise, an INVALID_ARGUMENT error is returned. + int32 offset = 18; + + // The categories associated with a category page. + // + // To represent full path of category, use '>' sign to separate different + // hierarchies. If '>' is part of the category name, replace it with + // other character(s). + // + // Category pages include special pages such as sales or promotions. For + // instance, a special sale page may have the category hierarchy: + // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + // + // Required for `category-page-view` events. At least one of + // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or + // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is + // required for `search` events. Other event types should not set this field. + // Otherwise, an INVALID_ARGUMENT error is returned. + repeated string page_categories = 11; + + // User information. + UserInfo user_info = 12; + + // Complete URL (window.location.href) of the user's current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. Maximum length 5,000 + // characters. + string uri = 13; + + // The referrer URL of the current page. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string referrer_uri = 14; + + // A unique ID of a web page view. + // + // This should be kept the same for all user events triggered from the same + // pageview. For example, an item detail page view could trigger multiple + // events as the user is browsing the page. The `pageViewId` property should + // be kept the same for all these events so that they can be grouped together + // properly. + // + // When using the client side event reporting with JavaScript pixel and Google + // Tag Manager, this value is filled in automatically. + string page_view_id = 15; +} + +// Detailed product information associated with a user event. +message ProductDetail { + // Required. [Product][google.cloud.retail.v2beta.Product] information. + // + // Required field(s): + // + // * [Product.id][google.cloud.retail.v2beta.Product.id] + // + // Optional override field(s): + // + // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] + // + // If any supported optional fields are provided, we will treat them as a full + // override when looking up product information from the catalog. Thus, it is + // important to ensure that the overriding fields are accurate and + // complete. + // + // All other product fields are ignored and instead populated via catalog + // lookup after event ingestion. + Product product = 1 [(google.api.field_behavior) = REQUIRED]; + + // Quantity of the product associated with the user event. + // + // For example, this field will be 2 if two products are added to the shopping + // cart for `purchase-complete` event. Required for `add-to-cart` and + // `purchase-complete` event types. + google.protobuf.Int32Value quantity = 2; +} + +// Detailed completion information including completion attribution token and +// clicked completion info. +message CompletionDetail { + // Completion attribution token in + // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. + string completion_attribution_token = 1; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. + string selected_suggestion = 2; + + // End user selected + // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] + // position, starting from 0. + int32 selected_position = 3; +} + +// A transaction represents the entire purchase transaction. +message PurchaseTransaction { + // The transaction ID with a length limit of 128 characters. + string id = 1; + + // Required. Total non-zero revenue or grand total associated with the + // transaction. This value include shipping, tax, or other adjustments to + // total revenue that you want to include as part of your revenue + // calculations. + float revenue = 2 [(google.api.field_behavior) = REQUIRED]; + + // All the taxes associated with the transaction. + float tax = 3; + + // All the costs associated with the products. These can be manufacturing + // costs, shipping expenses not borne by the end user, or any other costs, + // such that: + // + // * Profit = + // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - + // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - + // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] + float cost = 4; + + // Required. Currency code. Use three-character ISO-4217 code. + string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event_service.proto new file mode 100644 index 00000000000..74dccdff892 --- /dev/null +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2beta/user_event_service.proto @@ -0,0 +1,190 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.retail.v2beta; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/httpbody.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2beta/import_config.proto"; +import "google/cloud/retail/v2beta/purge_config.proto"; +import "google/cloud/retail/v2beta/user_event.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail"; +option java_multiple_files = true; +option java_outer_classname = "UserEventServiceProto"; +option java_package = "com.google.cloud.retail.v2beta"; +option objc_class_prefix = "RETAIL"; +option php_namespace = "Google\\Cloud\\Retail\\V2beta"; +option ruby_package = "Google::Cloud::Retail::V2beta"; + +// Service for ingesting end user actions on the customer website. +service UserEventService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Writes a single user event. + rpc WriteUserEvent(WriteUserEventRequest) returns (UserEvent) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write" + body: "user_event" + }; + } + + // Writes a single user event from the browser. This uses a GET request to + // due to browser restriction of POST-ing to a 3rd party domain. + // + // This method is used only by the Retail API JavaScript pixel and Google Tag + // Manager. Users should not call this method directly. + rpc CollectUserEvent(CollectUserEventRequest) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }; + } + + // Deletes permanently all user events specified by the filter provided. + // Depending on the number of events specified by the filter, this operation + // could take hours or days to complete. To test a filter, use the list + // command first. + rpc PurgeUserEvents(PurgeUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.PurgeUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.PurgeMetadata" + }; + } + + // Bulk import of User events. Request processing might be + // synchronous. Events that already exist are skipped. + // Use this method for backfilling historical user events. + // + // `Operation.response` is of type `ImportResponse`. Note that it is + // possible for a subset of the items to be successfully inserted. + // `Operation.metadata` is of type `ImportMetadata`. + rpc ImportUserEvents(ImportUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.ImportUserEventsResponse" + metadata_type: "google.cloud.retail.v2beta.ImportMetadata" + }; + } + + // Starts a user-event rejoin operation with latest product catalog. Events + // are not annotated with detailed product information for products that are + // missing from the catalog when the user event is ingested. These + // events are stored as unjoined events with limited usage on training and + // serving. You can use this method to start a join operation on specified + // events with the latest version of product catalog. You can also use this + // method to correct events joined with the wrong product catalog. A rejoin + // operation can take hours or days to complete. + rpc RejoinUserEvents(RejoinUserEventsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "RejoinUserEventsResponse" + metadata_type: "RejoinUserEventsMetadata" + }; + } +} + +// Request message for WriteUserEvent method. +message WriteUserEventRequest { + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. User event to write. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // Required. The parent catalog name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. URL encoded UserEvent proto with a length limit of 2,000,000 + // characters. + string user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // The URL including cgi-parameters but excluding the hash fragment with a + // length limit of 5,000 characters. This is often more useful than the + // referer URL, because many browsers only send the domain for 3rd party + // requests. + string uri = 3; + + // The event timestamp in milliseconds. This prevents browser caching of + // otherwise identical get requests. The name is abbreviated to reduce the + // payload bytes. + int64 ets = 4; +} + +// Request message for RejoinUserEvents method. +message RejoinUserEventsRequest { + // The scope of user events to be rejoined with the latest product catalog. + // If the rejoining aims at reducing number of unjoined events, set + // `UserEventRejoinScope` to `UNJOINED_EVENTS`. + // If the rejoining aims at correcting product catalog information in joined + // events, set `UserEventRejoinScope` to `JOINED_EVENTS`. + // If all events needs to be rejoined, set `UserEventRejoinScope` to + // `USER_EVENT_REJOIN_SCOPE_UNSPECIFIED`. + enum UserEventRejoinScope { + // Rejoin all events with the latest product catalog, including both joined + // events and unjoined events. + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0; + + // Only rejoin joined events with the latest product catalog. + JOINED_EVENTS = 1; + + // Only rejoin unjoined events with the latest product catalog. + UNJOINED_EVENTS = 2; + } + + // Required. The parent catalog resource name, such as + // `projects/1234/locations/global/catalogs/default_catalog`. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of the user event rejoin to define the scope and range of the user + // events to be rejoined with the latest product catalog. Defaults to + // `USER_EVENT_REJOIN_SCOPE_UNSPECIFIED` if this field is not set, or set to + // an invalid integer value. + UserEventRejoinScope user_event_rejoin_scope = 2; +} + +// Response message for `RejoinUserEvents` method. +message RejoinUserEventsResponse { + // Number of user events that were joined with latest product catalog. + int64 rejoined_user_events_count = 1; +} + +// Metadata for `RejoinUserEvents` method. +message RejoinUserEventsMetadata {} diff --git a/packages/google-cloud-retail/protos/protos.d.ts b/packages/google-cloud-retail/protos/protos.d.ts new file mode 100644 index 00000000000..1d348e9aa9b --- /dev/null +++ b/packages/google-cloud-retail/protos/protos.d.ts @@ -0,0 +1,59739 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import type {protobuf as $protobuf} from "google-gax"; +import Long = require("long"); +/** Namespace google. */ +export namespace google { + + /** Namespace cloud. */ + namespace cloud { + + /** Namespace retail. */ + namespace retail { + + /** Namespace v2. */ + namespace v2 { + + /** Properties of a ProductLevelConfig. */ + interface IProductLevelConfig { + + /** ProductLevelConfig ingestionProductType */ + ingestionProductType?: (string|null); + + /** ProductLevelConfig merchantCenterProductIdField */ + merchantCenterProductIdField?: (string|null); + } + + /** Represents a ProductLevelConfig. */ + class ProductLevelConfig implements IProductLevelConfig { + + /** + * Constructs a new ProductLevelConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IProductLevelConfig); + + /** ProductLevelConfig ingestionProductType. */ + public ingestionProductType: string; + + /** ProductLevelConfig merchantCenterProductIdField. */ + public merchantCenterProductIdField: string; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductLevelConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IProductLevelConfig): google.cloud.retail.v2.ProductLevelConfig; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductLevelConfig + * @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.cloud.retail.v2.ProductLevelConfig; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductLevelConfig + * @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.cloud.retail.v2.ProductLevelConfig; + + /** + * Verifies a ProductLevelConfig 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 ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductLevelConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ProductLevelConfig; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @param message ProductLevelConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ProductLevelConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductLevelConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductLevelConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CatalogAttribute. */ + interface ICatalogAttribute { + + /** CatalogAttribute key */ + key?: (string|null); + + /** CatalogAttribute inUse */ + inUse?: (boolean|null); + + /** CatalogAttribute type */ + type?: (google.cloud.retail.v2.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2.CatalogAttribute.AttributeType|null); + + /** CatalogAttribute indexableOption */ + indexableOption?: (google.cloud.retail.v2.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.IndexableOption|null); + + /** CatalogAttribute dynamicFacetableOption */ + dynamicFacetableOption?: (google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption|null); + + /** CatalogAttribute searchableOption */ + searchableOption?: (google.cloud.retail.v2.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.SearchableOption|null); + } + + /** Represents a CatalogAttribute. */ + class CatalogAttribute implements ICatalogAttribute { + + /** + * Constructs a new CatalogAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICatalogAttribute); + + /** CatalogAttribute key. */ + public key: string; + + /** CatalogAttribute inUse. */ + public inUse: boolean; + + /** CatalogAttribute type. */ + public type: (google.cloud.retail.v2.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2.CatalogAttribute.AttributeType); + + /** CatalogAttribute indexableOption. */ + public indexableOption: (google.cloud.retail.v2.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.IndexableOption); + + /** CatalogAttribute dynamicFacetableOption. */ + public dynamicFacetableOption: (google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption); + + /** CatalogAttribute searchableOption. */ + public searchableOption: (google.cloud.retail.v2.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2.CatalogAttribute.SearchableOption); + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CatalogAttribute instance + */ + public static create(properties?: google.cloud.retail.v2.ICatalogAttribute): google.cloud.retail.v2.CatalogAttribute; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CatalogAttribute + * @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.cloud.retail.v2.CatalogAttribute; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CatalogAttribute + * @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.cloud.retail.v2.CatalogAttribute; + + /** + * Verifies a CatalogAttribute 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 CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CatalogAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CatalogAttribute; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @param message CatalogAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CatalogAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CatalogAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CatalogAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CatalogAttribute { + + /** AttributeType enum. */ + enum AttributeType { + UNKNOWN = 0, + TEXTUAL = 1, + NUMERICAL = 2 + } + + /** IndexableOption enum. */ + enum IndexableOption { + INDEXABLE_OPTION_UNSPECIFIED = 0, + INDEXABLE_ENABLED = 1, + INDEXABLE_DISABLED = 2 + } + + /** DynamicFacetableOption enum. */ + enum DynamicFacetableOption { + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0, + DYNAMIC_FACETABLE_ENABLED = 1, + DYNAMIC_FACETABLE_DISABLED = 2 + } + + /** SearchableOption enum. */ + enum SearchableOption { + SEARCHABLE_OPTION_UNSPECIFIED = 0, + SEARCHABLE_ENABLED = 1, + SEARCHABLE_DISABLED = 2 + } + } + + /** Properties of an AttributesConfig. */ + interface IAttributesConfig { + + /** AttributesConfig name */ + name?: (string|null); + + /** AttributesConfig catalogAttributes */ + catalogAttributes?: ({ [k: string]: google.cloud.retail.v2.ICatalogAttribute }|null); + + /** AttributesConfig attributeConfigLevel */ + attributeConfigLevel?: (google.cloud.retail.v2.AttributeConfigLevel|keyof typeof google.cloud.retail.v2.AttributeConfigLevel|null); + } + + /** Represents an AttributesConfig. */ + class AttributesConfig implements IAttributesConfig { + + /** + * Constructs a new AttributesConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAttributesConfig); + + /** AttributesConfig name. */ + public name: string; + + /** AttributesConfig catalogAttributes. */ + public catalogAttributes: { [k: string]: google.cloud.retail.v2.ICatalogAttribute }; + + /** AttributesConfig attributeConfigLevel. */ + public attributeConfigLevel: (google.cloud.retail.v2.AttributeConfigLevel|keyof typeof google.cloud.retail.v2.AttributeConfigLevel); + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns AttributesConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IAttributesConfig): google.cloud.retail.v2.AttributesConfig; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AttributesConfig + * @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.cloud.retail.v2.AttributesConfig; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AttributesConfig + * @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.cloud.retail.v2.AttributesConfig; + + /** + * Verifies an AttributesConfig 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 AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AttributesConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AttributesConfig; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @param message AttributesConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AttributesConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AttributesConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AttributesConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionConfig. */ + interface ICompletionConfig { + + /** CompletionConfig name */ + name?: (string|null); + + /** CompletionConfig matchingOrder */ + matchingOrder?: (string|null); + + /** CompletionConfig maxSuggestions */ + maxSuggestions?: (number|null); + + /** CompletionConfig minPrefixLength */ + minPrefixLength?: (number|null); + + /** CompletionConfig autoLearning */ + autoLearning?: (boolean|null); + + /** CompletionConfig suggestionsInputConfig */ + suggestionsInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation */ + lastSuggestionsImportOperation?: (string|null); + + /** CompletionConfig denylistInputConfig */ + denylistInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation */ + lastDenylistImportOperation?: (string|null); + + /** CompletionConfig allowlistInputConfig */ + allowlistInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation */ + lastAllowlistImportOperation?: (string|null); + } + + /** Represents a CompletionConfig. */ + class CompletionConfig implements ICompletionConfig { + + /** + * Constructs a new CompletionConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICompletionConfig); + + /** CompletionConfig name. */ + public name: string; + + /** CompletionConfig matchingOrder. */ + public matchingOrder: string; + + /** CompletionConfig maxSuggestions. */ + public maxSuggestions: number; + + /** CompletionConfig minPrefixLength. */ + public minPrefixLength: number; + + /** CompletionConfig autoLearning. */ + public autoLearning: boolean; + + /** CompletionConfig suggestionsInputConfig. */ + public suggestionsInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation. */ + public lastSuggestionsImportOperation: string; + + /** CompletionConfig denylistInputConfig. */ + public denylistInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation. */ + public lastDenylistImportOperation: string; + + /** CompletionConfig allowlistInputConfig. */ + public allowlistInputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation. */ + public lastAllowlistImportOperation: string; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionConfig instance + */ + public static create(properties?: google.cloud.retail.v2.ICompletionConfig): google.cloud.retail.v2.CompletionConfig; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionConfig + * @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.cloud.retail.v2.CompletionConfig; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionConfig + * @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.cloud.retail.v2.CompletionConfig; + + /** + * Verifies a CompletionConfig 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 CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompletionConfig; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @param message CompletionConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompletionConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Catalog. */ + interface ICatalog { + + /** Catalog name */ + name?: (string|null); + + /** Catalog displayName */ + displayName?: (string|null); + + /** Catalog productLevelConfig */ + productLevelConfig?: (google.cloud.retail.v2.IProductLevelConfig|null); + } + + /** Represents a Catalog. */ + class Catalog implements ICatalog { + + /** + * Constructs a new Catalog. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICatalog); + + /** Catalog name. */ + public name: string; + + /** Catalog displayName. */ + public displayName: string; + + /** Catalog productLevelConfig. */ + public productLevelConfig?: (google.cloud.retail.v2.IProductLevelConfig|null); + + /** + * Creates a new Catalog instance using the specified properties. + * @param [properties] Properties to set + * @returns Catalog instance + */ + public static create(properties?: google.cloud.retail.v2.ICatalog): google.cloud.retail.v2.Catalog; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Catalog + * @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.cloud.retail.v2.Catalog; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Catalog + * @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.cloud.retail.v2.Catalog; + + /** + * Verifies a Catalog 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 Catalog message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Catalog + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Catalog; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @param message Catalog + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Catalog, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Catalog to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Catalog + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** AttributeConfigLevel enum. */ + enum AttributeConfigLevel { + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0, + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1, + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2 + } + + /** SolutionType enum. */ + enum SolutionType { + SOLUTION_TYPE_UNSPECIFIED = 0, + SOLUTION_TYPE_RECOMMENDATION = 1, + SOLUTION_TYPE_SEARCH = 2 + } + + /** SearchSolutionUseCase enum. */ + enum SearchSolutionUseCase { + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0, + SEARCH_SOLUTION_USE_CASE_SEARCH = 1, + SEARCH_SOLUTION_USE_CASE_BROWSE = 2 + } + + /** Properties of a Condition. */ + interface ICondition { + + /** Condition queryTerms */ + queryTerms?: (google.cloud.retail.v2.Condition.IQueryTerm[]|null); + + /** Condition activeTimeRange */ + activeTimeRange?: (google.cloud.retail.v2.Condition.ITimeRange[]|null); + } + + /** Represents a Condition. */ + class Condition implements ICondition { + + /** + * Constructs a new Condition. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICondition); + + /** Condition queryTerms. */ + public queryTerms: google.cloud.retail.v2.Condition.IQueryTerm[]; + + /** Condition activeTimeRange. */ + public activeTimeRange: google.cloud.retail.v2.Condition.ITimeRange[]; + + /** + * Creates a new Condition instance using the specified properties. + * @param [properties] Properties to set + * @returns Condition instance + */ + public static create(properties?: google.cloud.retail.v2.ICondition): google.cloud.retail.v2.Condition; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Condition + * @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.cloud.retail.v2.Condition; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Condition + * @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.cloud.retail.v2.Condition; + + /** + * Verifies a Condition 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 Condition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Condition + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Condition; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @param message Condition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Condition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Condition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Condition + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Condition { + + /** Properties of a QueryTerm. */ + interface IQueryTerm { + + /** QueryTerm value */ + value?: (string|null); + + /** QueryTerm fullMatch */ + fullMatch?: (boolean|null); + } + + /** Represents a QueryTerm. */ + class QueryTerm implements IQueryTerm { + + /** + * Constructs a new QueryTerm. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Condition.IQueryTerm); + + /** QueryTerm value. */ + public value: string; + + /** QueryTerm fullMatch. */ + public fullMatch: boolean; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryTerm instance + */ + public static create(properties?: google.cloud.retail.v2.Condition.IQueryTerm): google.cloud.retail.v2.Condition.QueryTerm; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryTerm + * @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.cloud.retail.v2.Condition.QueryTerm; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryTerm + * @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.cloud.retail.v2.Condition.QueryTerm; + + /** + * Verifies a QueryTerm 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 QueryTerm message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTerm + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Condition.QueryTerm; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @param message QueryTerm + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Condition.QueryTerm, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTerm to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryTerm + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TimeRange. */ + interface ITimeRange { + + /** TimeRange startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TimeRange. */ + class TimeRange implements ITimeRange { + + /** + * Constructs a new TimeRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Condition.ITimeRange); + + /** TimeRange startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new TimeRange instance using the specified properties. + * @param [properties] Properties to set + * @returns TimeRange instance + */ + public static create(properties?: google.cloud.retail.v2.Condition.ITimeRange): google.cloud.retail.v2.Condition.TimeRange; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TimeRange + * @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.cloud.retail.v2.Condition.TimeRange; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TimeRange + * @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.cloud.retail.v2.Condition.TimeRange; + + /** + * Verifies a TimeRange 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 TimeRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TimeRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Condition.TimeRange; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @param message TimeRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Condition.TimeRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TimeRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TimeRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rule. */ + interface IRule { + + /** Rule boostAction */ + boostAction?: (google.cloud.retail.v2.Rule.IBoostAction|null); + + /** Rule redirectAction */ + redirectAction?: (google.cloud.retail.v2.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction */ + onewaySynonymsAction?: (google.cloud.retail.v2.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction */ + doNotAssociateAction?: (google.cloud.retail.v2.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction */ + replacementAction?: (google.cloud.retail.v2.Rule.IReplacementAction|null); + + /** Rule ignoreAction */ + ignoreAction?: (google.cloud.retail.v2.Rule.IIgnoreAction|null); + + /** Rule filterAction */ + filterAction?: (google.cloud.retail.v2.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction */ + twowaySynonymsAction?: (google.cloud.retail.v2.Rule.ITwowaySynonymsAction|null); + + /** Rule condition */ + condition?: (google.cloud.retail.v2.ICondition|null); + } + + /** Represents a Rule. */ + class Rule implements IRule { + + /** + * Constructs a new Rule. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRule); + + /** Rule boostAction. */ + public boostAction?: (google.cloud.retail.v2.Rule.IBoostAction|null); + + /** Rule redirectAction. */ + public redirectAction?: (google.cloud.retail.v2.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction. */ + public onewaySynonymsAction?: (google.cloud.retail.v2.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction. */ + public doNotAssociateAction?: (google.cloud.retail.v2.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction. */ + public replacementAction?: (google.cloud.retail.v2.Rule.IReplacementAction|null); + + /** Rule ignoreAction. */ + public ignoreAction?: (google.cloud.retail.v2.Rule.IIgnoreAction|null); + + /** Rule filterAction. */ + public filterAction?: (google.cloud.retail.v2.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction. */ + public twowaySynonymsAction?: (google.cloud.retail.v2.Rule.ITwowaySynonymsAction|null); + + /** Rule condition. */ + public condition?: (google.cloud.retail.v2.ICondition|null); + + /** Rule action. */ + public action?: ("boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"); + + /** + * Creates a new Rule instance using the specified properties. + * @param [properties] Properties to set + * @returns Rule instance + */ + public static create(properties?: google.cloud.retail.v2.IRule): google.cloud.retail.v2.Rule; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rule + * @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.cloud.retail.v2.Rule; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rule + * @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.cloud.retail.v2.Rule; + + /** + * Verifies a Rule 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 Rule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rule + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @param message Rule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Rule { + + /** Properties of a BoostAction. */ + interface IBoostAction { + + /** BoostAction boost */ + boost?: (number|null); + + /** BoostAction productsFilter */ + productsFilter?: (string|null); + } + + /** Represents a BoostAction. */ + class BoostAction implements IBoostAction { + + /** + * Constructs a new BoostAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IBoostAction); + + /** BoostAction boost. */ + public boost: number; + + /** BoostAction productsFilter. */ + public productsFilter: string; + + /** + * Creates a new BoostAction instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IBoostAction): google.cloud.retail.v2.Rule.BoostAction; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostAction + * @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.cloud.retail.v2.Rule.BoostAction; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostAction + * @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.cloud.retail.v2.Rule.BoostAction; + + /** + * Verifies a BoostAction 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 BoostAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.BoostAction; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @param message BoostAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.BoostAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FilterAction. */ + interface IFilterAction { + + /** FilterAction filter */ + filter?: (string|null); + } + + /** Represents a FilterAction. */ + class FilterAction implements IFilterAction { + + /** + * Constructs a new FilterAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IFilterAction); + + /** FilterAction filter. */ + public filter: string; + + /** + * Creates a new FilterAction instance using the specified properties. + * @param [properties] Properties to set + * @returns FilterAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IFilterAction): google.cloud.retail.v2.Rule.FilterAction; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FilterAction + * @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.cloud.retail.v2.Rule.FilterAction; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FilterAction + * @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.cloud.retail.v2.Rule.FilterAction; + + /** + * Verifies a FilterAction 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 FilterAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FilterAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.FilterAction; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @param message FilterAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.FilterAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FilterAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FilterAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RedirectAction. */ + interface IRedirectAction { + + /** RedirectAction redirectUri */ + redirectUri?: (string|null); + } + + /** Represents a RedirectAction. */ + class RedirectAction implements IRedirectAction { + + /** + * Constructs a new RedirectAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IRedirectAction); + + /** RedirectAction redirectUri. */ + public redirectUri: string; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @param [properties] Properties to set + * @returns RedirectAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IRedirectAction): google.cloud.retail.v2.Rule.RedirectAction; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RedirectAction + * @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.cloud.retail.v2.Rule.RedirectAction; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RedirectAction + * @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.cloud.retail.v2.Rule.RedirectAction; + + /** + * Verifies a RedirectAction 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 RedirectAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RedirectAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.RedirectAction; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @param message RedirectAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.RedirectAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RedirectAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RedirectAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TwowaySynonymsAction. */ + interface ITwowaySynonymsAction { + + /** TwowaySynonymsAction synonyms */ + synonyms?: (string[]|null); + } + + /** Represents a TwowaySynonymsAction. */ + class TwowaySynonymsAction implements ITwowaySynonymsAction { + + /** + * Constructs a new TwowaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.ITwowaySynonymsAction); + + /** TwowaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns TwowaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.ITwowaySynonymsAction): google.cloud.retail.v2.Rule.TwowaySynonymsAction; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2.Rule.TwowaySynonymsAction; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2.Rule.TwowaySynonymsAction; + + /** + * Verifies a TwowaySynonymsAction 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 TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TwowaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.TwowaySynonymsAction; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @param message TwowaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.TwowaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OnewaySynonymsAction. */ + interface IOnewaySynonymsAction { + + /** OnewaySynonymsAction queryTerms */ + queryTerms?: (string[]|null); + + /** OnewaySynonymsAction synonyms */ + synonyms?: (string[]|null); + + /** OnewaySynonymsAction onewayTerms */ + onewayTerms?: (string[]|null); + } + + /** Represents an OnewaySynonymsAction. */ + class OnewaySynonymsAction implements IOnewaySynonymsAction { + + /** + * Constructs a new OnewaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IOnewaySynonymsAction); + + /** OnewaySynonymsAction queryTerms. */ + public queryTerms: string[]; + + /** OnewaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** OnewaySynonymsAction onewayTerms. */ + public onewayTerms: string[]; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns OnewaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IOnewaySynonymsAction): google.cloud.retail.v2.Rule.OnewaySynonymsAction; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2.Rule.OnewaySynonymsAction; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2.Rule.OnewaySynonymsAction; + + /** + * Verifies an OnewaySynonymsAction 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 OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OnewaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.OnewaySynonymsAction; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @param message OnewaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.OnewaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DoNotAssociateAction. */ + interface IDoNotAssociateAction { + + /** DoNotAssociateAction queryTerms */ + queryTerms?: (string[]|null); + + /** DoNotAssociateAction doNotAssociateTerms */ + doNotAssociateTerms?: (string[]|null); + + /** DoNotAssociateAction terms */ + terms?: (string[]|null); + } + + /** Represents a DoNotAssociateAction. */ + class DoNotAssociateAction implements IDoNotAssociateAction { + + /** + * Constructs a new DoNotAssociateAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IDoNotAssociateAction); + + /** DoNotAssociateAction queryTerms. */ + public queryTerms: string[]; + + /** DoNotAssociateAction doNotAssociateTerms. */ + public doNotAssociateTerms: string[]; + + /** DoNotAssociateAction terms. */ + public terms: string[]; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @param [properties] Properties to set + * @returns DoNotAssociateAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IDoNotAssociateAction): google.cloud.retail.v2.Rule.DoNotAssociateAction; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DoNotAssociateAction + * @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.cloud.retail.v2.Rule.DoNotAssociateAction; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DoNotAssociateAction + * @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.cloud.retail.v2.Rule.DoNotAssociateAction; + + /** + * Verifies a DoNotAssociateAction 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 DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoNotAssociateAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.DoNotAssociateAction; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @param message DoNotAssociateAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.DoNotAssociateAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DoNotAssociateAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplacementAction. */ + interface IReplacementAction { + + /** ReplacementAction queryTerms */ + queryTerms?: (string[]|null); + + /** ReplacementAction replacementTerm */ + replacementTerm?: (string|null); + + /** ReplacementAction term */ + term?: (string|null); + } + + /** Represents a ReplacementAction. */ + class ReplacementAction implements IReplacementAction { + + /** + * Constructs a new ReplacementAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IReplacementAction); + + /** ReplacementAction queryTerms. */ + public queryTerms: string[]; + + /** ReplacementAction replacementTerm. */ + public replacementTerm: string; + + /** ReplacementAction term. */ + public term: string; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplacementAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IReplacementAction): google.cloud.retail.v2.Rule.ReplacementAction; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplacementAction + * @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.cloud.retail.v2.Rule.ReplacementAction; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplacementAction + * @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.cloud.retail.v2.Rule.ReplacementAction; + + /** + * Verifies a ReplacementAction 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 ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplacementAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.ReplacementAction; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @param message ReplacementAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.ReplacementAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplacementAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplacementAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an IgnoreAction. */ + interface IIgnoreAction { + + /** IgnoreAction ignoreTerms */ + ignoreTerms?: (string[]|null); + } + + /** Represents an IgnoreAction. */ + class IgnoreAction implements IIgnoreAction { + + /** + * Constructs a new IgnoreAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.Rule.IIgnoreAction); + + /** IgnoreAction ignoreTerms. */ + public ignoreTerms: string[]; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @param [properties] Properties to set + * @returns IgnoreAction instance + */ + public static create(properties?: google.cloud.retail.v2.Rule.IIgnoreAction): google.cloud.retail.v2.Rule.IgnoreAction; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IgnoreAction + * @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.cloud.retail.v2.Rule.IgnoreAction; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IgnoreAction + * @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.cloud.retail.v2.Rule.IgnoreAction; + + /** + * Verifies an IgnoreAction 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 IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IgnoreAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rule.IgnoreAction; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @param message IgnoreAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rule.IgnoreAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IgnoreAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IgnoreAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an Audience. */ + interface IAudience { + + /** Audience genders */ + genders?: (string[]|null); + + /** Audience ageGroups */ + ageGroups?: (string[]|null); + } + + /** Represents an Audience. */ + class Audience implements IAudience { + + /** + * Constructs a new Audience. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAudience); + + /** Audience genders. */ + public genders: string[]; + + /** Audience ageGroups. */ + public ageGroups: string[]; + + /** + * Creates a new Audience instance using the specified properties. + * @param [properties] Properties to set + * @returns Audience instance + */ + public static create(properties?: google.cloud.retail.v2.IAudience): google.cloud.retail.v2.Audience; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Audience + * @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.cloud.retail.v2.Audience; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Audience + * @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.cloud.retail.v2.Audience; + + /** + * Verifies an Audience 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 Audience message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Audience + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Audience; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @param message Audience + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Audience, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Audience to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Audience + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ColorInfo. */ + interface IColorInfo { + + /** ColorInfo colorFamilies */ + colorFamilies?: (string[]|null); + + /** ColorInfo colors */ + colors?: (string[]|null); + } + + /** Represents a ColorInfo. */ + class ColorInfo implements IColorInfo { + + /** + * Constructs a new ColorInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IColorInfo); + + /** ColorInfo colorFamilies. */ + public colorFamilies: string[]; + + /** ColorInfo colors. */ + public colors: string[]; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns ColorInfo instance + */ + public static create(properties?: google.cloud.retail.v2.IColorInfo): google.cloud.retail.v2.ColorInfo; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ColorInfo + * @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.cloud.retail.v2.ColorInfo; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ColorInfo + * @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.cloud.retail.v2.ColorInfo; + + /** + * Verifies a ColorInfo 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 ColorInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ColorInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ColorInfo; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @param message ColorInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ColorInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ColorInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ColorInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CustomAttribute. */ + interface ICustomAttribute { + + /** CustomAttribute text */ + text?: (string[]|null); + + /** CustomAttribute numbers */ + numbers?: (number[]|null); + + /** CustomAttribute searchable */ + searchable?: (boolean|null); + + /** CustomAttribute indexable */ + indexable?: (boolean|null); + } + + /** Represents a CustomAttribute. */ + class CustomAttribute implements ICustomAttribute { + + /** + * Constructs a new CustomAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICustomAttribute); + + /** CustomAttribute text. */ + public text: string[]; + + /** CustomAttribute numbers. */ + public numbers: number[]; + + /** CustomAttribute searchable. */ + public searchable?: (boolean|null); + + /** CustomAttribute indexable. */ + public indexable?: (boolean|null); + + /** CustomAttribute _searchable. */ + public _searchable?: "searchable"; + + /** CustomAttribute _indexable. */ + public _indexable?: "indexable"; + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomAttribute instance + */ + public static create(properties?: google.cloud.retail.v2.ICustomAttribute): google.cloud.retail.v2.CustomAttribute; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomAttribute + * @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.cloud.retail.v2.CustomAttribute; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomAttribute + * @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.cloud.retail.v2.CustomAttribute; + + /** + * Verifies a CustomAttribute 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 CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CustomAttribute; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @param message CustomAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CustomAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FulfillmentInfo. */ + interface IFulfillmentInfo { + + /** FulfillmentInfo type */ + type?: (string|null); + + /** FulfillmentInfo placeIds */ + placeIds?: (string[]|null); + } + + /** Represents a FulfillmentInfo. */ + class FulfillmentInfo implements IFulfillmentInfo { + + /** + * Constructs a new FulfillmentInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IFulfillmentInfo); + + /** FulfillmentInfo type. */ + public type: string; + + /** FulfillmentInfo placeIds. */ + public placeIds: string[]; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns FulfillmentInfo instance + */ + public static create(properties?: google.cloud.retail.v2.IFulfillmentInfo): google.cloud.retail.v2.FulfillmentInfo; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FulfillmentInfo + * @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.cloud.retail.v2.FulfillmentInfo; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FulfillmentInfo + * @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.cloud.retail.v2.FulfillmentInfo; + + /** + * Verifies a FulfillmentInfo 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 FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FulfillmentInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.FulfillmentInfo; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @param message FulfillmentInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.FulfillmentInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FulfillmentInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FulfillmentInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Image. */ + interface IImage { + + /** Image uri */ + uri?: (string|null); + + /** Image height */ + height?: (number|null); + + /** Image width */ + width?: (number|null); + } + + /** Represents an Image. */ + class Image implements IImage { + + /** + * Constructs a new Image. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImage); + + /** Image uri. */ + public uri: string; + + /** Image height. */ + public height: number; + + /** Image width. */ + public width: number; + + /** + * Creates a new Image instance using the specified properties. + * @param [properties] Properties to set + * @returns Image instance + */ + public static create(properties?: google.cloud.retail.v2.IImage): google.cloud.retail.v2.Image; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Image message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Image + * @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.cloud.retail.v2.Image; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Image + * @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.cloud.retail.v2.Image; + + /** + * Verifies an Image 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 Image message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Image + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Image; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @param message Image + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Image, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Image to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Image + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Interval. */ + interface IInterval { + + /** Interval minimum */ + minimum?: (number|null); + + /** Interval exclusiveMinimum */ + exclusiveMinimum?: (number|null); + + /** Interval maximum */ + maximum?: (number|null); + + /** Interval exclusiveMaximum */ + exclusiveMaximum?: (number|null); + } + + /** Represents an Interval. */ + class Interval implements IInterval { + + /** + * Constructs a new Interval. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IInterval); + + /** Interval minimum. */ + public minimum?: (number|null); + + /** Interval exclusiveMinimum. */ + public exclusiveMinimum?: (number|null); + + /** Interval maximum. */ + public maximum?: (number|null); + + /** Interval exclusiveMaximum. */ + public exclusiveMaximum?: (number|null); + + /** Interval min. */ + public min?: ("minimum"|"exclusiveMinimum"); + + /** Interval max. */ + public max?: ("maximum"|"exclusiveMaximum"); + + /** + * Creates a new Interval instance using the specified properties. + * @param [properties] Properties to set + * @returns Interval instance + */ + public static create(properties?: google.cloud.retail.v2.IInterval): google.cloud.retail.v2.Interval; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Interval + * @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.cloud.retail.v2.Interval; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Interval + * @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.cloud.retail.v2.Interval; + + /** + * Verifies an Interval 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 Interval message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Interval + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Interval; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @param message Interval + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Interval, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Interval to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Interval + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PriceInfo. */ + interface IPriceInfo { + + /** PriceInfo currencyCode */ + currencyCode?: (string|null); + + /** PriceInfo price */ + price?: (number|null); + + /** PriceInfo originalPrice */ + originalPrice?: (number|null); + + /** PriceInfo cost */ + cost?: (number|null); + + /** PriceInfo priceEffectiveTime */ + priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime */ + priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange */ + priceRange?: (google.cloud.retail.v2.PriceInfo.IPriceRange|null); + } + + /** Represents a PriceInfo. */ + class PriceInfo implements IPriceInfo { + + /** + * Constructs a new PriceInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPriceInfo); + + /** PriceInfo currencyCode. */ + public currencyCode: string; + + /** PriceInfo price. */ + public price: number; + + /** PriceInfo originalPrice. */ + public originalPrice: number; + + /** PriceInfo cost. */ + public cost: number; + + /** PriceInfo priceEffectiveTime. */ + public priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime. */ + public priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange. */ + public priceRange?: (google.cloud.retail.v2.PriceInfo.IPriceRange|null); + + /** + * Creates a new PriceInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceInfo instance + */ + public static create(properties?: google.cloud.retail.v2.IPriceInfo): google.cloud.retail.v2.PriceInfo; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceInfo + * @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.cloud.retail.v2.PriceInfo; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceInfo + * @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.cloud.retail.v2.PriceInfo; + + /** + * Verifies a PriceInfo 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 PriceInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PriceInfo; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @param message PriceInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PriceInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PriceInfo { + + /** Properties of a PriceRange. */ + interface IPriceRange { + + /** PriceRange price */ + price?: (google.cloud.retail.v2.IInterval|null); + + /** PriceRange originalPrice */ + originalPrice?: (google.cloud.retail.v2.IInterval|null); + } + + /** Represents a PriceRange. */ + class PriceRange implements IPriceRange { + + /** + * Constructs a new PriceRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.PriceInfo.IPriceRange); + + /** PriceRange price. */ + public price?: (google.cloud.retail.v2.IInterval|null); + + /** PriceRange originalPrice. */ + public originalPrice?: (google.cloud.retail.v2.IInterval|null); + + /** + * Creates a new PriceRange instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceRange instance + */ + public static create(properties?: google.cloud.retail.v2.PriceInfo.IPriceRange): google.cloud.retail.v2.PriceInfo.PriceRange; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceRange + * @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.cloud.retail.v2.PriceInfo.PriceRange; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceRange + * @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.cloud.retail.v2.PriceInfo.PriceRange; + + /** + * Verifies a PriceRange 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 PriceRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PriceInfo.PriceRange; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @param message PriceRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PriceInfo.PriceRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rating. */ + interface IRating { + + /** Rating ratingCount */ + ratingCount?: (number|null); + + /** Rating averageRating */ + averageRating?: (number|null); + + /** Rating ratingHistogram */ + ratingHistogram?: (number[]|null); + } + + /** Represents a Rating. */ + class Rating implements IRating { + + /** + * Constructs a new Rating. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRating); + + /** Rating ratingCount. */ + public ratingCount: number; + + /** Rating averageRating. */ + public averageRating: number; + + /** Rating ratingHistogram. */ + public ratingHistogram: number[]; + + /** + * Creates a new Rating instance using the specified properties. + * @param [properties] Properties to set + * @returns Rating instance + */ + public static create(properties?: google.cloud.retail.v2.IRating): google.cloud.retail.v2.Rating; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rating + * @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.cloud.retail.v2.Rating; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rating + * @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.cloud.retail.v2.Rating; + + /** + * Verifies a Rating 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 Rating message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rating + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Rating; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @param message Rating + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Rating, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rating to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rating + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserInfo. */ + interface IUserInfo { + + /** UserInfo userId */ + userId?: (string|null); + + /** UserInfo ipAddress */ + ipAddress?: (string|null); + + /** UserInfo userAgent */ + userAgent?: (string|null); + + /** UserInfo directUserRequest */ + directUserRequest?: (boolean|null); + } + + /** Represents a UserInfo. */ + class UserInfo implements IUserInfo { + + /** + * Constructs a new UserInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUserInfo); + + /** UserInfo userId. */ + public userId: string; + + /** UserInfo ipAddress. */ + public ipAddress: string; + + /** UserInfo userAgent. */ + public userAgent: string; + + /** UserInfo directUserRequest. */ + public directUserRequest: boolean; + + /** + * Creates a new UserInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns UserInfo instance + */ + public static create(properties?: google.cloud.retail.v2.IUserInfo): google.cloud.retail.v2.UserInfo; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserInfo + * @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.cloud.retail.v2.UserInfo; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserInfo + * @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.cloud.retail.v2.UserInfo; + + /** + * Verifies a UserInfo 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 UserInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UserInfo; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @param message UserInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UserInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a LocalInventory. */ + interface ILocalInventory { + + /** LocalInventory placeId */ + placeId?: (string|null); + + /** LocalInventory priceInfo */ + priceInfo?: (google.cloud.retail.v2.IPriceInfo|null); + + /** LocalInventory attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2.ICustomAttribute }|null); + + /** LocalInventory fulfillmentTypes */ + fulfillmentTypes?: (string[]|null); + } + + /** Represents a LocalInventory. */ + class LocalInventory implements ILocalInventory { + + /** + * Constructs a new LocalInventory. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ILocalInventory); + + /** LocalInventory placeId. */ + public placeId: string; + + /** LocalInventory priceInfo. */ + public priceInfo?: (google.cloud.retail.v2.IPriceInfo|null); + + /** LocalInventory attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2.ICustomAttribute }; + + /** LocalInventory fulfillmentTypes. */ + public fulfillmentTypes: string[]; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @param [properties] Properties to set + * @returns LocalInventory instance + */ + public static create(properties?: google.cloud.retail.v2.ILocalInventory): google.cloud.retail.v2.LocalInventory; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LocalInventory + * @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.cloud.retail.v2.LocalInventory; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LocalInventory + * @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.cloud.retail.v2.LocalInventory; + + /** + * Verifies a LocalInventory 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 LocalInventory message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocalInventory + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.LocalInventory; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @param message LocalInventory + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.LocalInventory, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocalInventory to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LocalInventory + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GcsSource. */ + interface IGcsSource { + + /** GcsSource inputUris */ + inputUris?: (string[]|null); + + /** GcsSource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a GcsSource. */ + class GcsSource implements IGcsSource { + + /** + * Constructs a new GcsSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGcsSource); + + /** GcsSource inputUris. */ + public inputUris: string[]; + + /** GcsSource dataSchema. */ + public dataSchema: string; + + /** + * Creates a new GcsSource instance using the specified properties. + * @param [properties] Properties to set + * @returns GcsSource instance + */ + public static create(properties?: google.cloud.retail.v2.IGcsSource): google.cloud.retail.v2.GcsSource; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GcsSource + * @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.cloud.retail.v2.GcsSource; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GcsSource + * @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.cloud.retail.v2.GcsSource; + + /** + * Verifies a GcsSource 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 GcsSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GcsSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GcsSource; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @param message GcsSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GcsSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GcsSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GcsSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BigQuerySource. */ + interface IBigQuerySource { + + /** BigQuerySource partitionDate */ + partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId */ + projectId?: (string|null); + + /** BigQuerySource datasetId */ + datasetId?: (string|null); + + /** BigQuerySource tableId */ + tableId?: (string|null); + + /** BigQuerySource gcsStagingDir */ + gcsStagingDir?: (string|null); + + /** BigQuerySource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a BigQuerySource. */ + class BigQuerySource implements IBigQuerySource { + + /** + * Constructs a new BigQuerySource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IBigQuerySource); + + /** BigQuerySource partitionDate. */ + public partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId. */ + public projectId: string; + + /** BigQuerySource datasetId. */ + public datasetId: string; + + /** BigQuerySource tableId. */ + public tableId: string; + + /** BigQuerySource gcsStagingDir. */ + public gcsStagingDir: string; + + /** BigQuerySource dataSchema. */ + public dataSchema: string; + + /** BigQuerySource partition. */ + public partition?: "partitionDate"; + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQuerySource instance + */ + public static create(properties?: google.cloud.retail.v2.IBigQuerySource): google.cloud.retail.v2.BigQuerySource; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQuerySource + * @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.cloud.retail.v2.BigQuerySource; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQuerySource + * @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.cloud.retail.v2.BigQuerySource; + + /** + * Verifies a BigQuerySource 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 BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQuerySource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.BigQuerySource; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @param message BigQuerySource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.BigQuerySource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQuerySource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BigQuerySource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInlineSource. */ + interface IProductInlineSource { + + /** ProductInlineSource products */ + products?: (google.cloud.retail.v2.IProduct[]|null); + } + + /** Represents a ProductInlineSource. */ + class ProductInlineSource implements IProductInlineSource { + + /** + * Constructs a new ProductInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IProductInlineSource); + + /** ProductInlineSource products. */ + public products: google.cloud.retail.v2.IProduct[]; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2.IProductInlineSource): google.cloud.retail.v2.ProductInlineSource; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInlineSource + * @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.cloud.retail.v2.ProductInlineSource; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInlineSource + * @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.cloud.retail.v2.ProductInlineSource; + + /** + * Verifies a ProductInlineSource 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 ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ProductInlineSource; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @param message ProductInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ProductInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInlineSource. */ + interface IUserEventInlineSource { + + /** UserEventInlineSource userEvents */ + userEvents?: (google.cloud.retail.v2.IUserEvent[]|null); + } + + /** Represents a UserEventInlineSource. */ + class UserEventInlineSource implements IUserEventInlineSource { + + /** + * Constructs a new UserEventInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUserEventInlineSource); + + /** UserEventInlineSource userEvents. */ + public userEvents: google.cloud.retail.v2.IUserEvent[]; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2.IUserEventInlineSource): google.cloud.retail.v2.UserEventInlineSource; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInlineSource + * @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.cloud.retail.v2.UserEventInlineSource; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInlineSource + * @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.cloud.retail.v2.UserEventInlineSource; + + /** + * Verifies a UserEventInlineSource 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 UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UserEventInlineSource; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @param message UserEventInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UserEventInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportErrorsConfig. */ + interface IImportErrorsConfig { + + /** ImportErrorsConfig gcsPrefix */ + gcsPrefix?: (string|null); + } + + /** Represents an ImportErrorsConfig. */ + class ImportErrorsConfig implements IImportErrorsConfig { + + /** + * Constructs a new ImportErrorsConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportErrorsConfig); + + /** ImportErrorsConfig gcsPrefix. */ + public gcsPrefix?: (string|null); + + /** ImportErrorsConfig destination. */ + public destination?: "gcsPrefix"; + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportErrorsConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IImportErrorsConfig): google.cloud.retail.v2.ImportErrorsConfig; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportErrorsConfig + * @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.cloud.retail.v2.ImportErrorsConfig; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportErrorsConfig + * @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.cloud.retail.v2.ImportErrorsConfig; + + /** + * Verifies an ImportErrorsConfig 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 ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportErrorsConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportErrorsConfig; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @param message ImportErrorsConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportErrorsConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportErrorsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsRequest. */ + interface IImportProductsRequest { + + /** ImportProductsRequest parent */ + parent?: (string|null); + + /** ImportProductsRequest requestId */ + requestId?: (string|null); + + /** ImportProductsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode */ + reconciliationMode?: (google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode|null); + + /** ImportProductsRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportProductsRequest. */ + class ImportProductsRequest implements IImportProductsRequest { + + /** + * Constructs a new ImportProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportProductsRequest); + + /** ImportProductsRequest parent. */ + public parent: string; + + /** ImportProductsRequest requestId. */ + public requestId: string; + + /** ImportProductsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode. */ + public reconciliationMode: (google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode); + + /** ImportProductsRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IImportProductsRequest): google.cloud.retail.v2.ImportProductsRequest; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsRequest + * @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.cloud.retail.v2.ImportProductsRequest; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsRequest + * @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.cloud.retail.v2.ImportProductsRequest; + + /** + * Verifies an ImportProductsRequest 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 ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportProductsRequest; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @param message ImportProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ImportProductsRequest { + + /** ReconciliationMode enum. */ + enum ReconciliationMode { + RECONCILIATION_MODE_UNSPECIFIED = 0, + INCREMENTAL = 1, + FULL = 2 + } + } + + /** Properties of an ImportUserEventsRequest. */ + interface IImportUserEventsRequest { + + /** ImportUserEventsRequest parent */ + parent?: (string|null); + + /** ImportUserEventsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + } + + /** Represents an ImportUserEventsRequest. */ + class ImportUserEventsRequest implements IImportUserEventsRequest { + + /** + * Constructs a new ImportUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportUserEventsRequest); + + /** ImportUserEventsRequest parent. */ + public parent: string; + + /** ImportUserEventsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IImportUserEventsRequest): google.cloud.retail.v2.ImportUserEventsRequest; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2.ImportUserEventsRequest; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2.ImportUserEventsRequest; + + /** + * Verifies an ImportUserEventsRequest 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 ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportUserEventsRequest; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @param message ImportUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataRequest. */ + interface IImportCompletionDataRequest { + + /** ImportCompletionDataRequest parent */ + parent?: (string|null); + + /** ImportCompletionDataRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportCompletionDataRequest. */ + class ImportCompletionDataRequest implements IImportCompletionDataRequest { + + /** + * Constructs a new ImportCompletionDataRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportCompletionDataRequest); + + /** ImportCompletionDataRequest parent. */ + public parent: string; + + /** ImportCompletionDataRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IImportCompletionDataRequest): google.cloud.retail.v2.ImportCompletionDataRequest; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2.ImportCompletionDataRequest; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2.ImportCompletionDataRequest; + + /** + * Verifies an ImportCompletionDataRequest 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 ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportCompletionDataRequest; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @param message ImportCompletionDataRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportCompletionDataRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInputConfig. */ + interface IProductInputConfig { + + /** ProductInputConfig productInlineSource */ + productInlineSource?: (google.cloud.retail.v2.IProductInlineSource|null); + + /** ProductInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2.IGcsSource|null); + + /** ProductInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + } + + /** Represents a ProductInputConfig. */ + class ProductInputConfig implements IProductInputConfig { + + /** + * Constructs a new ProductInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IProductInputConfig); + + /** ProductInputConfig productInlineSource. */ + public productInlineSource?: (google.cloud.retail.v2.IProductInlineSource|null); + + /** ProductInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2.IGcsSource|null); + + /** ProductInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + + /** ProductInputConfig source. */ + public source?: ("productInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IProductInputConfig): google.cloud.retail.v2.ProductInputConfig; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInputConfig + * @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.cloud.retail.v2.ProductInputConfig; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInputConfig + * @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.cloud.retail.v2.ProductInputConfig; + + /** + * Verifies a ProductInputConfig 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 ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ProductInputConfig; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @param message ProductInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ProductInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInputConfig. */ + interface IUserEventInputConfig { + + /** UserEventInputConfig userEventInlineSource */ + userEventInlineSource?: (google.cloud.retail.v2.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + } + + /** Represents a UserEventInputConfig. */ + class UserEventInputConfig implements IUserEventInputConfig { + + /** + * Constructs a new UserEventInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUserEventInputConfig); + + /** UserEventInputConfig userEventInlineSource. */ + public userEventInlineSource?: (google.cloud.retail.v2.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + + /** UserEventInputConfig source. */ + public source?: ("userEventInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IUserEventInputConfig): google.cloud.retail.v2.UserEventInputConfig; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInputConfig + * @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.cloud.retail.v2.UserEventInputConfig; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInputConfig + * @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.cloud.retail.v2.UserEventInputConfig; + + /** + * Verifies a UserEventInputConfig 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 UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UserEventInputConfig; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @param message UserEventInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UserEventInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDataInputConfig. */ + interface ICompletionDataInputConfig { + + /** CompletionDataInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + } + + /** Represents a CompletionDataInputConfig. */ + class CompletionDataInputConfig implements ICompletionDataInputConfig { + + /** + * Constructs a new CompletionDataInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICompletionDataInputConfig); + + /** CompletionDataInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2.IBigQuerySource|null); + + /** CompletionDataInputConfig source. */ + public source?: "bigQuerySource"; + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDataInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2.ICompletionDataInputConfig): google.cloud.retail.v2.CompletionDataInputConfig; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2.CompletionDataInputConfig; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2.CompletionDataInputConfig; + + /** + * Verifies a CompletionDataInputConfig 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 CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDataInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompletionDataInputConfig; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @param message CompletionDataInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompletionDataInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportMetadata. */ + interface IImportMetadata { + + /** ImportMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount */ + successCount?: (number|Long|string|null); + + /** ImportMetadata failureCount */ + failureCount?: (number|Long|string|null); + + /** ImportMetadata requestId */ + requestId?: (string|null); + + /** ImportMetadata notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportMetadata. */ + class ImportMetadata implements IImportMetadata { + + /** + * Constructs a new ImportMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportMetadata); + + /** ImportMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount. */ + public successCount: (number|Long|string); + + /** ImportMetadata failureCount. */ + public failureCount: (number|Long|string); + + /** ImportMetadata requestId. */ + public requestId: string; + + /** ImportMetadata notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IImportMetadata): google.cloud.retail.v2.ImportMetadata; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportMetadata + * @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.cloud.retail.v2.ImportMetadata; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportMetadata + * @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.cloud.retail.v2.ImportMetadata; + + /** + * Verifies an ImportMetadata 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 ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportMetadata; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @param message ImportMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsResponse. */ + interface IImportProductsResponse { + + /** ImportProductsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportProductsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + } + + /** Represents an ImportProductsResponse. */ + class ImportProductsResponse implements IImportProductsResponse { + + /** + * Constructs a new ImportProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportProductsResponse); + + /** ImportProductsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportProductsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IImportProductsResponse): google.cloud.retail.v2.ImportProductsResponse; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsResponse + * @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.cloud.retail.v2.ImportProductsResponse; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsResponse + * @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.cloud.retail.v2.ImportProductsResponse; + + /** + * Verifies an ImportProductsResponse 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 ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportProductsResponse; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @param message ImportProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportUserEventsResponse. */ + interface IImportUserEventsResponse { + + /** ImportUserEventsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportUserEventsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary */ + importSummary?: (google.cloud.retail.v2.IUserEventImportSummary|null); + } + + /** Represents an ImportUserEventsResponse. */ + class ImportUserEventsResponse implements IImportUserEventsResponse { + + /** + * Constructs a new ImportUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportUserEventsResponse); + + /** ImportUserEventsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportUserEventsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary. */ + public importSummary?: (google.cloud.retail.v2.IUserEventImportSummary|null); + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IImportUserEventsResponse): google.cloud.retail.v2.ImportUserEventsResponse; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2.ImportUserEventsResponse; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2.ImportUserEventsResponse; + + /** + * Verifies an ImportUserEventsResponse 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 ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportUserEventsResponse; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @param message ImportUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventImportSummary. */ + interface IUserEventImportSummary { + + /** UserEventImportSummary joinedEventsCount */ + joinedEventsCount?: (number|Long|string|null); + + /** UserEventImportSummary unjoinedEventsCount */ + unjoinedEventsCount?: (number|Long|string|null); + } + + /** Represents a UserEventImportSummary. */ + class UserEventImportSummary implements IUserEventImportSummary { + + /** + * Constructs a new UserEventImportSummary. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUserEventImportSummary); + + /** UserEventImportSummary joinedEventsCount. */ + public joinedEventsCount: (number|Long|string); + + /** UserEventImportSummary unjoinedEventsCount. */ + public unjoinedEventsCount: (number|Long|string); + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventImportSummary instance + */ + public static create(properties?: google.cloud.retail.v2.IUserEventImportSummary): google.cloud.retail.v2.UserEventImportSummary; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventImportSummary + * @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.cloud.retail.v2.UserEventImportSummary; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventImportSummary + * @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.cloud.retail.v2.UserEventImportSummary; + + /** + * Verifies a UserEventImportSummary 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 UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventImportSummary + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UserEventImportSummary; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @param message UserEventImportSummary + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UserEventImportSummary, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventImportSummary to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventImportSummary + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataResponse. */ + interface IImportCompletionDataResponse { + + /** ImportCompletionDataResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + } + + /** Represents an ImportCompletionDataResponse. */ + class ImportCompletionDataResponse implements IImportCompletionDataResponse { + + /** + * Constructs a new ImportCompletionDataResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IImportCompletionDataResponse); + + /** ImportCompletionDataResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IImportCompletionDataResponse): google.cloud.retail.v2.ImportCompletionDataResponse; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2.ImportCompletionDataResponse; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2.ImportCompletionDataResponse; + + /** + * Verifies an ImportCompletionDataResponse 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 ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ImportCompletionDataResponse; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @param message ImportCompletionDataResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ImportCompletionDataResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Product. */ + interface IProduct { + + /** Product expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl */ + ttl?: (google.protobuf.IDuration|null); + + /** Product name */ + name?: (string|null); + + /** Product id */ + id?: (string|null); + + /** Product type */ + type?: (google.cloud.retail.v2.Product.Type|keyof typeof google.cloud.retail.v2.Product.Type|null); + + /** Product primaryProductId */ + primaryProductId?: (string|null); + + /** Product collectionMemberIds */ + collectionMemberIds?: (string[]|null); + + /** Product gtin */ + gtin?: (string|null); + + /** Product categories */ + categories?: (string[]|null); + + /** Product title */ + title?: (string|null); + + /** Product brands */ + brands?: (string[]|null); + + /** Product description */ + description?: (string|null); + + /** Product languageCode */ + languageCode?: (string|null); + + /** Product attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2.ICustomAttribute }|null); + + /** Product tags */ + tags?: (string[]|null); + + /** Product priceInfo */ + priceInfo?: (google.cloud.retail.v2.IPriceInfo|null); + + /** Product rating */ + rating?: (google.cloud.retail.v2.IRating|null); + + /** Product availableTime */ + availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability */ + availability?: (google.cloud.retail.v2.Product.Availability|keyof typeof google.cloud.retail.v2.Product.Availability|null); + + /** Product availableQuantity */ + availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo */ + fulfillmentInfo?: (google.cloud.retail.v2.IFulfillmentInfo[]|null); + + /** Product uri */ + uri?: (string|null); + + /** Product images */ + images?: (google.cloud.retail.v2.IImage[]|null); + + /** Product audience */ + audience?: (google.cloud.retail.v2.IAudience|null); + + /** Product colorInfo */ + colorInfo?: (google.cloud.retail.v2.IColorInfo|null); + + /** Product sizes */ + sizes?: (string[]|null); + + /** Product materials */ + materials?: (string[]|null); + + /** Product patterns */ + patterns?: (string[]|null); + + /** Product conditions */ + conditions?: (string[]|null); + + /** Product promotions */ + promotions?: (google.cloud.retail.v2.IPromotion[]|null); + + /** Product publishTime */ + publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields */ + retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants */ + variants?: (google.cloud.retail.v2.IProduct[]|null); + + /** Product localInventories */ + localInventories?: (google.cloud.retail.v2.ILocalInventory[]|null); + } + + /** Represents a Product. */ + class Product implements IProduct { + + /** + * Constructs a new Product. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IProduct); + + /** Product expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl. */ + public ttl?: (google.protobuf.IDuration|null); + + /** Product name. */ + public name: string; + + /** Product id. */ + public id: string; + + /** Product type. */ + public type: (google.cloud.retail.v2.Product.Type|keyof typeof google.cloud.retail.v2.Product.Type); + + /** Product primaryProductId. */ + public primaryProductId: string; + + /** Product collectionMemberIds. */ + public collectionMemberIds: string[]; + + /** Product gtin. */ + public gtin: string; + + /** Product categories. */ + public categories: string[]; + + /** Product title. */ + public title: string; + + /** Product brands. */ + public brands: string[]; + + /** Product description. */ + public description: string; + + /** Product languageCode. */ + public languageCode: string; + + /** Product attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2.ICustomAttribute }; + + /** Product tags. */ + public tags: string[]; + + /** Product priceInfo. */ + public priceInfo?: (google.cloud.retail.v2.IPriceInfo|null); + + /** Product rating. */ + public rating?: (google.cloud.retail.v2.IRating|null); + + /** Product availableTime. */ + public availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability. */ + public availability: (google.cloud.retail.v2.Product.Availability|keyof typeof google.cloud.retail.v2.Product.Availability); + + /** Product availableQuantity. */ + public availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo. */ + public fulfillmentInfo: google.cloud.retail.v2.IFulfillmentInfo[]; + + /** Product uri. */ + public uri: string; + + /** Product images. */ + public images: google.cloud.retail.v2.IImage[]; + + /** Product audience. */ + public audience?: (google.cloud.retail.v2.IAudience|null); + + /** Product colorInfo. */ + public colorInfo?: (google.cloud.retail.v2.IColorInfo|null); + + /** Product sizes. */ + public sizes: string[]; + + /** Product materials. */ + public materials: string[]; + + /** Product patterns. */ + public patterns: string[]; + + /** Product conditions. */ + public conditions: string[]; + + /** Product promotions. */ + public promotions: google.cloud.retail.v2.IPromotion[]; + + /** Product publishTime. */ + public publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields. */ + public retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants. */ + public variants: google.cloud.retail.v2.IProduct[]; + + /** Product localInventories. */ + public localInventories: google.cloud.retail.v2.ILocalInventory[]; + + /** Product expiration. */ + public expiration?: ("expireTime"|"ttl"); + + /** + * Creates a new Product instance using the specified properties. + * @param [properties] Properties to set + * @returns Product instance + */ + public static create(properties?: google.cloud.retail.v2.IProduct): google.cloud.retail.v2.Product; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Product message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Product + * @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.cloud.retail.v2.Product; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Product + * @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.cloud.retail.v2.Product; + + /** + * Verifies a Product 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 Product message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Product + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Product; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @param message Product + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Product, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Product to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Product + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Product { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + PRIMARY = 1, + VARIANT = 2, + COLLECTION = 3 + } + + /** Availability enum. */ + enum Availability { + AVAILABILITY_UNSPECIFIED = 0, + IN_STOCK = 1, + OUT_OF_STOCK = 2, + PREORDER = 3, + BACKORDER = 4 + } + } + + /** Properties of a Promotion. */ + interface IPromotion { + + /** Promotion promotionId */ + promotionId?: (string|null); + } + + /** Represents a Promotion. */ + class Promotion implements IPromotion { + + /** + * Constructs a new Promotion. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPromotion); + + /** Promotion promotionId. */ + public promotionId: string; + + /** + * Creates a new Promotion instance using the specified properties. + * @param [properties] Properties to set + * @returns Promotion instance + */ + public static create(properties?: google.cloud.retail.v2.IPromotion): google.cloud.retail.v2.Promotion; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Promotion + * @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.cloud.retail.v2.Promotion; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Promotion + * @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.cloud.retail.v2.Promotion; + + /** + * Verifies a Promotion 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 Promotion message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Promotion + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Promotion; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @param message Promotion + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Promotion, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Promotion to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Promotion + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEvent. */ + interface IUserEvent { + + /** UserEvent eventType */ + eventType?: (string|null); + + /** UserEvent visitorId */ + visitorId?: (string|null); + + /** UserEvent sessionId */ + sessionId?: (string|null); + + /** UserEvent eventTime */ + eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds */ + experimentIds?: (string[]|null); + + /** UserEvent attributionToken */ + attributionToken?: (string|null); + + /** UserEvent productDetails */ + productDetails?: (google.cloud.retail.v2.IProductDetail[]|null); + + /** UserEvent completionDetail */ + completionDetail?: (google.cloud.retail.v2.ICompletionDetail|null); + + /** UserEvent attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2.ICustomAttribute }|null); + + /** UserEvent cartId */ + cartId?: (string|null); + + /** UserEvent purchaseTransaction */ + purchaseTransaction?: (google.cloud.retail.v2.IPurchaseTransaction|null); + + /** UserEvent searchQuery */ + searchQuery?: (string|null); + + /** UserEvent filter */ + filter?: (string|null); + + /** UserEvent orderBy */ + orderBy?: (string|null); + + /** UserEvent offset */ + offset?: (number|null); + + /** UserEvent pageCategories */ + pageCategories?: (string[]|null); + + /** UserEvent userInfo */ + userInfo?: (google.cloud.retail.v2.IUserInfo|null); + + /** UserEvent uri */ + uri?: (string|null); + + /** UserEvent referrerUri */ + referrerUri?: (string|null); + + /** UserEvent pageViewId */ + pageViewId?: (string|null); + } + + /** Represents a UserEvent. */ + class UserEvent implements IUserEvent { + + /** + * Constructs a new UserEvent. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUserEvent); + + /** UserEvent eventType. */ + public eventType: string; + + /** UserEvent visitorId. */ + public visitorId: string; + + /** UserEvent sessionId. */ + public sessionId: string; + + /** UserEvent eventTime. */ + public eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds. */ + public experimentIds: string[]; + + /** UserEvent attributionToken. */ + public attributionToken: string; + + /** UserEvent productDetails. */ + public productDetails: google.cloud.retail.v2.IProductDetail[]; + + /** UserEvent completionDetail. */ + public completionDetail?: (google.cloud.retail.v2.ICompletionDetail|null); + + /** UserEvent attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2.ICustomAttribute }; + + /** UserEvent cartId. */ + public cartId: string; + + /** UserEvent purchaseTransaction. */ + public purchaseTransaction?: (google.cloud.retail.v2.IPurchaseTransaction|null); + + /** UserEvent searchQuery. */ + public searchQuery: string; + + /** UserEvent filter. */ + public filter: string; + + /** UserEvent orderBy. */ + public orderBy: string; + + /** UserEvent offset. */ + public offset: number; + + /** UserEvent pageCategories. */ + public pageCategories: string[]; + + /** UserEvent userInfo. */ + public userInfo?: (google.cloud.retail.v2.IUserInfo|null); + + /** UserEvent uri. */ + public uri: string; + + /** UserEvent referrerUri. */ + public referrerUri: string; + + /** UserEvent pageViewId. */ + public pageViewId: string; + + /** + * Creates a new UserEvent instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEvent instance + */ + public static create(properties?: google.cloud.retail.v2.IUserEvent): google.cloud.retail.v2.UserEvent; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEvent + * @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.cloud.retail.v2.UserEvent; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEvent + * @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.cloud.retail.v2.UserEvent; + + /** + * Verifies a UserEvent 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 UserEvent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEvent + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UserEvent; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @param message UserEvent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UserEvent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEvent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEvent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductDetail. */ + interface IProductDetail { + + /** ProductDetail product */ + product?: (google.cloud.retail.v2.IProduct|null); + + /** ProductDetail quantity */ + quantity?: (google.protobuf.IInt32Value|null); + } + + /** Represents a ProductDetail. */ + class ProductDetail implements IProductDetail { + + /** + * Constructs a new ProductDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IProductDetail); + + /** ProductDetail product. */ + public product?: (google.cloud.retail.v2.IProduct|null); + + /** ProductDetail quantity. */ + public quantity?: (google.protobuf.IInt32Value|null); + + /** + * Creates a new ProductDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductDetail instance + */ + public static create(properties?: google.cloud.retail.v2.IProductDetail): google.cloud.retail.v2.ProductDetail; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductDetail + * @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.cloud.retail.v2.ProductDetail; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductDetail + * @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.cloud.retail.v2.ProductDetail; + + /** + * Verifies a ProductDetail 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 ProductDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ProductDetail; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @param message ProductDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ProductDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDetail. */ + interface ICompletionDetail { + + /** CompletionDetail completionAttributionToken */ + completionAttributionToken?: (string|null); + + /** CompletionDetail selectedSuggestion */ + selectedSuggestion?: (string|null); + + /** CompletionDetail selectedPosition */ + selectedPosition?: (number|null); + } + + /** Represents a CompletionDetail. */ + class CompletionDetail implements ICompletionDetail { + + /** + * Constructs a new CompletionDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICompletionDetail); + + /** CompletionDetail completionAttributionToken. */ + public completionAttributionToken: string; + + /** CompletionDetail selectedSuggestion. */ + public selectedSuggestion: string; + + /** CompletionDetail selectedPosition. */ + public selectedPosition: number; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDetail instance + */ + public static create(properties?: google.cloud.retail.v2.ICompletionDetail): google.cloud.retail.v2.CompletionDetail; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDetail + * @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.cloud.retail.v2.CompletionDetail; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDetail + * @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.cloud.retail.v2.CompletionDetail; + + /** + * Verifies a CompletionDetail 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 CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompletionDetail; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @param message CompletionDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompletionDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurchaseTransaction. */ + interface IPurchaseTransaction { + + /** PurchaseTransaction id */ + id?: (string|null); + + /** PurchaseTransaction revenue */ + revenue?: (number|null); + + /** PurchaseTransaction tax */ + tax?: (number|null); + + /** PurchaseTransaction cost */ + cost?: (number|null); + + /** PurchaseTransaction currencyCode */ + currencyCode?: (string|null); + } + + /** Represents a PurchaseTransaction. */ + class PurchaseTransaction implements IPurchaseTransaction { + + /** + * Constructs a new PurchaseTransaction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPurchaseTransaction); + + /** PurchaseTransaction id. */ + public id: string; + + /** PurchaseTransaction revenue. */ + public revenue: number; + + /** PurchaseTransaction tax. */ + public tax: number; + + /** PurchaseTransaction cost. */ + public cost: number; + + /** PurchaseTransaction currencyCode. */ + public currencyCode: string; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @param [properties] Properties to set + * @returns PurchaseTransaction instance + */ + public static create(properties?: google.cloud.retail.v2.IPurchaseTransaction): google.cloud.retail.v2.PurchaseTransaction; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurchaseTransaction + * @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.cloud.retail.v2.PurchaseTransaction; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurchaseTransaction + * @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.cloud.retail.v2.PurchaseTransaction; + + /** + * Verifies a PurchaseTransaction 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 PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurchaseTransaction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PurchaseTransaction; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @param message PurchaseTransaction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PurchaseTransaction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurchaseTransaction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurchaseTransaction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CatalogService */ + class CatalogService extends $protobuf.rpc.Service { + + /** + * Constructs a new CatalogService 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 CatalogService 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): CatalogService; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCatalogsResponse + */ + public listCatalogs(request: google.cloud.retail.v2.IListCatalogsRequest, callback: google.cloud.retail.v2.CatalogService.ListCatalogsCallback): void; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @returns Promise + */ + public listCatalogs(request: google.cloud.retail.v2.IListCatalogsRequest): Promise; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Catalog + */ + public updateCatalog(request: google.cloud.retail.v2.IUpdateCatalogRequest, callback: google.cloud.retail.v2.CatalogService.UpdateCatalogCallback): void; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @returns Promise + */ + public updateCatalog(request: google.cloud.retail.v2.IUpdateCatalogRequest): Promise; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public setDefaultBranch(request: google.cloud.retail.v2.ISetDefaultBranchRequest, callback: google.cloud.retail.v2.CatalogService.SetDefaultBranchCallback): void; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @returns Promise + */ + public setDefaultBranch(request: google.cloud.retail.v2.ISetDefaultBranchRequest): Promise; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + */ + public getDefaultBranch(request: google.cloud.retail.v2.IGetDefaultBranchRequest, callback: google.cloud.retail.v2.CatalogService.GetDefaultBranchCallback): void; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @returns Promise + */ + public getDefaultBranch(request: google.cloud.retail.v2.IGetDefaultBranchRequest): Promise; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public getCompletionConfig(request: google.cloud.retail.v2.IGetCompletionConfigRequest, callback: google.cloud.retail.v2.CatalogService.GetCompletionConfigCallback): void; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @returns Promise + */ + public getCompletionConfig(request: google.cloud.retail.v2.IGetCompletionConfigRequest): Promise; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public updateCompletionConfig(request: google.cloud.retail.v2.IUpdateCompletionConfigRequest, callback: google.cloud.retail.v2.CatalogService.UpdateCompletionConfigCallback): void; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @returns Promise + */ + public updateCompletionConfig(request: google.cloud.retail.v2.IUpdateCompletionConfigRequest): Promise; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public getAttributesConfig(request: google.cloud.retail.v2.IGetAttributesConfigRequest, callback: google.cloud.retail.v2.CatalogService.GetAttributesConfigCallback): void; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @returns Promise + */ + public getAttributesConfig(request: google.cloud.retail.v2.IGetAttributesConfigRequest): Promise; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public updateAttributesConfig(request: google.cloud.retail.v2.IUpdateAttributesConfigRequest, callback: google.cloud.retail.v2.CatalogService.UpdateAttributesConfigCallback): void; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @returns Promise + */ + public updateAttributesConfig(request: google.cloud.retail.v2.IUpdateAttributesConfigRequest): Promise; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public addCatalogAttribute(request: google.cloud.retail.v2.IAddCatalogAttributeRequest, callback: google.cloud.retail.v2.CatalogService.AddCatalogAttributeCallback): void; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @returns Promise + */ + public addCatalogAttribute(request: google.cloud.retail.v2.IAddCatalogAttributeRequest): Promise; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public removeCatalogAttribute(request: google.cloud.retail.v2.IRemoveCatalogAttributeRequest, callback: google.cloud.retail.v2.CatalogService.RemoveCatalogAttributeCallback): void; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @returns Promise + */ + public removeCatalogAttribute(request: google.cloud.retail.v2.IRemoveCatalogAttributeRequest): Promise; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2.IReplaceCatalogAttributeRequest, callback: google.cloud.retail.v2.CatalogService.ReplaceCatalogAttributeCallback): void; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @returns Promise + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2.IReplaceCatalogAttributeRequest): Promise; + } + + namespace CatalogService { + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|listCatalogs}. + * @param error Error, if any + * @param [response] ListCatalogsResponse + */ + type ListCatalogsCallback = (error: (Error|null), response?: google.cloud.retail.v2.ListCatalogsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateCatalog}. + * @param error Error, if any + * @param [response] Catalog + */ + type UpdateCatalogCallback = (error: (Error|null), response?: google.cloud.retail.v2.Catalog) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|setDefaultBranch}. + * @param error Error, if any + * @param [response] Empty + */ + type SetDefaultBranchCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getDefaultBranch}. + * @param error Error, if any + * @param [response] GetDefaultBranchResponse + */ + type GetDefaultBranchCallback = (error: (Error|null), response?: google.cloud.retail.v2.GetDefaultBranchResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type GetCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type UpdateCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type GetAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type UpdateAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|addCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type AddCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|removeCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type RemoveCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|replaceCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type ReplaceCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2.AttributesConfig) => void; + } + + /** Properties of a ListCatalogsRequest. */ + interface IListCatalogsRequest { + + /** ListCatalogsRequest parent */ + parent?: (string|null); + + /** ListCatalogsRequest pageSize */ + pageSize?: (number|null); + + /** ListCatalogsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCatalogsRequest. */ + class ListCatalogsRequest implements IListCatalogsRequest { + + /** + * Constructs a new ListCatalogsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListCatalogsRequest); + + /** ListCatalogsRequest parent. */ + public parent: string; + + /** ListCatalogsRequest pageSize. */ + public pageSize: number; + + /** ListCatalogsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IListCatalogsRequest): google.cloud.retail.v2.ListCatalogsRequest; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsRequest + * @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.cloud.retail.v2.ListCatalogsRequest; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsRequest + * @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.cloud.retail.v2.ListCatalogsRequest; + + /** + * Verifies a ListCatalogsRequest 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListCatalogsRequest; + + /** + * Creates a plain object from a ListCatalogsRequest message. Also converts values to other types if specified. + * @param message ListCatalogsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListCatalogsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCatalogsResponse. */ + interface IListCatalogsResponse { + + /** ListCatalogsResponse catalogs */ + catalogs?: (google.cloud.retail.v2.ICatalog[]|null); + + /** ListCatalogsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCatalogsResponse. */ + class ListCatalogsResponse implements IListCatalogsResponse { + + /** + * Constructs a new ListCatalogsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListCatalogsResponse); + + /** ListCatalogsResponse catalogs. */ + public catalogs: google.cloud.retail.v2.ICatalog[]; + + /** ListCatalogsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IListCatalogsResponse): google.cloud.retail.v2.ListCatalogsResponse; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsResponse + * @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.cloud.retail.v2.ListCatalogsResponse; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsResponse + * @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.cloud.retail.v2.ListCatalogsResponse; + + /** + * Verifies a ListCatalogsResponse 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 ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListCatalogsResponse; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @param message ListCatalogsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListCatalogsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCatalogRequest. */ + interface IUpdateCatalogRequest { + + /** UpdateCatalogRequest catalog */ + catalog?: (google.cloud.retail.v2.ICatalog|null); + + /** UpdateCatalogRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCatalogRequest. */ + class UpdateCatalogRequest implements IUpdateCatalogRequest { + + /** + * Constructs a new UpdateCatalogRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateCatalogRequest); + + /** UpdateCatalogRequest catalog. */ + public catalog?: (google.cloud.retail.v2.ICatalog|null); + + /** UpdateCatalogRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCatalogRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateCatalogRequest): google.cloud.retail.v2.UpdateCatalogRequest; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2.UpdateCatalogRequest; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2.UpdateCatalogRequest; + + /** + * Verifies an UpdateCatalogRequest 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 UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCatalogRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateCatalogRequest; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @param message UpdateCatalogRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateCatalogRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetDefaultBranchRequest. */ + interface ISetDefaultBranchRequest { + + /** SetDefaultBranchRequest catalog */ + catalog?: (string|null); + + /** SetDefaultBranchRequest branchId */ + branchId?: (string|null); + + /** SetDefaultBranchRequest note */ + note?: (string|null); + + /** SetDefaultBranchRequest force */ + force?: (boolean|null); + } + + /** Represents a SetDefaultBranchRequest. */ + class SetDefaultBranchRequest implements ISetDefaultBranchRequest { + + /** + * Constructs a new SetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISetDefaultBranchRequest); + + /** SetDefaultBranchRequest catalog. */ + public catalog: string; + + /** SetDefaultBranchRequest branchId. */ + public branchId: string; + + /** SetDefaultBranchRequest note. */ + public note: string; + + /** SetDefaultBranchRequest force. */ + public force: boolean; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ISetDefaultBranchRequest): google.cloud.retail.v2.SetDefaultBranchRequest; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2.SetDefaultBranchRequest; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2.SetDefaultBranchRequest; + + /** + * Verifies a SetDefaultBranchRequest 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 SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SetDefaultBranchRequest; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message SetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchRequest. */ + interface IGetDefaultBranchRequest { + + /** GetDefaultBranchRequest catalog */ + catalog?: (string|null); + } + + /** Represents a GetDefaultBranchRequest. */ + class GetDefaultBranchRequest implements IGetDefaultBranchRequest { + + /** + * Constructs a new GetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetDefaultBranchRequest); + + /** GetDefaultBranchRequest catalog. */ + public catalog: string; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetDefaultBranchRequest): google.cloud.retail.v2.GetDefaultBranchRequest; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2.GetDefaultBranchRequest; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2.GetDefaultBranchRequest; + + /** + * Verifies a GetDefaultBranchRequest 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 GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetDefaultBranchRequest; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message GetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchResponse. */ + interface IGetDefaultBranchResponse { + + /** GetDefaultBranchResponse branch */ + branch?: (string|null); + + /** GetDefaultBranchResponse setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note */ + note?: (string|null); + } + + /** Represents a GetDefaultBranchResponse. */ + class GetDefaultBranchResponse implements IGetDefaultBranchResponse { + + /** + * Constructs a new GetDefaultBranchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetDefaultBranchResponse); + + /** GetDefaultBranchResponse branch. */ + public branch: string; + + /** GetDefaultBranchResponse setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note. */ + public note: string; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IGetDefaultBranchResponse): google.cloud.retail.v2.GetDefaultBranchResponse; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2.GetDefaultBranchResponse; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2.GetDefaultBranchResponse; + + /** + * Verifies a GetDefaultBranchResponse 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 GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetDefaultBranchResponse; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @param message GetDefaultBranchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetDefaultBranchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetCompletionConfigRequest. */ + interface IGetCompletionConfigRequest { + + /** GetCompletionConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetCompletionConfigRequest. */ + class GetCompletionConfigRequest implements IGetCompletionConfigRequest { + + /** + * Constructs a new GetCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetCompletionConfigRequest); + + /** GetCompletionConfigRequest name. */ + public name: string; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetCompletionConfigRequest): google.cloud.retail.v2.GetCompletionConfigRequest; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2.GetCompletionConfigRequest; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2.GetCompletionConfigRequest; + + /** + * Verifies a GetCompletionConfigRequest 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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetCompletionConfigRequest; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @param message GetCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCompletionConfigRequest. */ + interface IUpdateCompletionConfigRequest { + + /** UpdateCompletionConfigRequest completionConfig */ + completionConfig?: (google.cloud.retail.v2.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCompletionConfigRequest. */ + class UpdateCompletionConfigRequest implements IUpdateCompletionConfigRequest { + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateCompletionConfigRequest); + + /** UpdateCompletionConfigRequest completionConfig. */ + public completionConfig?: (google.cloud.retail.v2.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateCompletionConfigRequest): google.cloud.retail.v2.UpdateCompletionConfigRequest; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2.UpdateCompletionConfigRequest; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2.UpdateCompletionConfigRequest; + + /** + * Verifies an UpdateCompletionConfigRequest 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 UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateCompletionConfigRequest; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @param message UpdateCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetAttributesConfigRequest. */ + interface IGetAttributesConfigRequest { + + /** GetAttributesConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetAttributesConfigRequest. */ + class GetAttributesConfigRequest implements IGetAttributesConfigRequest { + + /** + * Constructs a new GetAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetAttributesConfigRequest); + + /** GetAttributesConfigRequest name. */ + public name: string; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetAttributesConfigRequest): google.cloud.retail.v2.GetAttributesConfigRequest; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2.GetAttributesConfigRequest; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2.GetAttributesConfigRequest; + + /** + * Verifies a GetAttributesConfigRequest 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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetAttributesConfigRequest; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @param message GetAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateAttributesConfigRequest. */ + interface IUpdateAttributesConfigRequest { + + /** UpdateAttributesConfigRequest attributesConfig */ + attributesConfig?: (google.cloud.retail.v2.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateAttributesConfigRequest. */ + class UpdateAttributesConfigRequest implements IUpdateAttributesConfigRequest { + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateAttributesConfigRequest); + + /** UpdateAttributesConfigRequest attributesConfig. */ + public attributesConfig?: (google.cloud.retail.v2.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateAttributesConfigRequest): google.cloud.retail.v2.UpdateAttributesConfigRequest; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2.UpdateAttributesConfigRequest; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2.UpdateAttributesConfigRequest; + + /** + * Verifies an UpdateAttributesConfigRequest 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 UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateAttributesConfigRequest; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @param message UpdateAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddCatalogAttributeRequest. */ + interface IAddCatalogAttributeRequest { + + /** AddCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** AddCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2.ICatalogAttribute|null); + } + + /** Represents an AddCatalogAttributeRequest. */ + class AddCatalogAttributeRequest implements IAddCatalogAttributeRequest { + + /** + * Constructs a new AddCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddCatalogAttributeRequest); + + /** AddCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** AddCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2.ICatalogAttribute|null); + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IAddCatalogAttributeRequest): google.cloud.retail.v2.AddCatalogAttributeRequest; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2.AddCatalogAttributeRequest; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2.AddCatalogAttributeRequest; + + /** + * Verifies an AddCatalogAttributeRequest 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 AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddCatalogAttributeRequest; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message AddCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveCatalogAttributeRequest. */ + interface IRemoveCatalogAttributeRequest { + + /** RemoveCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** RemoveCatalogAttributeRequest key */ + key?: (string|null); + } + + /** Represents a RemoveCatalogAttributeRequest. */ + class RemoveCatalogAttributeRequest implements IRemoveCatalogAttributeRequest { + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveCatalogAttributeRequest); + + /** RemoveCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** RemoveCatalogAttributeRequest key. */ + public key: string; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveCatalogAttributeRequest): google.cloud.retail.v2.RemoveCatalogAttributeRequest; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2.RemoveCatalogAttributeRequest; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2.RemoveCatalogAttributeRequest; + + /** + * Verifies a RemoveCatalogAttributeRequest 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 RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveCatalogAttributeRequest; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message RemoveCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplaceCatalogAttributeRequest. */ + interface IReplaceCatalogAttributeRequest { + + /** ReplaceCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** ReplaceCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a ReplaceCatalogAttributeRequest. */ + class ReplaceCatalogAttributeRequest implements IReplaceCatalogAttributeRequest { + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IReplaceCatalogAttributeRequest); + + /** ReplaceCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** ReplaceCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplaceCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IReplaceCatalogAttributeRequest): google.cloud.retail.v2.ReplaceCatalogAttributeRequest; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2.ReplaceCatalogAttributeRequest; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2.ReplaceCatalogAttributeRequest; + + /** + * Verifies a ReplaceCatalogAttributeRequest 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 ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplaceCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ReplaceCatalogAttributeRequest; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message ReplaceCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ReplaceCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CompletionService */ + class CompletionService extends $protobuf.rpc.Service { + + /** + * Constructs a new CompletionService 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 CompletionService 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): CompletionService; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompleteQueryResponse + */ + public completeQuery(request: google.cloud.retail.v2.ICompleteQueryRequest, callback: google.cloud.retail.v2.CompletionService.CompleteQueryCallback): void; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @returns Promise + */ + public completeQuery(request: google.cloud.retail.v2.ICompleteQueryRequest): Promise; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importCompletionData(request: google.cloud.retail.v2.IImportCompletionDataRequest, callback: google.cloud.retail.v2.CompletionService.ImportCompletionDataCallback): void; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @returns Promise + */ + public importCompletionData(request: google.cloud.retail.v2.IImportCompletionDataRequest): Promise; + } + + namespace CompletionService { + + /** + * Callback as used by {@link google.cloud.retail.v2.CompletionService|completeQuery}. + * @param error Error, if any + * @param [response] CompleteQueryResponse + */ + type CompleteQueryCallback = (error: (Error|null), response?: google.cloud.retail.v2.CompleteQueryResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.CompletionService|importCompletionData}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportCompletionDataCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CompleteQueryRequest. */ + interface ICompleteQueryRequest { + + /** CompleteQueryRequest catalog */ + catalog?: (string|null); + + /** CompleteQueryRequest query */ + query?: (string|null); + + /** CompleteQueryRequest visitorId */ + visitorId?: (string|null); + + /** CompleteQueryRequest languageCodes */ + languageCodes?: (string[]|null); + + /** CompleteQueryRequest deviceType */ + deviceType?: (string|null); + + /** CompleteQueryRequest dataset */ + dataset?: (string|null); + + /** CompleteQueryRequest maxSuggestions */ + maxSuggestions?: (number|null); + } + + /** Represents a CompleteQueryRequest. */ + class CompleteQueryRequest implements ICompleteQueryRequest { + + /** + * Constructs a new CompleteQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICompleteQueryRequest); + + /** CompleteQueryRequest catalog. */ + public catalog: string; + + /** CompleteQueryRequest query. */ + public query: string; + + /** CompleteQueryRequest visitorId. */ + public visitorId: string; + + /** CompleteQueryRequest languageCodes. */ + public languageCodes: string[]; + + /** CompleteQueryRequest deviceType. */ + public deviceType: string; + + /** CompleteQueryRequest dataset. */ + public dataset: string; + + /** CompleteQueryRequest maxSuggestions. */ + public maxSuggestions: number; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ICompleteQueryRequest): google.cloud.retail.v2.CompleteQueryRequest; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryRequest + * @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.cloud.retail.v2.CompleteQueryRequest; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryRequest + * @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.cloud.retail.v2.CompleteQueryRequest; + + /** + * Verifies a CompleteQueryRequest 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 CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompleteQueryRequest; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @param message CompleteQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompleteQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompleteQueryResponse. */ + interface ICompleteQueryResponse { + + /** CompleteQueryResponse completionResults */ + completionResults?: (google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult[]|null); + + /** CompleteQueryResponse attributionToken */ + attributionToken?: (string|null); + + /** CompleteQueryResponse recentSearchResults */ + recentSearchResults?: (google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult[]|null); + } + + /** Represents a CompleteQueryResponse. */ + class CompleteQueryResponse implements ICompleteQueryResponse { + + /** + * Constructs a new CompleteQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICompleteQueryResponse); + + /** CompleteQueryResponse completionResults. */ + public completionResults: google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult[]; + + /** CompleteQueryResponse attributionToken. */ + public attributionToken: string; + + /** CompleteQueryResponse recentSearchResults. */ + public recentSearchResults: google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult[]; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryResponse instance + */ + public static create(properties?: google.cloud.retail.v2.ICompleteQueryResponse): google.cloud.retail.v2.CompleteQueryResponse; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryResponse + * @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.cloud.retail.v2.CompleteQueryResponse; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryResponse + * @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.cloud.retail.v2.CompleteQueryResponse; + + /** + * Verifies a CompleteQueryResponse 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 CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompleteQueryResponse; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @param message CompleteQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompleteQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CompleteQueryResponse { + + /** Properties of a CompletionResult. */ + interface ICompletionResult { + + /** CompletionResult suggestion */ + suggestion?: (string|null); + + /** CompletionResult attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2.ICustomAttribute }|null); + } + + /** Represents a CompletionResult. */ + class CompletionResult implements ICompletionResult { + + /** + * Constructs a new CompletionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult); + + /** CompletionResult suggestion. */ + public suggestion: string; + + /** CompletionResult attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2.ICustomAttribute }; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionResult instance + */ + public static create(properties?: google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult): google.cloud.retail.v2.CompleteQueryResponse.CompletionResult; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionResult + * @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.cloud.retail.v2.CompleteQueryResponse.CompletionResult; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionResult + * @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.cloud.retail.v2.CompleteQueryResponse.CompletionResult; + + /** + * Verifies a CompletionResult 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 CompletionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompleteQueryResponse.CompletionResult; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @param message CompletionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompleteQueryResponse.CompletionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecentSearchResult. */ + interface IRecentSearchResult { + + /** RecentSearchResult recentSearch */ + recentSearch?: (string|null); + } + + /** Represents a RecentSearchResult. */ + class RecentSearchResult implements IRecentSearchResult { + + /** + * Constructs a new RecentSearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult); + + /** RecentSearchResult recentSearch. */ + public recentSearch: string; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentSearchResult instance + */ + public static create(properties?: google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult): google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentSearchResult + * @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.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentSearchResult + * @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.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult; + + /** + * Verifies a RecentSearchResult 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 RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentSearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @param message RecentSearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentSearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecentSearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Control. */ + interface IControl { + + /** Control rule */ + rule?: (google.cloud.retail.v2.IRule|null); + + /** Control name */ + name?: (string|null); + + /** Control displayName */ + displayName?: (string|null); + + /** Control associatedServingConfigIds */ + associatedServingConfigIds?: (string[]|null); + + /** Control solutionTypes */ + solutionTypes?: (google.cloud.retail.v2.SolutionType[]|null); + + /** Control searchSolutionUseCase */ + searchSolutionUseCase?: (google.cloud.retail.v2.SearchSolutionUseCase[]|null); + } + + /** Represents a Control. */ + class Control implements IControl { + + /** + * Constructs a new Control. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IControl); + + /** Control rule. */ + public rule?: (google.cloud.retail.v2.IRule|null); + + /** Control name. */ + public name: string; + + /** Control displayName. */ + public displayName: string; + + /** Control associatedServingConfigIds. */ + public associatedServingConfigIds: string[]; + + /** Control solutionTypes. */ + public solutionTypes: google.cloud.retail.v2.SolutionType[]; + + /** Control searchSolutionUseCase. */ + public searchSolutionUseCase: google.cloud.retail.v2.SearchSolutionUseCase[]; + + /** Control control. */ + public control?: "rule"; + + /** + * Creates a new Control instance using the specified properties. + * @param [properties] Properties to set + * @returns Control instance + */ + public static create(properties?: google.cloud.retail.v2.IControl): google.cloud.retail.v2.Control; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Control message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Control + * @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.cloud.retail.v2.Control; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Control + * @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.cloud.retail.v2.Control; + + /** + * Verifies a Control 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 Control message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Control + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.Control; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @param message Control + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.Control, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Control to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Control + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a ControlService */ + class ControlService extends $protobuf.rpc.Service { + + /** + * Constructs a new ControlService 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 ControlService 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): ControlService; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public createControl(request: google.cloud.retail.v2.ICreateControlRequest, callback: google.cloud.retail.v2.ControlService.CreateControlCallback): void; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @returns Promise + */ + public createControl(request: google.cloud.retail.v2.ICreateControlRequest): Promise; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteControl(request: google.cloud.retail.v2.IDeleteControlRequest, callback: google.cloud.retail.v2.ControlService.DeleteControlCallback): void; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @returns Promise + */ + public deleteControl(request: google.cloud.retail.v2.IDeleteControlRequest): Promise; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public updateControl(request: google.cloud.retail.v2.IUpdateControlRequest, callback: google.cloud.retail.v2.ControlService.UpdateControlCallback): void; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @returns Promise + */ + public updateControl(request: google.cloud.retail.v2.IUpdateControlRequest): Promise; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public getControl(request: google.cloud.retail.v2.IGetControlRequest, callback: google.cloud.retail.v2.ControlService.GetControlCallback): void; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @returns Promise + */ + public getControl(request: google.cloud.retail.v2.IGetControlRequest): Promise; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListControlsResponse + */ + public listControls(request: google.cloud.retail.v2.IListControlsRequest, callback: google.cloud.retail.v2.ControlService.ListControlsCallback): void; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @returns Promise + */ + public listControls(request: google.cloud.retail.v2.IListControlsRequest): Promise; + } + + namespace ControlService { + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|createControl}. + * @param error Error, if any + * @param [response] Control + */ + type CreateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|deleteControl}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteControlCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|updateControl}. + * @param error Error, if any + * @param [response] Control + */ + type UpdateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|getControl}. + * @param error Error, if any + * @param [response] Control + */ + type GetControlCallback = (error: (Error|null), response?: google.cloud.retail.v2.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|listControls}. + * @param error Error, if any + * @param [response] ListControlsResponse + */ + type ListControlsCallback = (error: (Error|null), response?: google.cloud.retail.v2.ListControlsResponse) => void; + } + + /** Properties of a CreateControlRequest. */ + interface ICreateControlRequest { + + /** CreateControlRequest parent */ + parent?: (string|null); + + /** CreateControlRequest control */ + control?: (google.cloud.retail.v2.IControl|null); + + /** CreateControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a CreateControlRequest. */ + class CreateControlRequest implements ICreateControlRequest { + + /** + * Constructs a new CreateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICreateControlRequest); + + /** CreateControlRequest parent. */ + public parent: string; + + /** CreateControlRequest control. */ + public control?: (google.cloud.retail.v2.IControl|null); + + /** CreateControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ICreateControlRequest): google.cloud.retail.v2.CreateControlRequest; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateControlRequest + * @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.cloud.retail.v2.CreateControlRequest; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateControlRequest + * @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.cloud.retail.v2.CreateControlRequest; + + /** + * Verifies a CreateControlRequest 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 CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CreateControlRequest; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @param message CreateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CreateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateControlRequest. */ + interface IUpdateControlRequest { + + /** UpdateControlRequest control */ + control?: (google.cloud.retail.v2.IControl|null); + + /** UpdateControlRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateControlRequest. */ + class UpdateControlRequest implements IUpdateControlRequest { + + /** + * Constructs a new UpdateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateControlRequest); + + /** UpdateControlRequest control. */ + public control?: (google.cloud.retail.v2.IControl|null); + + /** UpdateControlRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateControlRequest): google.cloud.retail.v2.UpdateControlRequest; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateControlRequest + * @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.cloud.retail.v2.UpdateControlRequest; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateControlRequest + * @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.cloud.retail.v2.UpdateControlRequest; + + /** + * Verifies an UpdateControlRequest 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 UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateControlRequest; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @param message UpdateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteControlRequest. */ + interface IDeleteControlRequest { + + /** DeleteControlRequest name */ + name?: (string|null); + } + + /** Represents a DeleteControlRequest. */ + class DeleteControlRequest implements IDeleteControlRequest { + + /** + * Constructs a new DeleteControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IDeleteControlRequest); + + /** DeleteControlRequest name. */ + public name: string; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IDeleteControlRequest): google.cloud.retail.v2.DeleteControlRequest; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteControlRequest + * @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.cloud.retail.v2.DeleteControlRequest; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteControlRequest + * @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.cloud.retail.v2.DeleteControlRequest; + + /** + * Verifies a DeleteControlRequest 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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.DeleteControlRequest; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @param message DeleteControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.DeleteControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetControlRequest. */ + interface IGetControlRequest { + + /** GetControlRequest name */ + name?: (string|null); + } + + /** Represents a GetControlRequest. */ + class GetControlRequest implements IGetControlRequest { + + /** + * Constructs a new GetControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetControlRequest); + + /** GetControlRequest name. */ + public name: string; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetControlRequest): google.cloud.retail.v2.GetControlRequest; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetControlRequest + * @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.cloud.retail.v2.GetControlRequest; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetControlRequest + * @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.cloud.retail.v2.GetControlRequest; + + /** + * Verifies a GetControlRequest 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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetControlRequest; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @param message GetControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsRequest. */ + interface IListControlsRequest { + + /** ListControlsRequest parent */ + parent?: (string|null); + + /** ListControlsRequest pageSize */ + pageSize?: (number|null); + + /** ListControlsRequest pageToken */ + pageToken?: (string|null); + + /** ListControlsRequest filter */ + filter?: (string|null); + } + + /** Represents a ListControlsRequest. */ + class ListControlsRequest implements IListControlsRequest { + + /** + * Constructs a new ListControlsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListControlsRequest); + + /** ListControlsRequest parent. */ + public parent: string; + + /** ListControlsRequest pageSize. */ + public pageSize: number; + + /** ListControlsRequest pageToken. */ + public pageToken: string; + + /** ListControlsRequest filter. */ + public filter: string; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IListControlsRequest): google.cloud.retail.v2.ListControlsRequest; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsRequest + * @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.cloud.retail.v2.ListControlsRequest; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsRequest + * @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.cloud.retail.v2.ListControlsRequest; + + /** + * Verifies a ListControlsRequest 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 ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListControlsRequest; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @param message ListControlsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListControlsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsResponse. */ + interface IListControlsResponse { + + /** ListControlsResponse controls */ + controls?: (google.cloud.retail.v2.IControl[]|null); + + /** ListControlsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListControlsResponse. */ + class ListControlsResponse implements IListControlsResponse { + + /** + * Constructs a new ListControlsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListControlsResponse); + + /** ListControlsResponse controls. */ + public controls: google.cloud.retail.v2.IControl[]; + + /** ListControlsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IListControlsResponse): google.cloud.retail.v2.ListControlsResponse; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsResponse + * @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.cloud.retail.v2.ListControlsResponse; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsResponse + * @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.cloud.retail.v2.ListControlsResponse; + + /** + * Verifies a ListControlsResponse 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 ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListControlsResponse; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @param message ListControlsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListControlsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a PredictionService */ + class PredictionService extends $protobuf.rpc.Service { + + /** + * Constructs a new PredictionService 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 PredictionService 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): PredictionService; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PredictResponse + */ + public predict(request: google.cloud.retail.v2.IPredictRequest, callback: google.cloud.retail.v2.PredictionService.PredictCallback): void; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @returns Promise + */ + public predict(request: google.cloud.retail.v2.IPredictRequest): Promise; + } + + namespace PredictionService { + + /** + * Callback as used by {@link google.cloud.retail.v2.PredictionService|predict}. + * @param error Error, if any + * @param [response] PredictResponse + */ + type PredictCallback = (error: (Error|null), response?: google.cloud.retail.v2.PredictResponse) => void; + } + + /** Properties of a PredictRequest. */ + interface IPredictRequest { + + /** PredictRequest placement */ + placement?: (string|null); + + /** PredictRequest userEvent */ + userEvent?: (google.cloud.retail.v2.IUserEvent|null); + + /** PredictRequest pageSize */ + pageSize?: (number|null); + + /** PredictRequest pageToken */ + pageToken?: (string|null); + + /** PredictRequest filter */ + filter?: (string|null); + + /** PredictRequest validateOnly */ + validateOnly?: (boolean|null); + + /** PredictRequest params */ + params?: ({ [k: string]: google.protobuf.IValue }|null); + + /** PredictRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a PredictRequest. */ + class PredictRequest implements IPredictRequest { + + /** + * Constructs a new PredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPredictRequest); + + /** PredictRequest placement. */ + public placement: string; + + /** PredictRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2.IUserEvent|null); + + /** PredictRequest pageSize. */ + public pageSize: number; + + /** PredictRequest pageToken. */ + public pageToken: string; + + /** PredictRequest filter. */ + public filter: string; + + /** PredictRequest validateOnly. */ + public validateOnly: boolean; + + /** PredictRequest params. */ + public params: { [k: string]: google.protobuf.IValue }; + + /** PredictRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IPredictRequest): google.cloud.retail.v2.PredictRequest; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictRequest + * @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.cloud.retail.v2.PredictRequest; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictRequest + * @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.cloud.retail.v2.PredictRequest; + + /** + * Verifies a PredictRequest 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 PredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PredictRequest; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @param message PredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PredictResponse. */ + interface IPredictResponse { + + /** PredictResponse results */ + results?: (google.cloud.retail.v2.PredictResponse.IPredictionResult[]|null); + + /** PredictResponse attributionToken */ + attributionToken?: (string|null); + + /** PredictResponse missingIds */ + missingIds?: (string[]|null); + + /** PredictResponse validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents a PredictResponse. */ + class PredictResponse implements IPredictResponse { + + /** + * Constructs a new PredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPredictResponse); + + /** PredictResponse results. */ + public results: google.cloud.retail.v2.PredictResponse.IPredictionResult[]; + + /** PredictResponse attributionToken. */ + public attributionToken: string; + + /** PredictResponse missingIds. */ + public missingIds: string[]; + + /** PredictResponse validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IPredictResponse): google.cloud.retail.v2.PredictResponse; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictResponse + * @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.cloud.retail.v2.PredictResponse; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictResponse + * @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.cloud.retail.v2.PredictResponse; + + /** + * Verifies a PredictResponse 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 PredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PredictResponse; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @param message PredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PredictResponse { + + /** Properties of a PredictionResult. */ + interface IPredictionResult { + + /** PredictionResult id */ + id?: (string|null); + + /** PredictionResult metadata */ + metadata?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a PredictionResult. */ + class PredictionResult implements IPredictionResult { + + /** + * Constructs a new PredictionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.PredictResponse.IPredictionResult); + + /** PredictionResult id. */ + public id: string; + + /** PredictionResult metadata. */ + public metadata: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictionResult instance + */ + public static create(properties?: google.cloud.retail.v2.PredictResponse.IPredictionResult): google.cloud.retail.v2.PredictResponse.PredictionResult; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictionResult + * @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.cloud.retail.v2.PredictResponse.PredictionResult; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictionResult + * @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.cloud.retail.v2.PredictResponse.PredictionResult; + + /** + * Verifies a PredictionResult 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 PredictionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PredictResponse.PredictionResult; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @param message PredictionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PredictResponse.PredictionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Represents a ProductService */ + class ProductService extends $protobuf.rpc.Service { + + /** + * Constructs a new ProductService 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 ProductService 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): ProductService; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public createProduct(request: google.cloud.retail.v2.ICreateProductRequest, callback: google.cloud.retail.v2.ProductService.CreateProductCallback): void; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @returns Promise + */ + public createProduct(request: google.cloud.retail.v2.ICreateProductRequest): Promise; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public getProduct(request: google.cloud.retail.v2.IGetProductRequest, callback: google.cloud.retail.v2.ProductService.GetProductCallback): void; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @returns Promise + */ + public getProduct(request: google.cloud.retail.v2.IGetProductRequest): Promise; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListProductsResponse + */ + public listProducts(request: google.cloud.retail.v2.IListProductsRequest, callback: google.cloud.retail.v2.ProductService.ListProductsCallback): void; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @returns Promise + */ + public listProducts(request: google.cloud.retail.v2.IListProductsRequest): Promise; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public updateProduct(request: google.cloud.retail.v2.IUpdateProductRequest, callback: google.cloud.retail.v2.ProductService.UpdateProductCallback): void; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @returns Promise + */ + public updateProduct(request: google.cloud.retail.v2.IUpdateProductRequest): Promise; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteProduct(request: google.cloud.retail.v2.IDeleteProductRequest, callback: google.cloud.retail.v2.ProductService.DeleteProductCallback): void; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @returns Promise + */ + public deleteProduct(request: google.cloud.retail.v2.IDeleteProductRequest): Promise; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importProducts(request: google.cloud.retail.v2.IImportProductsRequest, callback: google.cloud.retail.v2.ProductService.ImportProductsCallback): void; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @returns Promise + */ + public importProducts(request: google.cloud.retail.v2.IImportProductsRequest): Promise; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public setInventory(request: google.cloud.retail.v2.ISetInventoryRequest, callback: google.cloud.retail.v2.ProductService.SetInventoryCallback): void; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @returns Promise + */ + public setInventory(request: google.cloud.retail.v2.ISetInventoryRequest): Promise; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2.IAddFulfillmentPlacesRequest, callback: google.cloud.retail.v2.ProductService.AddFulfillmentPlacesCallback): void; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2.IAddFulfillmentPlacesRequest): Promise; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, callback: google.cloud.retail.v2.ProductService.RemoveFulfillmentPlacesCallback): void; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest): Promise; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addLocalInventories(request: google.cloud.retail.v2.IAddLocalInventoriesRequest, callback: google.cloud.retail.v2.ProductService.AddLocalInventoriesCallback): void; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @returns Promise + */ + public addLocalInventories(request: google.cloud.retail.v2.IAddLocalInventoriesRequest): Promise; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeLocalInventories(request: google.cloud.retail.v2.IRemoveLocalInventoriesRequest, callback: google.cloud.retail.v2.ProductService.RemoveLocalInventoriesCallback): void; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @returns Promise + */ + public removeLocalInventories(request: google.cloud.retail.v2.IRemoveLocalInventoriesRequest): Promise; + } + + namespace ProductService { + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|createProduct}. + * @param error Error, if any + * @param [response] Product + */ + type CreateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|getProduct}. + * @param error Error, if any + * @param [response] Product + */ + type GetProductCallback = (error: (Error|null), response?: google.cloud.retail.v2.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|listProducts}. + * @param error Error, if any + * @param [response] ListProductsResponse + */ + type ListProductsCallback = (error: (Error|null), response?: google.cloud.retail.v2.ListProductsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|updateProduct}. + * @param error Error, if any + * @param [response] Product + */ + type UpdateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|deleteProduct}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteProductCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|importProducts}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportProductsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|setInventory}. + * @param error Error, if any + * @param [response] Operation + */ + type SetInventoryCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|addFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type AddFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|removeFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|addLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type AddLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|removeLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateProductRequest. */ + interface ICreateProductRequest { + + /** CreateProductRequest parent */ + parent?: (string|null); + + /** CreateProductRequest product */ + product?: (google.cloud.retail.v2.IProduct|null); + + /** CreateProductRequest productId */ + productId?: (string|null); + } + + /** Represents a CreateProductRequest. */ + class CreateProductRequest implements ICreateProductRequest { + + /** + * Constructs a new CreateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICreateProductRequest); + + /** CreateProductRequest parent. */ + public parent: string; + + /** CreateProductRequest product. */ + public product?: (google.cloud.retail.v2.IProduct|null); + + /** CreateProductRequest productId. */ + public productId: string; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ICreateProductRequest): google.cloud.retail.v2.CreateProductRequest; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateProductRequest + * @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.cloud.retail.v2.CreateProductRequest; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateProductRequest + * @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.cloud.retail.v2.CreateProductRequest; + + /** + * Verifies a CreateProductRequest 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 CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CreateProductRequest; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @param message CreateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CreateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetProductRequest. */ + interface IGetProductRequest { + + /** GetProductRequest name */ + name?: (string|null); + } + + /** Represents a GetProductRequest. */ + class GetProductRequest implements IGetProductRequest { + + /** + * Constructs a new GetProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetProductRequest); + + /** GetProductRequest name. */ + public name: string; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetProductRequest): google.cloud.retail.v2.GetProductRequest; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetProductRequest + * @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.cloud.retail.v2.GetProductRequest; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetProductRequest + * @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.cloud.retail.v2.GetProductRequest; + + /** + * Verifies a GetProductRequest 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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetProductRequest; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @param message GetProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateProductRequest. */ + interface IUpdateProductRequest { + + /** UpdateProductRequest product */ + product?: (google.cloud.retail.v2.IProduct|null); + + /** UpdateProductRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an UpdateProductRequest. */ + class UpdateProductRequest implements IUpdateProductRequest { + + /** + * Constructs a new UpdateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateProductRequest); + + /** UpdateProductRequest product. */ + public product?: (google.cloud.retail.v2.IProduct|null); + + /** UpdateProductRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateProductRequest): google.cloud.retail.v2.UpdateProductRequest; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateProductRequest + * @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.cloud.retail.v2.UpdateProductRequest; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateProductRequest + * @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.cloud.retail.v2.UpdateProductRequest; + + /** + * Verifies an UpdateProductRequest 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 UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateProductRequest; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @param message UpdateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteProductRequest. */ + interface IDeleteProductRequest { + + /** DeleteProductRequest name */ + name?: (string|null); + } + + /** Represents a DeleteProductRequest. */ + class DeleteProductRequest implements IDeleteProductRequest { + + /** + * Constructs a new DeleteProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IDeleteProductRequest); + + /** DeleteProductRequest name. */ + public name: string; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IDeleteProductRequest): google.cloud.retail.v2.DeleteProductRequest; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteProductRequest + * @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.cloud.retail.v2.DeleteProductRequest; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteProductRequest + * @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.cloud.retail.v2.DeleteProductRequest; + + /** + * Verifies a DeleteProductRequest 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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.DeleteProductRequest; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @param message DeleteProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.DeleteProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsRequest. */ + interface IListProductsRequest { + + /** ListProductsRequest parent */ + parent?: (string|null); + + /** ListProductsRequest pageSize */ + pageSize?: (number|null); + + /** ListProductsRequest pageToken */ + pageToken?: (string|null); + + /** ListProductsRequest filter */ + filter?: (string|null); + + /** ListProductsRequest readMask */ + readMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a ListProductsRequest. */ + class ListProductsRequest implements IListProductsRequest { + + /** + * Constructs a new ListProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListProductsRequest); + + /** ListProductsRequest parent. */ + public parent: string; + + /** ListProductsRequest pageSize. */ + public pageSize: number; + + /** ListProductsRequest pageToken. */ + public pageToken: string; + + /** ListProductsRequest filter. */ + public filter: string; + + /** ListProductsRequest readMask. */ + public readMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IListProductsRequest): google.cloud.retail.v2.ListProductsRequest; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsRequest + * @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.cloud.retail.v2.ListProductsRequest; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsRequest + * @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.cloud.retail.v2.ListProductsRequest; + + /** + * Verifies a ListProductsRequest 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 ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListProductsRequest; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @param message ListProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsResponse. */ + interface IListProductsResponse { + + /** ListProductsResponse products */ + products?: (google.cloud.retail.v2.IProduct[]|null); + + /** ListProductsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListProductsResponse. */ + class ListProductsResponse implements IListProductsResponse { + + /** + * Constructs a new ListProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListProductsResponse); + + /** ListProductsResponse products. */ + public products: google.cloud.retail.v2.IProduct[]; + + /** ListProductsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IListProductsResponse): google.cloud.retail.v2.ListProductsResponse; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsResponse + * @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.cloud.retail.v2.ListProductsResponse; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsResponse + * @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.cloud.retail.v2.ListProductsResponse; + + /** + * Verifies a ListProductsResponse 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 ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListProductsResponse; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @param message ListProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryRequest. */ + interface ISetInventoryRequest { + + /** SetInventoryRequest inventory */ + inventory?: (google.cloud.retail.v2.IProduct|null); + + /** SetInventoryRequest setMask */ + setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a SetInventoryRequest. */ + class SetInventoryRequest implements ISetInventoryRequest { + + /** + * Constructs a new SetInventoryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISetInventoryRequest); + + /** SetInventoryRequest inventory. */ + public inventory?: (google.cloud.retail.v2.IProduct|null); + + /** SetInventoryRequest setMask. */ + public setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ISetInventoryRequest): google.cloud.retail.v2.SetInventoryRequest; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryRequest + * @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.cloud.retail.v2.SetInventoryRequest; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryRequest + * @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.cloud.retail.v2.SetInventoryRequest; + + /** + * Verifies a SetInventoryRequest 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 SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SetInventoryRequest; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @param message SetInventoryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SetInventoryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryMetadata. */ + interface ISetInventoryMetadata { + } + + /** Represents a SetInventoryMetadata. */ + class SetInventoryMetadata implements ISetInventoryMetadata { + + /** + * Constructs a new SetInventoryMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISetInventoryMetadata); + + /** + * Creates a new SetInventoryMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.ISetInventoryMetadata): google.cloud.retail.v2.SetInventoryMetadata; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryMetadata + * @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.cloud.retail.v2.SetInventoryMetadata; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryMetadata + * @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.cloud.retail.v2.SetInventoryMetadata; + + /** + * Verifies a SetInventoryMetadata 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 SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SetInventoryMetadata; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @param message SetInventoryMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SetInventoryMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryResponse. */ + interface ISetInventoryResponse { + } + + /** Represents a SetInventoryResponse. */ + class SetInventoryResponse implements ISetInventoryResponse { + + /** + * Constructs a new SetInventoryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISetInventoryResponse); + + /** + * Creates a new SetInventoryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryResponse instance + */ + public static create(properties?: google.cloud.retail.v2.ISetInventoryResponse): google.cloud.retail.v2.SetInventoryResponse; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryResponse + * @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.cloud.retail.v2.SetInventoryResponse; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryResponse + * @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.cloud.retail.v2.SetInventoryResponse; + + /** + * Verifies a SetInventoryResponse 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 SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SetInventoryResponse; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @param message SetInventoryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SetInventoryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesRequest. */ + interface IAddFulfillmentPlacesRequest { + + /** AddFulfillmentPlacesRequest product */ + product?: (string|null); + + /** AddFulfillmentPlacesRequest type */ + type?: (string|null); + + /** AddFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** AddFulfillmentPlacesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddFulfillmentPlacesRequest. */ + class AddFulfillmentPlacesRequest implements IAddFulfillmentPlacesRequest { + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesRequest); + + /** AddFulfillmentPlacesRequest product. */ + public product: string; + + /** AddFulfillmentPlacesRequest type. */ + public type: string; + + /** AddFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** AddFulfillmentPlacesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesRequest): google.cloud.retail.v2.AddFulfillmentPlacesRequest; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2.AddFulfillmentPlacesRequest; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2.AddFulfillmentPlacesRequest; + + /** + * Verifies an AddFulfillmentPlacesRequest 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 AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddFulfillmentPlacesRequest; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesMetadata. */ + interface IAddFulfillmentPlacesMetadata { + } + + /** Represents an AddFulfillmentPlacesMetadata. */ + class AddFulfillmentPlacesMetadata implements IAddFulfillmentPlacesMetadata { + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesMetadata); + + /** + * Creates a new AddFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesMetadata): google.cloud.retail.v2.AddFulfillmentPlacesMetadata; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2.AddFulfillmentPlacesMetadata; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2.AddFulfillmentPlacesMetadata; + + /** + * Verifies an AddFulfillmentPlacesMetadata 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 AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddFulfillmentPlacesMetadata; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesResponse. */ + interface IAddFulfillmentPlacesResponse { + } + + /** Represents an AddFulfillmentPlacesResponse. */ + class AddFulfillmentPlacesResponse implements IAddFulfillmentPlacesResponse { + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesResponse); + + /** + * Creates a new AddFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IAddFulfillmentPlacesResponse): google.cloud.retail.v2.AddFulfillmentPlacesResponse; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2.AddFulfillmentPlacesResponse; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2.AddFulfillmentPlacesResponse; + + /** + * Verifies an AddFulfillmentPlacesResponse 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 AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddFulfillmentPlacesResponse; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesRequest. */ + interface IAddLocalInventoriesRequest { + + /** AddLocalInventoriesRequest product */ + product?: (string|null); + + /** AddLocalInventoriesRequest localInventories */ + localInventories?: (google.cloud.retail.v2.ILocalInventory[]|null); + + /** AddLocalInventoriesRequest addMask */ + addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddLocalInventoriesRequest. */ + class AddLocalInventoriesRequest implements IAddLocalInventoriesRequest { + + /** + * Constructs a new AddLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddLocalInventoriesRequest); + + /** AddLocalInventoriesRequest product. */ + public product: string; + + /** AddLocalInventoriesRequest localInventories. */ + public localInventories: google.cloud.retail.v2.ILocalInventory[]; + + /** AddLocalInventoriesRequest addMask. */ + public addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IAddLocalInventoriesRequest): google.cloud.retail.v2.AddLocalInventoriesRequest; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2.AddLocalInventoriesRequest; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2.AddLocalInventoriesRequest; + + /** + * Verifies an AddLocalInventoriesRequest 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 AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddLocalInventoriesRequest; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message AddLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesMetadata. */ + interface IAddLocalInventoriesMetadata { + } + + /** Represents an AddLocalInventoriesMetadata. */ + class AddLocalInventoriesMetadata implements IAddLocalInventoriesMetadata { + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddLocalInventoriesMetadata); + + /** + * Creates a new AddLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IAddLocalInventoriesMetadata): google.cloud.retail.v2.AddLocalInventoriesMetadata; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2.AddLocalInventoriesMetadata; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2.AddLocalInventoriesMetadata; + + /** + * Verifies an AddLocalInventoriesMetadata 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 AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddLocalInventoriesMetadata; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message AddLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesResponse. */ + interface IAddLocalInventoriesResponse { + } + + /** Represents an AddLocalInventoriesResponse. */ + class AddLocalInventoriesResponse implements IAddLocalInventoriesResponse { + + /** + * Constructs a new AddLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddLocalInventoriesResponse); + + /** + * Creates a new AddLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IAddLocalInventoriesResponse): google.cloud.retail.v2.AddLocalInventoriesResponse; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2.AddLocalInventoriesResponse; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2.AddLocalInventoriesResponse; + + /** + * Verifies an AddLocalInventoriesResponse 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 AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddLocalInventoriesResponse; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message AddLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesRequest. */ + interface IRemoveLocalInventoriesRequest { + + /** RemoveLocalInventoriesRequest product */ + product?: (string|null); + + /** RemoveLocalInventoriesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveLocalInventoriesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveLocalInventoriesRequest. */ + class RemoveLocalInventoriesRequest implements IRemoveLocalInventoriesRequest { + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesRequest); + + /** RemoveLocalInventoriesRequest product. */ + public product: string; + + /** RemoveLocalInventoriesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveLocalInventoriesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesRequest): google.cloud.retail.v2.RemoveLocalInventoriesRequest; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2.RemoveLocalInventoriesRequest; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2.RemoveLocalInventoriesRequest; + + /** + * Verifies a RemoveLocalInventoriesRequest 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 RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveLocalInventoriesRequest; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesMetadata. */ + interface IRemoveLocalInventoriesMetadata { + } + + /** Represents a RemoveLocalInventoriesMetadata. */ + class RemoveLocalInventoriesMetadata implements IRemoveLocalInventoriesMetadata { + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesMetadata); + + /** + * Creates a new RemoveLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesMetadata): google.cloud.retail.v2.RemoveLocalInventoriesMetadata; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2.RemoveLocalInventoriesMetadata; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2.RemoveLocalInventoriesMetadata; + + /** + * Verifies a RemoveLocalInventoriesMetadata 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 RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveLocalInventoriesMetadata; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesResponse. */ + interface IRemoveLocalInventoriesResponse { + } + + /** Represents a RemoveLocalInventoriesResponse. */ + class RemoveLocalInventoriesResponse implements IRemoveLocalInventoriesResponse { + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesResponse); + + /** + * Creates a new RemoveLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveLocalInventoriesResponse): google.cloud.retail.v2.RemoveLocalInventoriesResponse; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2.RemoveLocalInventoriesResponse; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2.RemoveLocalInventoriesResponse; + + /** + * Verifies a RemoveLocalInventoriesResponse 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 RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveLocalInventoriesResponse; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesRequest. */ + interface IRemoveFulfillmentPlacesRequest { + + /** RemoveFulfillmentPlacesRequest product */ + product?: (string|null); + + /** RemoveFulfillmentPlacesRequest type */ + type?: (string|null); + + /** RemoveFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveFulfillmentPlacesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveFulfillmentPlacesRequest. */ + class RemoveFulfillmentPlacesRequest implements IRemoveFulfillmentPlacesRequest { + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest); + + /** RemoveFulfillmentPlacesRequest product. */ + public product: string; + + /** RemoveFulfillmentPlacesRequest type. */ + public type: string; + + /** RemoveFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveFulfillmentPlacesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest): google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2.RemoveFulfillmentPlacesRequest; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2.RemoveFulfillmentPlacesRequest; + + /** + * Verifies a RemoveFulfillmentPlacesRequest 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 RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesMetadata. */ + interface IRemoveFulfillmentPlacesMetadata { + } + + /** Represents a RemoveFulfillmentPlacesMetadata. */ + class RemoveFulfillmentPlacesMetadata implements IRemoveFulfillmentPlacesMetadata { + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata); + + /** + * Creates a new RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata): google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata 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 RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesResponse. */ + interface IRemoveFulfillmentPlacesResponse { + } + + /** Represents a RemoveFulfillmentPlacesResponse. */ + class RemoveFulfillmentPlacesResponse implements IRemoveFulfillmentPlacesResponse { + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse); + + /** + * Creates a new RemoveFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse): google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + + /** + * Verifies a RemoveFulfillmentPlacesResponse 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 RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveFulfillmentPlacesResponse; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeMetadata. */ + interface IPurgeMetadata { + } + + /** Represents a PurgeMetadata. */ + class PurgeMetadata implements IPurgeMetadata { + + /** + * Constructs a new PurgeMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPurgeMetadata); + + /** + * Creates a new PurgeMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IPurgeMetadata): google.cloud.retail.v2.PurgeMetadata; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeMetadata + * @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.cloud.retail.v2.PurgeMetadata; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeMetadata + * @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.cloud.retail.v2.PurgeMetadata; + + /** + * Verifies a PurgeMetadata 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 PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PurgeMetadata; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @param message PurgeMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PurgeMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsRequest. */ + interface IPurgeUserEventsRequest { + + /** PurgeUserEventsRequest parent */ + parent?: (string|null); + + /** PurgeUserEventsRequest filter */ + filter?: (string|null); + + /** PurgeUserEventsRequest force */ + force?: (boolean|null); + } + + /** Represents a PurgeUserEventsRequest. */ + class PurgeUserEventsRequest implements IPurgeUserEventsRequest { + + /** + * Constructs a new PurgeUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPurgeUserEventsRequest); + + /** PurgeUserEventsRequest parent. */ + public parent: string; + + /** PurgeUserEventsRequest filter. */ + public filter: string; + + /** PurgeUserEventsRequest force. */ + public force: boolean; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IPurgeUserEventsRequest): google.cloud.retail.v2.PurgeUserEventsRequest; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2.PurgeUserEventsRequest; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2.PurgeUserEventsRequest; + + /** + * Verifies a PurgeUserEventsRequest 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 PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PurgeUserEventsRequest; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @param message PurgeUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PurgeUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsResponse. */ + interface IPurgeUserEventsResponse { + + /** PurgeUserEventsResponse purgedEventsCount */ + purgedEventsCount?: (number|Long|string|null); + } + + /** Represents a PurgeUserEventsResponse. */ + class PurgeUserEventsResponse implements IPurgeUserEventsResponse { + + /** + * Constructs a new PurgeUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IPurgeUserEventsResponse); + + /** PurgeUserEventsResponse purgedEventsCount. */ + public purgedEventsCount: (number|Long|string); + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IPurgeUserEventsResponse): google.cloud.retail.v2.PurgeUserEventsResponse; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2.PurgeUserEventsResponse; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2.PurgeUserEventsResponse; + + /** + * Verifies a PurgeUserEventsResponse 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 PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.PurgeUserEventsResponse; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @param message PurgeUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.PurgeUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a SearchService */ + class SearchService extends $protobuf.rpc.Service { + + /** + * Constructs a new SearchService 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 SearchService 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): SearchService; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SearchResponse + */ + public search(request: google.cloud.retail.v2.ISearchRequest, callback: google.cloud.retail.v2.SearchService.SearchCallback): void; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @returns Promise + */ + public search(request: google.cloud.retail.v2.ISearchRequest): Promise; + } + + namespace SearchService { + + /** + * Callback as used by {@link google.cloud.retail.v2.SearchService|search}. + * @param error Error, if any + * @param [response] SearchResponse + */ + type SearchCallback = (error: (Error|null), response?: google.cloud.retail.v2.SearchResponse) => void; + } + + /** Properties of a SearchRequest. */ + interface ISearchRequest { + + /** SearchRequest placement */ + placement?: (string|null); + + /** SearchRequest branch */ + branch?: (string|null); + + /** SearchRequest query */ + query?: (string|null); + + /** SearchRequest visitorId */ + visitorId?: (string|null); + + /** SearchRequest userInfo */ + userInfo?: (google.cloud.retail.v2.IUserInfo|null); + + /** SearchRequest pageSize */ + pageSize?: (number|null); + + /** SearchRequest pageToken */ + pageToken?: (string|null); + + /** SearchRequest offset */ + offset?: (number|null); + + /** SearchRequest filter */ + filter?: (string|null); + + /** SearchRequest canonicalFilter */ + canonicalFilter?: (string|null); + + /** SearchRequest orderBy */ + orderBy?: (string|null); + + /** SearchRequest facetSpecs */ + facetSpecs?: (google.cloud.retail.v2.SearchRequest.IFacetSpec[]|null); + + /** SearchRequest dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec */ + boostSpec?: (google.cloud.retail.v2.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec */ + queryExpansionSpec?: (google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest variantRollupKeys */ + variantRollupKeys?: (string[]|null); + + /** SearchRequest pageCategories */ + pageCategories?: (string[]|null); + + /** SearchRequest searchMode */ + searchMode?: (google.cloud.retail.v2.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2.SearchRequest.SearchMode|null); + + /** SearchRequest personalizationSpec */ + personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** SearchRequest spellCorrectionSpec */ + spellCorrectionSpec?: (google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null); + } + + /** Represents a SearchRequest. */ + class SearchRequest implements ISearchRequest { + + /** + * Constructs a new SearchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISearchRequest); + + /** SearchRequest placement. */ + public placement: string; + + /** SearchRequest branch. */ + public branch: string; + + /** SearchRequest query. */ + public query: string; + + /** SearchRequest visitorId. */ + public visitorId: string; + + /** SearchRequest userInfo. */ + public userInfo?: (google.cloud.retail.v2.IUserInfo|null); + + /** SearchRequest pageSize. */ + public pageSize: number; + + /** SearchRequest pageToken. */ + public pageToken: string; + + /** SearchRequest offset. */ + public offset: number; + + /** SearchRequest filter. */ + public filter: string; + + /** SearchRequest canonicalFilter. */ + public canonicalFilter: string; + + /** SearchRequest orderBy. */ + public orderBy: string; + + /** SearchRequest facetSpecs. */ + public facetSpecs: google.cloud.retail.v2.SearchRequest.IFacetSpec[]; + + /** SearchRequest dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec. */ + public boostSpec?: (google.cloud.retail.v2.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec. */ + public queryExpansionSpec?: (google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest variantRollupKeys. */ + public variantRollupKeys: string[]; + + /** SearchRequest pageCategories. */ + public pageCategories: string[]; + + /** SearchRequest searchMode. */ + public searchMode: (google.cloud.retail.v2.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2.SearchRequest.SearchMode); + + /** SearchRequest personalizationSpec. */ + public personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels. */ + public labels: { [k: string]: string }; + + /** SearchRequest spellCorrectionSpec. */ + public spellCorrectionSpec?: (google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null); + + /** SearchRequest _spellCorrectionSpec. */ + public _spellCorrectionSpec?: "spellCorrectionSpec"; + + /** + * Creates a new SearchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ISearchRequest): google.cloud.retail.v2.SearchRequest; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchRequest + * @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.cloud.retail.v2.SearchRequest; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchRequest + * @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.cloud.retail.v2.SearchRequest; + + /** + * Verifies a SearchRequest 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 SearchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @param message SearchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchRequest { + + /** Properties of a FacetSpec. */ + interface IFacetSpec { + + /** FacetSpec facetKey */ + facetKey?: (google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit */ + limit?: (number|null); + + /** FacetSpec excludedFilterKeys */ + excludedFilterKeys?: (string[]|null); + + /** FacetSpec enableDynamicPosition */ + enableDynamicPosition?: (boolean|null); + } + + /** Represents a FacetSpec. */ + class FacetSpec implements IFacetSpec { + + /** + * Constructs a new FacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.IFacetSpec); + + /** FacetSpec facetKey. */ + public facetKey?: (google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit. */ + public limit: number; + + /** FacetSpec excludedFilterKeys. */ + public excludedFilterKeys: string[]; + + /** FacetSpec enableDynamicPosition. */ + public enableDynamicPosition: boolean; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.IFacetSpec): google.cloud.retail.v2.SearchRequest.FacetSpec; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetSpec + * @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.cloud.retail.v2.SearchRequest.FacetSpec; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetSpec + * @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.cloud.retail.v2.SearchRequest.FacetSpec; + + /** + * Verifies a FacetSpec 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 FacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.FacetSpec; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @param message FacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.FacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FacetSpec { + + /** Properties of a FacetKey. */ + interface IFacetKey { + + /** FacetKey key */ + key?: (string|null); + + /** FacetKey intervals */ + intervals?: (google.cloud.retail.v2.IInterval[]|null); + + /** FacetKey restrictedValues */ + restrictedValues?: (string[]|null); + + /** FacetKey prefixes */ + prefixes?: (string[]|null); + + /** FacetKey contains */ + contains?: (string[]|null); + + /** FacetKey caseInsensitive */ + caseInsensitive?: (boolean|null); + + /** FacetKey orderBy */ + orderBy?: (string|null); + + /** FacetKey query */ + query?: (string|null); + + /** FacetKey returnMinMax */ + returnMinMax?: (boolean|null); + } + + /** Represents a FacetKey. */ + class FacetKey implements IFacetKey { + + /** + * Constructs a new FacetKey. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey); + + /** FacetKey key. */ + public key: string; + + /** FacetKey intervals. */ + public intervals: google.cloud.retail.v2.IInterval[]; + + /** FacetKey restrictedValues. */ + public restrictedValues: string[]; + + /** FacetKey prefixes. */ + public prefixes: string[]; + + /** FacetKey contains. */ + public contains: string[]; + + /** FacetKey caseInsensitive. */ + public caseInsensitive: boolean; + + /** FacetKey orderBy. */ + public orderBy: string; + + /** FacetKey query. */ + public query: string; + + /** FacetKey returnMinMax. */ + public returnMinMax: boolean; + + /** + * Creates a new FacetKey instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetKey instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey): google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetKey + * @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.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetKey + * @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.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey; + + /** + * Verifies a FacetKey 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 FacetKey message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetKey + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @param message FacetKey + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetKey to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetKey + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a DynamicFacetSpec. */ + interface IDynamicFacetSpec { + + /** DynamicFacetSpec mode */ + mode?: (google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode|null); + } + + /** Represents a DynamicFacetSpec. */ + class DynamicFacetSpec implements IDynamicFacetSpec { + + /** + * Constructs a new DynamicFacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec); + + /** DynamicFacetSpec mode. */ + public mode: (google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode); + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns DynamicFacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec): google.cloud.retail.v2.SearchRequest.DynamicFacetSpec; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DynamicFacetSpec + * @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.cloud.retail.v2.SearchRequest.DynamicFacetSpec; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DynamicFacetSpec + * @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.cloud.retail.v2.SearchRequest.DynamicFacetSpec; + + /** + * Verifies a DynamicFacetSpec 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 DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DynamicFacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.DynamicFacetSpec; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @param message DynamicFacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.DynamicFacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DynamicFacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DynamicFacetSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + DISABLED = 1, + ENABLED = 2 + } + } + + /** Properties of a BoostSpec. */ + interface IBoostSpec { + + /** BoostSpec conditionBoostSpecs */ + conditionBoostSpecs?: (google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + + /** BoostSpec skipBoostSpecValidation */ + skipBoostSpecValidation?: (boolean|null); + } + + /** Represents a BoostSpec. */ + class BoostSpec implements IBoostSpec { + + /** + * Constructs a new BoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.IBoostSpec); + + /** BoostSpec conditionBoostSpecs. */ + public conditionBoostSpecs: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** BoostSpec skipBoostSpecValidation. */ + public skipBoostSpecValidation?: (boolean|null); + + /** BoostSpec _skipBoostSpecValidation. */ + public _skipBoostSpecValidation?: "skipBoostSpecValidation"; + + /** + * Creates a new BoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.IBoostSpec): google.cloud.retail.v2.SearchRequest.BoostSpec; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostSpec + * @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.cloud.retail.v2.SearchRequest.BoostSpec; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostSpec + * @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.cloud.retail.v2.SearchRequest.BoostSpec; + + /** + * Verifies a BoostSpec 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 BoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.BoostSpec; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @param message BoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.BoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace BoostSpec { + + /** Properties of a ConditionBoostSpec. */ + interface IConditionBoostSpec { + + /** ConditionBoostSpec condition */ + condition?: (string|null); + + /** ConditionBoostSpec boost */ + boost?: (number|null); + } + + /** Represents a ConditionBoostSpec. */ + class ConditionBoostSpec implements IConditionBoostSpec { + + /** + * Constructs a new ConditionBoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec); + + /** ConditionBoostSpec condition. */ + public condition: string; + + /** ConditionBoostSpec boost. */ + public boost: number; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns ConditionBoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec): google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ConditionBoostSpec + * @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.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ConditionBoostSpec + * @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.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Verifies a ConditionBoostSpec 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 ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ConditionBoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @param message ConditionBoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ConditionBoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionSpec. */ + interface IQueryExpansionSpec { + + /** QueryExpansionSpec condition */ + condition?: (google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition|null); + + /** QueryExpansionSpec pinUnexpandedResults */ + pinUnexpandedResults?: (boolean|null); + } + + /** Represents a QueryExpansionSpec. */ + class QueryExpansionSpec implements IQueryExpansionSpec { + + /** + * Constructs a new QueryExpansionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec); + + /** QueryExpansionSpec condition. */ + public condition: (google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition); + + /** QueryExpansionSpec pinUnexpandedResults. */ + public pinUnexpandedResults: boolean; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec): google.cloud.retail.v2.SearchRequest.QueryExpansionSpec; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionSpec + * @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.cloud.retail.v2.SearchRequest.QueryExpansionSpec; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionSpec + * @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.cloud.retail.v2.SearchRequest.QueryExpansionSpec; + + /** + * Verifies a QueryExpansionSpec 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 QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.QueryExpansionSpec; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @param message QueryExpansionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.QueryExpansionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace QueryExpansionSpec { + + /** Condition enum. */ + enum Condition { + CONDITION_UNSPECIFIED = 0, + DISABLED = 1, + AUTO = 3 + } + } + + /** Properties of a PersonalizationSpec. */ + interface IPersonalizationSpec { + + /** PersonalizationSpec mode */ + mode?: (google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode|null); + } + + /** Represents a PersonalizationSpec. */ + class PersonalizationSpec implements IPersonalizationSpec { + + /** + * Constructs a new PersonalizationSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.IPersonalizationSpec); + + /** PersonalizationSpec mode. */ + public mode: (google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode); + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns PersonalizationSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.IPersonalizationSpec): google.cloud.retail.v2.SearchRequest.PersonalizationSpec; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PersonalizationSpec + * @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.cloud.retail.v2.SearchRequest.PersonalizationSpec; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PersonalizationSpec + * @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.cloud.retail.v2.SearchRequest.PersonalizationSpec; + + /** + * Verifies a PersonalizationSpec 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 PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PersonalizationSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.PersonalizationSpec; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @param message PersonalizationSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.PersonalizationSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PersonalizationSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PersonalizationSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PersonalizationSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + AUTO = 1, + DISABLED = 2 + } + } + + /** Properties of a SpellCorrectionSpec. */ + interface ISpellCorrectionSpec { + + /** SpellCorrectionSpec mode */ + mode?: (google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|null); + } + + /** Represents a SpellCorrectionSpec. */ + class SpellCorrectionSpec implements ISpellCorrectionSpec { + + /** + * Constructs a new SpellCorrectionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec); + + /** SpellCorrectionSpec mode. */ + public mode: (google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode); + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns SpellCorrectionSpec instance + */ + public static create(properties?: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Verifies a SpellCorrectionSpec 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 SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpellCorrectionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @param message SpellCorrectionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SpellCorrectionSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + SUGGESTION_ONLY = 1, + AUTO = 2 + } + } + + /** SearchMode enum. */ + enum SearchMode { + SEARCH_MODE_UNSPECIFIED = 0, + PRODUCT_SEARCH_ONLY = 1, + FACETED_SEARCH_ONLY = 2 + } + } + + /** Properties of a SearchResponse. */ + interface ISearchResponse { + + /** SearchResponse results */ + results?: (google.cloud.retail.v2.SearchResponse.ISearchResult[]|null); + + /** SearchResponse facets */ + facets?: (google.cloud.retail.v2.SearchResponse.IFacet[]|null); + + /** SearchResponse totalSize */ + totalSize?: (number|null); + + /** SearchResponse correctedQuery */ + correctedQuery?: (string|null); + + /** SearchResponse attributionToken */ + attributionToken?: (string|null); + + /** SearchResponse nextPageToken */ + nextPageToken?: (string|null); + + /** SearchResponse queryExpansionInfo */ + queryExpansionInfo?: (google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri */ + redirectUri?: (string|null); + + /** SearchResponse appliedControls */ + appliedControls?: (string[]|null); + + /** SearchResponse invalidConditionBoostSpecs */ + invalidConditionBoostSpecs?: (google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + } + + /** Represents a SearchResponse. */ + class SearchResponse implements ISearchResponse { + + /** + * Constructs a new SearchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ISearchResponse); + + /** SearchResponse results. */ + public results: google.cloud.retail.v2.SearchResponse.ISearchResult[]; + + /** SearchResponse facets. */ + public facets: google.cloud.retail.v2.SearchResponse.IFacet[]; + + /** SearchResponse totalSize. */ + public totalSize: number; + + /** SearchResponse correctedQuery. */ + public correctedQuery: string; + + /** SearchResponse attributionToken. */ + public attributionToken: string; + + /** SearchResponse nextPageToken. */ + public nextPageToken: string; + + /** SearchResponse queryExpansionInfo. */ + public queryExpansionInfo?: (google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri. */ + public redirectUri: string; + + /** SearchResponse appliedControls. */ + public appliedControls: string[]; + + /** SearchResponse invalidConditionBoostSpecs. */ + public invalidConditionBoostSpecs: google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResponse instance + */ + public static create(properties?: google.cloud.retail.v2.ISearchResponse): google.cloud.retail.v2.SearchResponse; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResponse + * @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.cloud.retail.v2.SearchResponse; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResponse + * @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.cloud.retail.v2.SearchResponse; + + /** + * Verifies a SearchResponse 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 SearchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchResponse; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @param message SearchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchResponse { + + /** Properties of a SearchResult. */ + interface ISearchResult { + + /** SearchResult id */ + id?: (string|null); + + /** SearchResult product */ + product?: (google.cloud.retail.v2.IProduct|null); + + /** SearchResult matchingVariantCount */ + matchingVariantCount?: (number|null); + + /** SearchResult matchingVariantFields */ + matchingVariantFields?: ({ [k: string]: google.protobuf.IFieldMask }|null); + + /** SearchResult variantRollupValues */ + variantRollupValues?: ({ [k: string]: google.protobuf.IValue }|null); + + /** SearchResult personalLabels */ + personalLabels?: (string[]|null); + } + + /** Represents a SearchResult. */ + class SearchResult implements ISearchResult { + + /** + * Constructs a new SearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchResponse.ISearchResult); + + /** SearchResult id. */ + public id: string; + + /** SearchResult product. */ + public product?: (google.cloud.retail.v2.IProduct|null); + + /** SearchResult matchingVariantCount. */ + public matchingVariantCount: number; + + /** SearchResult matchingVariantFields. */ + public matchingVariantFields: { [k: string]: google.protobuf.IFieldMask }; + + /** SearchResult variantRollupValues. */ + public variantRollupValues: { [k: string]: google.protobuf.IValue }; + + /** SearchResult personalLabels. */ + public personalLabels: string[]; + + /** + * Creates a new SearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResult instance + */ + public static create(properties?: google.cloud.retail.v2.SearchResponse.ISearchResult): google.cloud.retail.v2.SearchResponse.SearchResult; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResult + * @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.cloud.retail.v2.SearchResponse.SearchResult; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResult + * @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.cloud.retail.v2.SearchResponse.SearchResult; + + /** + * Verifies a SearchResult 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 SearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchResponse.SearchResult; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @param message SearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchResponse.SearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Facet. */ + interface IFacet { + + /** Facet key */ + key?: (string|null); + + /** Facet values */ + values?: (google.cloud.retail.v2.SearchResponse.Facet.IFacetValue[]|null); + + /** Facet dynamicFacet */ + dynamicFacet?: (boolean|null); + } + + /** Represents a Facet. */ + class Facet implements IFacet { + + /** + * Constructs a new Facet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchResponse.IFacet); + + /** Facet key. */ + public key: string; + + /** Facet values. */ + public values: google.cloud.retail.v2.SearchResponse.Facet.IFacetValue[]; + + /** Facet dynamicFacet. */ + public dynamicFacet: boolean; + + /** + * Creates a new Facet instance using the specified properties. + * @param [properties] Properties to set + * @returns Facet instance + */ + public static create(properties?: google.cloud.retail.v2.SearchResponse.IFacet): google.cloud.retail.v2.SearchResponse.Facet; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Facet + * @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.cloud.retail.v2.SearchResponse.Facet; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Facet + * @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.cloud.retail.v2.SearchResponse.Facet; + + /** + * Verifies a Facet 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 Facet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Facet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchResponse.Facet; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @param message Facet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchResponse.Facet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Facet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Facet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Facet { + + /** Properties of a FacetValue. */ + interface IFacetValue { + + /** FacetValue value */ + value?: (string|null); + + /** FacetValue interval */ + interval?: (google.cloud.retail.v2.IInterval|null); + + /** FacetValue count */ + count?: (number|Long|string|null); + + /** FacetValue minValue */ + minValue?: (number|null); + + /** FacetValue maxValue */ + maxValue?: (number|null); + } + + /** Represents a FacetValue. */ + class FacetValue implements IFacetValue { + + /** + * Constructs a new FacetValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchResponse.Facet.IFacetValue); + + /** FacetValue value. */ + public value?: (string|null); + + /** FacetValue interval. */ + public interval?: (google.cloud.retail.v2.IInterval|null); + + /** FacetValue count. */ + public count: (number|Long|string); + + /** FacetValue minValue. */ + public minValue: number; + + /** FacetValue maxValue. */ + public maxValue: number; + + /** FacetValue facetValue. */ + public facetValue?: ("value"|"interval"); + + /** + * Creates a new FacetValue instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetValue instance + */ + public static create(properties?: google.cloud.retail.v2.SearchResponse.Facet.IFacetValue): google.cloud.retail.v2.SearchResponse.Facet.FacetValue; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetValue + * @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.cloud.retail.v2.SearchResponse.Facet.FacetValue; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetValue + * @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.cloud.retail.v2.SearchResponse.Facet.FacetValue; + + /** + * Verifies a FacetValue 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 FacetValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetValue + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchResponse.Facet.FacetValue; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @param message FacetValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchResponse.Facet.FacetValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionInfo. */ + interface IQueryExpansionInfo { + + /** QueryExpansionInfo expandedQuery */ + expandedQuery?: (boolean|null); + + /** QueryExpansionInfo pinnedResultCount */ + pinnedResultCount?: (number|Long|string|null); + } + + /** Represents a QueryExpansionInfo. */ + class QueryExpansionInfo implements IQueryExpansionInfo { + + /** + * Constructs a new QueryExpansionInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo); + + /** QueryExpansionInfo expandedQuery. */ + public expandedQuery: boolean; + + /** QueryExpansionInfo pinnedResultCount. */ + public pinnedResultCount: (number|Long|string); + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionInfo instance + */ + public static create(properties?: google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo): google.cloud.retail.v2.SearchResponse.QueryExpansionInfo; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionInfo + * @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.cloud.retail.v2.SearchResponse.QueryExpansionInfo; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionInfo + * @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.cloud.retail.v2.SearchResponse.QueryExpansionInfo; + + /** + * Verifies a QueryExpansionInfo 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 QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.SearchResponse.QueryExpansionInfo; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @param message QueryExpansionInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.SearchResponse.QueryExpansionInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a ServingConfig. */ + interface IServingConfig { + + /** ServingConfig name */ + name?: (string|null); + + /** ServingConfig displayName */ + displayName?: (string|null); + + /** ServingConfig modelId */ + modelId?: (string|null); + + /** ServingConfig priceRerankingLevel */ + priceRerankingLevel?: (string|null); + + /** ServingConfig facetControlIds */ + facetControlIds?: (string[]|null); + + /** ServingConfig dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds */ + boostControlIds?: (string[]|null); + + /** ServingConfig filterControlIds */ + filterControlIds?: (string[]|null); + + /** ServingConfig redirectControlIds */ + redirectControlIds?: (string[]|null); + + /** ServingConfig twowaySynonymsControlIds */ + twowaySynonymsControlIds?: (string[]|null); + + /** ServingConfig onewaySynonymsControlIds */ + onewaySynonymsControlIds?: (string[]|null); + + /** ServingConfig doNotAssociateControlIds */ + doNotAssociateControlIds?: (string[]|null); + + /** ServingConfig replacementControlIds */ + replacementControlIds?: (string[]|null); + + /** ServingConfig ignoreControlIds */ + ignoreControlIds?: (string[]|null); + + /** ServingConfig diversityLevel */ + diversityLevel?: (string|null); + + /** ServingConfig enableCategoryFilterLevel */ + enableCategoryFilterLevel?: (string|null); + + /** ServingConfig personalizationSpec */ + personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + + /** ServingConfig solutionTypes */ + solutionTypes?: (google.cloud.retail.v2.SolutionType[]|null); + } + + /** Represents a ServingConfig. */ + class ServingConfig implements IServingConfig { + + /** + * Constructs a new ServingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IServingConfig); + + /** ServingConfig name. */ + public name: string; + + /** ServingConfig displayName. */ + public displayName: string; + + /** ServingConfig modelId. */ + public modelId: string; + + /** ServingConfig priceRerankingLevel. */ + public priceRerankingLevel: string; + + /** ServingConfig facetControlIds. */ + public facetControlIds: string[]; + + /** ServingConfig dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds. */ + public boostControlIds: string[]; + + /** ServingConfig filterControlIds. */ + public filterControlIds: string[]; + + /** ServingConfig redirectControlIds. */ + public redirectControlIds: string[]; + + /** ServingConfig twowaySynonymsControlIds. */ + public twowaySynonymsControlIds: string[]; + + /** ServingConfig onewaySynonymsControlIds. */ + public onewaySynonymsControlIds: string[]; + + /** ServingConfig doNotAssociateControlIds. */ + public doNotAssociateControlIds: string[]; + + /** ServingConfig replacementControlIds. */ + public replacementControlIds: string[]; + + /** ServingConfig ignoreControlIds. */ + public ignoreControlIds: string[]; + + /** ServingConfig diversityLevel. */ + public diversityLevel: string; + + /** ServingConfig enableCategoryFilterLevel. */ + public enableCategoryFilterLevel: string; + + /** ServingConfig personalizationSpec. */ + public personalizationSpec?: (google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null); + + /** ServingConfig solutionTypes. */ + public solutionTypes: google.cloud.retail.v2.SolutionType[]; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ServingConfig instance + */ + public static create(properties?: google.cloud.retail.v2.IServingConfig): google.cloud.retail.v2.ServingConfig; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServingConfig + * @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.cloud.retail.v2.ServingConfig; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServingConfig + * @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.cloud.retail.v2.ServingConfig; + + /** + * Verifies a ServingConfig 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 ServingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ServingConfig; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @param message ServingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ServingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a ServingConfigService */ + class ServingConfigService extends $protobuf.rpc.Service { + + /** + * Constructs a new ServingConfigService 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 ServingConfigService 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): ServingConfigService; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public createServingConfig(request: google.cloud.retail.v2.ICreateServingConfigRequest, callback: google.cloud.retail.v2.ServingConfigService.CreateServingConfigCallback): void; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @returns Promise + */ + public createServingConfig(request: google.cloud.retail.v2.ICreateServingConfigRequest): Promise; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteServingConfig(request: google.cloud.retail.v2.IDeleteServingConfigRequest, callback: google.cloud.retail.v2.ServingConfigService.DeleteServingConfigCallback): void; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @returns Promise + */ + public deleteServingConfig(request: google.cloud.retail.v2.IDeleteServingConfigRequest): Promise; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public updateServingConfig(request: google.cloud.retail.v2.IUpdateServingConfigRequest, callback: google.cloud.retail.v2.ServingConfigService.UpdateServingConfigCallback): void; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @returns Promise + */ + public updateServingConfig(request: google.cloud.retail.v2.IUpdateServingConfigRequest): Promise; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public getServingConfig(request: google.cloud.retail.v2.IGetServingConfigRequest, callback: google.cloud.retail.v2.ServingConfigService.GetServingConfigCallback): void; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @returns Promise + */ + public getServingConfig(request: google.cloud.retail.v2.IGetServingConfigRequest): Promise; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListServingConfigsResponse + */ + public listServingConfigs(request: google.cloud.retail.v2.IListServingConfigsRequest, callback: google.cloud.retail.v2.ServingConfigService.ListServingConfigsCallback): void; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @returns Promise + */ + public listServingConfigs(request: google.cloud.retail.v2.IListServingConfigsRequest): Promise; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public addControl(request: google.cloud.retail.v2.IAddControlRequest, callback: google.cloud.retail.v2.ServingConfigService.AddControlCallback): void; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @returns Promise + */ + public addControl(request: google.cloud.retail.v2.IAddControlRequest): Promise; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public removeControl(request: google.cloud.retail.v2.IRemoveControlRequest, callback: google.cloud.retail.v2.ServingConfigService.RemoveControlCallback): void; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @returns Promise + */ + public removeControl(request: google.cloud.retail.v2.IRemoveControlRequest): Promise; + } + + namespace ServingConfigService { + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|createServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type CreateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|deleteServingConfig}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteServingConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|updateServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type UpdateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|getServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type GetServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|listServingConfigs}. + * @param error Error, if any + * @param [response] ListServingConfigsResponse + */ + type ListServingConfigsCallback = (error: (Error|null), response?: google.cloud.retail.v2.ListServingConfigsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|addControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type AddControlCallback = (error: (Error|null), response?: google.cloud.retail.v2.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|removeControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type RemoveControlCallback = (error: (Error|null), response?: google.cloud.retail.v2.ServingConfig) => void; + } + + /** Properties of a CreateServingConfigRequest. */ + interface ICreateServingConfigRequest { + + /** CreateServingConfigRequest parent */ + parent?: (string|null); + + /** CreateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId */ + servingConfigId?: (string|null); + } + + /** Represents a CreateServingConfigRequest. */ + class CreateServingConfigRequest implements ICreateServingConfigRequest { + + /** + * Constructs a new CreateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICreateServingConfigRequest); + + /** CreateServingConfigRequest parent. */ + public parent: string; + + /** CreateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId. */ + public servingConfigId: string; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ICreateServingConfigRequest): google.cloud.retail.v2.CreateServingConfigRequest; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2.CreateServingConfigRequest; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2.CreateServingConfigRequest; + + /** + * Verifies a CreateServingConfigRequest 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 CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CreateServingConfigRequest; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @param message CreateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CreateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateServingConfigRequest. */ + interface IUpdateServingConfigRequest { + + /** UpdateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateServingConfigRequest. */ + class UpdateServingConfigRequest implements IUpdateServingConfigRequest { + + /** + * Constructs a new UpdateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IUpdateServingConfigRequest); + + /** UpdateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IUpdateServingConfigRequest): google.cloud.retail.v2.UpdateServingConfigRequest; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2.UpdateServingConfigRequest; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2.UpdateServingConfigRequest; + + /** + * Verifies an UpdateServingConfigRequest 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 UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.UpdateServingConfigRequest; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @param message UpdateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.UpdateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteServingConfigRequest. */ + interface IDeleteServingConfigRequest { + + /** DeleteServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a DeleteServingConfigRequest. */ + class DeleteServingConfigRequest implements IDeleteServingConfigRequest { + + /** + * Constructs a new DeleteServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IDeleteServingConfigRequest); + + /** DeleteServingConfigRequest name. */ + public name: string; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IDeleteServingConfigRequest): google.cloud.retail.v2.DeleteServingConfigRequest; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2.DeleteServingConfigRequest; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2.DeleteServingConfigRequest; + + /** + * Verifies a DeleteServingConfigRequest 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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.DeleteServingConfigRequest; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @param message DeleteServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.DeleteServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetServingConfigRequest. */ + interface IGetServingConfigRequest { + + /** GetServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetServingConfigRequest. */ + class GetServingConfigRequest implements IGetServingConfigRequest { + + /** + * Constructs a new GetServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IGetServingConfigRequest); + + /** GetServingConfigRequest name. */ + public name: string; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IGetServingConfigRequest): google.cloud.retail.v2.GetServingConfigRequest; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetServingConfigRequest + * @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.cloud.retail.v2.GetServingConfigRequest; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetServingConfigRequest + * @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.cloud.retail.v2.GetServingConfigRequest; + + /** + * Verifies a GetServingConfigRequest 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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.GetServingConfigRequest; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @param message GetServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.GetServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsRequest. */ + interface IListServingConfigsRequest { + + /** ListServingConfigsRequest parent */ + parent?: (string|null); + + /** ListServingConfigsRequest pageSize */ + pageSize?: (number|null); + + /** ListServingConfigsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListServingConfigsRequest. */ + class ListServingConfigsRequest implements IListServingConfigsRequest { + + /** + * Constructs a new ListServingConfigsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListServingConfigsRequest); + + /** ListServingConfigsRequest parent. */ + public parent: string; + + /** ListServingConfigsRequest pageSize. */ + public pageSize: number; + + /** ListServingConfigsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IListServingConfigsRequest): google.cloud.retail.v2.ListServingConfigsRequest; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2.ListServingConfigsRequest; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2.ListServingConfigsRequest; + + /** + * Verifies a ListServingConfigsRequest 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListServingConfigsRequest; + + /** + * Creates a plain object from a ListServingConfigsRequest message. Also converts values to other types if specified. + * @param message ListServingConfigsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListServingConfigsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsResponse. */ + interface IListServingConfigsResponse { + + /** ListServingConfigsResponse servingConfigs */ + servingConfigs?: (google.cloud.retail.v2.IServingConfig[]|null); + + /** ListServingConfigsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListServingConfigsResponse. */ + class ListServingConfigsResponse implements IListServingConfigsResponse { + + /** + * Constructs a new ListServingConfigsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IListServingConfigsResponse); + + /** ListServingConfigsResponse servingConfigs. */ + public servingConfigs: google.cloud.retail.v2.IServingConfig[]; + + /** ListServingConfigsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IListServingConfigsResponse): google.cloud.retail.v2.ListServingConfigsResponse; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2.ListServingConfigsResponse; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2.ListServingConfigsResponse; + + /** + * Verifies a ListServingConfigsResponse 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 ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.ListServingConfigsResponse; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @param message ListServingConfigsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.ListServingConfigsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddControlRequest. */ + interface IAddControlRequest { + + /** AddControlRequest servingConfig */ + servingConfig?: (string|null); + + /** AddControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents an AddControlRequest. */ + class AddControlRequest implements IAddControlRequest { + + /** + * Constructs a new AddControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IAddControlRequest); + + /** AddControlRequest servingConfig. */ + public servingConfig: string; + + /** AddControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IAddControlRequest): google.cloud.retail.v2.AddControlRequest; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddControlRequest + * @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.cloud.retail.v2.AddControlRequest; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddControlRequest + * @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.cloud.retail.v2.AddControlRequest; + + /** + * Verifies an AddControlRequest 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 AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.AddControlRequest; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @param message AddControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.AddControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveControlRequest. */ + interface IRemoveControlRequest { + + /** RemoveControlRequest servingConfig */ + servingConfig?: (string|null); + + /** RemoveControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a RemoveControlRequest. */ + class RemoveControlRequest implements IRemoveControlRequest { + + /** + * Constructs a new RemoveControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRemoveControlRequest); + + /** RemoveControlRequest servingConfig. */ + public servingConfig: string; + + /** RemoveControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IRemoveControlRequest): google.cloud.retail.v2.RemoveControlRequest; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveControlRequest + * @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.cloud.retail.v2.RemoveControlRequest; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveControlRequest + * @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.cloud.retail.v2.RemoveControlRequest; + + /** + * Verifies a RemoveControlRequest 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 RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RemoveControlRequest; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @param message RemoveControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RemoveControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a UserEventService */ + class UserEventService extends $protobuf.rpc.Service { + + /** + * Constructs a new UserEventService 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 UserEventService 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): UserEventService; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and UserEvent + */ + public writeUserEvent(request: google.cloud.retail.v2.IWriteUserEventRequest, callback: google.cloud.retail.v2.UserEventService.WriteUserEventCallback): void; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @returns Promise + */ + public writeUserEvent(request: google.cloud.retail.v2.IWriteUserEventRequest): Promise; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and HttpBody + */ + public collectUserEvent(request: google.cloud.retail.v2.ICollectUserEventRequest, callback: google.cloud.retail.v2.UserEventService.CollectUserEventCallback): void; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @returns Promise + */ + public collectUserEvent(request: google.cloud.retail.v2.ICollectUserEventRequest): Promise; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public purgeUserEvents(request: google.cloud.retail.v2.IPurgeUserEventsRequest, callback: google.cloud.retail.v2.UserEventService.PurgeUserEventsCallback): void; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @returns Promise + */ + public purgeUserEvents(request: google.cloud.retail.v2.IPurgeUserEventsRequest): Promise; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importUserEvents(request: google.cloud.retail.v2.IImportUserEventsRequest, callback: google.cloud.retail.v2.UserEventService.ImportUserEventsCallback): void; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @returns Promise + */ + public importUserEvents(request: google.cloud.retail.v2.IImportUserEventsRequest): Promise; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public rejoinUserEvents(request: google.cloud.retail.v2.IRejoinUserEventsRequest, callback: google.cloud.retail.v2.UserEventService.RejoinUserEventsCallback): void; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @returns Promise + */ + public rejoinUserEvents(request: google.cloud.retail.v2.IRejoinUserEventsRequest): Promise; + } + + namespace UserEventService { + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|writeUserEvent}. + * @param error Error, if any + * @param [response] UserEvent + */ + type WriteUserEventCallback = (error: (Error|null), response?: google.cloud.retail.v2.UserEvent) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|collectUserEvent}. + * @param error Error, if any + * @param [response] HttpBody + */ + type CollectUserEventCallback = (error: (Error|null), response?: google.api.HttpBody) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|purgeUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type PurgeUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|importUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|rejoinUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type RejoinUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a WriteUserEventRequest. */ + interface IWriteUserEventRequest { + + /** WriteUserEventRequest parent */ + parent?: (string|null); + + /** WriteUserEventRequest userEvent */ + userEvent?: (google.cloud.retail.v2.IUserEvent|null); + } + + /** Represents a WriteUserEventRequest. */ + class WriteUserEventRequest implements IWriteUserEventRequest { + + /** + * Constructs a new WriteUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IWriteUserEventRequest); + + /** WriteUserEventRequest parent. */ + public parent: string; + + /** WriteUserEventRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2.IUserEvent|null); + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IWriteUserEventRequest): google.cloud.retail.v2.WriteUserEventRequest; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteUserEventRequest + * @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.cloud.retail.v2.WriteUserEventRequest; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteUserEventRequest + * @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.cloud.retail.v2.WriteUserEventRequest; + + /** + * Verifies a WriteUserEventRequest 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 WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.WriteUserEventRequest; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @param message WriteUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.WriteUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WriteUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CollectUserEventRequest. */ + interface ICollectUserEventRequest { + + /** CollectUserEventRequest parent */ + parent?: (string|null); + + /** CollectUserEventRequest userEvent */ + userEvent?: (string|null); + + /** CollectUserEventRequest uri */ + uri?: (string|null); + + /** CollectUserEventRequest ets */ + ets?: (number|Long|string|null); + } + + /** Represents a CollectUserEventRequest. */ + class CollectUserEventRequest implements ICollectUserEventRequest { + + /** + * Constructs a new CollectUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.ICollectUserEventRequest); + + /** CollectUserEventRequest parent. */ + public parent: string; + + /** CollectUserEventRequest userEvent. */ + public userEvent: string; + + /** CollectUserEventRequest uri. */ + public uri: string; + + /** CollectUserEventRequest ets. */ + public ets: (number|Long|string); + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CollectUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2.ICollectUserEventRequest): google.cloud.retail.v2.CollectUserEventRequest; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CollectUserEventRequest + * @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.cloud.retail.v2.CollectUserEventRequest; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CollectUserEventRequest + * @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.cloud.retail.v2.CollectUserEventRequest; + + /** + * Verifies a CollectUserEventRequest 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 CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.CollectUserEventRequest; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @param message CollectUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.CollectUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CollectUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsRequest. */ + interface IRejoinUserEventsRequest { + + /** RejoinUserEventsRequest parent */ + parent?: (string|null); + + /** RejoinUserEventsRequest userEventRejoinScope */ + userEventRejoinScope?: (google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope|null); + } + + /** Represents a RejoinUserEventsRequest. */ + class RejoinUserEventsRequest implements IRejoinUserEventsRequest { + + /** + * Constructs a new RejoinUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRejoinUserEventsRequest); + + /** RejoinUserEventsRequest parent. */ + public parent: string; + + /** RejoinUserEventsRequest userEventRejoinScope. */ + public userEventRejoinScope: (google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope); + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2.IRejoinUserEventsRequest): google.cloud.retail.v2.RejoinUserEventsRequest; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2.RejoinUserEventsRequest; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2.RejoinUserEventsRequest; + + /** + * Verifies a RejoinUserEventsRequest 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 RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RejoinUserEventsRequest; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @param message RejoinUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RejoinUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace RejoinUserEventsRequest { + + /** UserEventRejoinScope enum. */ + enum UserEventRejoinScope { + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0, + JOINED_EVENTS = 1, + UNJOINED_EVENTS = 2 + } + } + + /** Properties of a RejoinUserEventsResponse. */ + interface IRejoinUserEventsResponse { + + /** RejoinUserEventsResponse rejoinedUserEventsCount */ + rejoinedUserEventsCount?: (number|Long|string|null); + } + + /** Represents a RejoinUserEventsResponse. */ + class RejoinUserEventsResponse implements IRejoinUserEventsResponse { + + /** + * Constructs a new RejoinUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRejoinUserEventsResponse); + + /** RejoinUserEventsResponse rejoinedUserEventsCount. */ + public rejoinedUserEventsCount: (number|Long|string); + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2.IRejoinUserEventsResponse): google.cloud.retail.v2.RejoinUserEventsResponse; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2.RejoinUserEventsResponse; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2.RejoinUserEventsResponse; + + /** + * Verifies a RejoinUserEventsResponse 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 RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RejoinUserEventsResponse; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @param message RejoinUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RejoinUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsMetadata. */ + interface IRejoinUserEventsMetadata { + } + + /** Represents a RejoinUserEventsMetadata. */ + class RejoinUserEventsMetadata implements IRejoinUserEventsMetadata { + + /** + * Constructs a new RejoinUserEventsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2.IRejoinUserEventsMetadata); + + /** + * Creates a new RejoinUserEventsMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsMetadata instance + */ + public static create(properties?: google.cloud.retail.v2.IRejoinUserEventsMetadata): google.cloud.retail.v2.RejoinUserEventsMetadata; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2.RejoinUserEventsMetadata; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2.RejoinUserEventsMetadata; + + /** + * Verifies a RejoinUserEventsMetadata 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 RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2.RejoinUserEventsMetadata; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @param message RejoinUserEventsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2.RejoinUserEventsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace v2alpha. */ + namespace v2alpha { + + /** Properties of a ProductLevelConfig. */ + interface IProductLevelConfig { + + /** ProductLevelConfig ingestionProductType */ + ingestionProductType?: (string|null); + + /** ProductLevelConfig merchantCenterProductIdField */ + merchantCenterProductIdField?: (string|null); + } + + /** Represents a ProductLevelConfig. */ + class ProductLevelConfig implements IProductLevelConfig { + + /** + * Constructs a new ProductLevelConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IProductLevelConfig); + + /** ProductLevelConfig ingestionProductType. */ + public ingestionProductType: string; + + /** ProductLevelConfig merchantCenterProductIdField. */ + public merchantCenterProductIdField: string; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductLevelConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IProductLevelConfig): google.cloud.retail.v2alpha.ProductLevelConfig; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductLevelConfig + * @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.cloud.retail.v2alpha.ProductLevelConfig; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductLevelConfig + * @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.cloud.retail.v2alpha.ProductLevelConfig; + + /** + * Verifies a ProductLevelConfig 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 ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductLevelConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ProductLevelConfig; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @param message ProductLevelConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ProductLevelConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductLevelConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductLevelConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CatalogAttribute. */ + interface ICatalogAttribute { + + /** CatalogAttribute key */ + key?: (string|null); + + /** CatalogAttribute inUse */ + inUse?: (boolean|null); + + /** CatalogAttribute type */ + type?: (google.cloud.retail.v2alpha.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.AttributeType|null); + + /** CatalogAttribute indexableOption */ + indexableOption?: (google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption|null); + + /** CatalogAttribute dynamicFacetableOption */ + dynamicFacetableOption?: (google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption|null); + + /** CatalogAttribute searchableOption */ + searchableOption?: (google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption|null); + + /** CatalogAttribute recommendationsFilteringOption */ + recommendationsFilteringOption?: (google.cloud.retail.v2alpha.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2alpha.RecommendationsFilteringOption|null); + } + + /** Represents a CatalogAttribute. */ + class CatalogAttribute implements ICatalogAttribute { + + /** + * Constructs a new CatalogAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICatalogAttribute); + + /** CatalogAttribute key. */ + public key: string; + + /** CatalogAttribute inUse. */ + public inUse: boolean; + + /** CatalogAttribute type. */ + public type: (google.cloud.retail.v2alpha.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.AttributeType); + + /** CatalogAttribute indexableOption. */ + public indexableOption: (google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption); + + /** CatalogAttribute dynamicFacetableOption. */ + public dynamicFacetableOption: (google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption); + + /** CatalogAttribute searchableOption. */ + public searchableOption: (google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption); + + /** CatalogAttribute recommendationsFilteringOption. */ + public recommendationsFilteringOption: (google.cloud.retail.v2alpha.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2alpha.RecommendationsFilteringOption); + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CatalogAttribute instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICatalogAttribute): google.cloud.retail.v2alpha.CatalogAttribute; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2alpha.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CatalogAttribute + * @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.cloud.retail.v2alpha.CatalogAttribute; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CatalogAttribute + * @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.cloud.retail.v2alpha.CatalogAttribute; + + /** + * Verifies a CatalogAttribute 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 CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CatalogAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CatalogAttribute; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @param message CatalogAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CatalogAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CatalogAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CatalogAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CatalogAttribute { + + /** AttributeType enum. */ + enum AttributeType { + UNKNOWN = 0, + TEXTUAL = 1, + NUMERICAL = 2 + } + + /** IndexableOption enum. */ + enum IndexableOption { + INDEXABLE_OPTION_UNSPECIFIED = 0, + INDEXABLE_ENABLED = 1, + INDEXABLE_DISABLED = 2 + } + + /** DynamicFacetableOption enum. */ + enum DynamicFacetableOption { + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0, + DYNAMIC_FACETABLE_ENABLED = 1, + DYNAMIC_FACETABLE_DISABLED = 2 + } + + /** SearchableOption enum. */ + enum SearchableOption { + SEARCHABLE_OPTION_UNSPECIFIED = 0, + SEARCHABLE_ENABLED = 1, + SEARCHABLE_DISABLED = 2 + } + } + + /** Properties of an AttributesConfig. */ + interface IAttributesConfig { + + /** AttributesConfig name */ + name?: (string|null); + + /** AttributesConfig catalogAttributes */ + catalogAttributes?: ({ [k: string]: google.cloud.retail.v2alpha.ICatalogAttribute }|null); + + /** AttributesConfig attributeConfigLevel */ + attributeConfigLevel?: (google.cloud.retail.v2alpha.AttributeConfigLevel|keyof typeof google.cloud.retail.v2alpha.AttributeConfigLevel|null); + } + + /** Represents an AttributesConfig. */ + class AttributesConfig implements IAttributesConfig { + + /** + * Constructs a new AttributesConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAttributesConfig); + + /** AttributesConfig name. */ + public name: string; + + /** AttributesConfig catalogAttributes. */ + public catalogAttributes: { [k: string]: google.cloud.retail.v2alpha.ICatalogAttribute }; + + /** AttributesConfig attributeConfigLevel. */ + public attributeConfigLevel: (google.cloud.retail.v2alpha.AttributeConfigLevel|keyof typeof google.cloud.retail.v2alpha.AttributeConfigLevel); + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns AttributesConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAttributesConfig): google.cloud.retail.v2alpha.AttributesConfig; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AttributesConfig + * @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.cloud.retail.v2alpha.AttributesConfig; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AttributesConfig + * @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.cloud.retail.v2alpha.AttributesConfig; + + /** + * Verifies an AttributesConfig 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 AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AttributesConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AttributesConfig; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @param message AttributesConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AttributesConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AttributesConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AttributesConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionConfig. */ + interface ICompletionConfig { + + /** CompletionConfig name */ + name?: (string|null); + + /** CompletionConfig matchingOrder */ + matchingOrder?: (string|null); + + /** CompletionConfig maxSuggestions */ + maxSuggestions?: (number|null); + + /** CompletionConfig minPrefixLength */ + minPrefixLength?: (number|null); + + /** CompletionConfig autoLearning */ + autoLearning?: (boolean|null); + + /** CompletionConfig suggestionsInputConfig */ + suggestionsInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation */ + lastSuggestionsImportOperation?: (string|null); + + /** CompletionConfig denylistInputConfig */ + denylistInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation */ + lastDenylistImportOperation?: (string|null); + + /** CompletionConfig allowlistInputConfig */ + allowlistInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation */ + lastAllowlistImportOperation?: (string|null); + } + + /** Represents a CompletionConfig. */ + class CompletionConfig implements ICompletionConfig { + + /** + * Constructs a new CompletionConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICompletionConfig); + + /** CompletionConfig name. */ + public name: string; + + /** CompletionConfig matchingOrder. */ + public matchingOrder: string; + + /** CompletionConfig maxSuggestions. */ + public maxSuggestions: number; + + /** CompletionConfig minPrefixLength. */ + public minPrefixLength: number; + + /** CompletionConfig autoLearning. */ + public autoLearning: boolean; + + /** CompletionConfig suggestionsInputConfig. */ + public suggestionsInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation. */ + public lastSuggestionsImportOperation: string; + + /** CompletionConfig denylistInputConfig. */ + public denylistInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation. */ + public lastDenylistImportOperation: string; + + /** CompletionConfig allowlistInputConfig. */ + public allowlistInputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation. */ + public lastAllowlistImportOperation: string; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICompletionConfig): google.cloud.retail.v2alpha.CompletionConfig; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionConfig + * @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.cloud.retail.v2alpha.CompletionConfig; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionConfig + * @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.cloud.retail.v2alpha.CompletionConfig; + + /** + * Verifies a CompletionConfig 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 CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompletionConfig; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @param message CompletionConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompletionConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MerchantCenterLink. */ + interface IMerchantCenterLink { + + /** MerchantCenterLink merchantCenterAccountId */ + merchantCenterAccountId?: (number|Long|string|null); + + /** MerchantCenterLink branchId */ + branchId?: (string|null); + + /** MerchantCenterLink destinations */ + destinations?: (string[]|null); + + /** MerchantCenterLink regionCode */ + regionCode?: (string|null); + + /** MerchantCenterLink languageCode */ + languageCode?: (string|null); + } + + /** Represents a MerchantCenterLink. */ + class MerchantCenterLink implements IMerchantCenterLink { + + /** + * Constructs a new MerchantCenterLink. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IMerchantCenterLink); + + /** MerchantCenterLink merchantCenterAccountId. */ + public merchantCenterAccountId: (number|Long|string); + + /** MerchantCenterLink branchId. */ + public branchId: string; + + /** MerchantCenterLink destinations. */ + public destinations: string[]; + + /** MerchantCenterLink regionCode. */ + public regionCode: string; + + /** MerchantCenterLink languageCode. */ + public languageCode: string; + + /** + * Creates a new MerchantCenterLink instance using the specified properties. + * @param [properties] Properties to set + * @returns MerchantCenterLink instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IMerchantCenterLink): google.cloud.retail.v2alpha.MerchantCenterLink; + + /** + * Encodes the specified MerchantCenterLink message. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLink.verify|verify} messages. + * @param message MerchantCenterLink message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IMerchantCenterLink, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MerchantCenterLink message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLink.verify|verify} messages. + * @param message MerchantCenterLink message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IMerchantCenterLink, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MerchantCenterLink + * @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.cloud.retail.v2alpha.MerchantCenterLink; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MerchantCenterLink + * @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.cloud.retail.v2alpha.MerchantCenterLink; + + /** + * Verifies a MerchantCenterLink 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 MerchantCenterLink message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MerchantCenterLink + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.MerchantCenterLink; + + /** + * Creates a plain object from a MerchantCenterLink message. Also converts values to other types if specified. + * @param message MerchantCenterLink + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.MerchantCenterLink, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MerchantCenterLink to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MerchantCenterLink + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MerchantCenterLinkingConfig. */ + interface IMerchantCenterLinkingConfig { + + /** MerchantCenterLinkingConfig links */ + links?: (google.cloud.retail.v2alpha.IMerchantCenterLink[]|null); + } + + /** Represents a MerchantCenterLinkingConfig. */ + class MerchantCenterLinkingConfig implements IMerchantCenterLinkingConfig { + + /** + * Constructs a new MerchantCenterLinkingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig); + + /** MerchantCenterLinkingConfig links. */ + public links: google.cloud.retail.v2alpha.IMerchantCenterLink[]; + + /** + * Creates a new MerchantCenterLinkingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns MerchantCenterLinkingConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig): google.cloud.retail.v2alpha.MerchantCenterLinkingConfig; + + /** + * Encodes the specified MerchantCenterLinkingConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.verify|verify} messages. + * @param message MerchantCenterLinkingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MerchantCenterLinkingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.verify|verify} messages. + * @param message MerchantCenterLinkingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MerchantCenterLinkingConfig + * @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.cloud.retail.v2alpha.MerchantCenterLinkingConfig; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MerchantCenterLinkingConfig + * @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.cloud.retail.v2alpha.MerchantCenterLinkingConfig; + + /** + * Verifies a MerchantCenterLinkingConfig 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 MerchantCenterLinkingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MerchantCenterLinkingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.MerchantCenterLinkingConfig; + + /** + * Creates a plain object from a MerchantCenterLinkingConfig message. Also converts values to other types if specified. + * @param message MerchantCenterLinkingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.MerchantCenterLinkingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MerchantCenterLinkingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MerchantCenterLinkingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Catalog. */ + interface ICatalog { + + /** Catalog name */ + name?: (string|null); + + /** Catalog displayName */ + displayName?: (string|null); + + /** Catalog productLevelConfig */ + productLevelConfig?: (google.cloud.retail.v2alpha.IProductLevelConfig|null); + + /** Catalog merchantCenterLinkingConfig */ + merchantCenterLinkingConfig?: (google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig|null); + } + + /** Represents a Catalog. */ + class Catalog implements ICatalog { + + /** + * Constructs a new Catalog. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICatalog); + + /** Catalog name. */ + public name: string; + + /** Catalog displayName. */ + public displayName: string; + + /** Catalog productLevelConfig. */ + public productLevelConfig?: (google.cloud.retail.v2alpha.IProductLevelConfig|null); + + /** Catalog merchantCenterLinkingConfig. */ + public merchantCenterLinkingConfig?: (google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig|null); + + /** + * Creates a new Catalog instance using the specified properties. + * @param [properties] Properties to set + * @returns Catalog instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICatalog): google.cloud.retail.v2alpha.Catalog; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2alpha.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Catalog + * @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.cloud.retail.v2alpha.Catalog; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Catalog + * @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.cloud.retail.v2alpha.Catalog; + + /** + * Verifies a Catalog 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 Catalog message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Catalog + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Catalog; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @param message Catalog + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Catalog, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Catalog to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Catalog + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** AttributeConfigLevel enum. */ + enum AttributeConfigLevel { + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0, + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1, + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2 + } + + /** SolutionType enum. */ + enum SolutionType { + SOLUTION_TYPE_UNSPECIFIED = 0, + SOLUTION_TYPE_RECOMMENDATION = 1, + SOLUTION_TYPE_SEARCH = 2 + } + + /** RecommendationsFilteringOption enum. */ + enum RecommendationsFilteringOption { + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0, + RECOMMENDATIONS_FILTERING_DISABLED = 1, + RECOMMENDATIONS_FILTERING_ENABLED = 3 + } + + /** SearchSolutionUseCase enum. */ + enum SearchSolutionUseCase { + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0, + SEARCH_SOLUTION_USE_CASE_SEARCH = 1, + SEARCH_SOLUTION_USE_CASE_BROWSE = 2 + } + + /** Properties of a Condition. */ + interface ICondition { + + /** Condition queryTerms */ + queryTerms?: (google.cloud.retail.v2alpha.Condition.IQueryTerm[]|null); + + /** Condition activeTimeRange */ + activeTimeRange?: (google.cloud.retail.v2alpha.Condition.ITimeRange[]|null); + } + + /** Represents a Condition. */ + class Condition implements ICondition { + + /** + * Constructs a new Condition. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICondition); + + /** Condition queryTerms. */ + public queryTerms: google.cloud.retail.v2alpha.Condition.IQueryTerm[]; + + /** Condition activeTimeRange. */ + public activeTimeRange: google.cloud.retail.v2alpha.Condition.ITimeRange[]; + + /** + * Creates a new Condition instance using the specified properties. + * @param [properties] Properties to set + * @returns Condition instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICondition): google.cloud.retail.v2alpha.Condition; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Condition + * @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.cloud.retail.v2alpha.Condition; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Condition + * @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.cloud.retail.v2alpha.Condition; + + /** + * Verifies a Condition 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 Condition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Condition + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Condition; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @param message Condition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Condition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Condition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Condition + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Condition { + + /** Properties of a QueryTerm. */ + interface IQueryTerm { + + /** QueryTerm value */ + value?: (string|null); + + /** QueryTerm fullMatch */ + fullMatch?: (boolean|null); + } + + /** Represents a QueryTerm. */ + class QueryTerm implements IQueryTerm { + + /** + * Constructs a new QueryTerm. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Condition.IQueryTerm); + + /** QueryTerm value. */ + public value: string; + + /** QueryTerm fullMatch. */ + public fullMatch: boolean; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryTerm instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Condition.IQueryTerm): google.cloud.retail.v2alpha.Condition.QueryTerm; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryTerm + * @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.cloud.retail.v2alpha.Condition.QueryTerm; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryTerm + * @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.cloud.retail.v2alpha.Condition.QueryTerm; + + /** + * Verifies a QueryTerm 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 QueryTerm message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTerm + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Condition.QueryTerm; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @param message QueryTerm + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Condition.QueryTerm, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTerm to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryTerm + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TimeRange. */ + interface ITimeRange { + + /** TimeRange startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TimeRange. */ + class TimeRange implements ITimeRange { + + /** + * Constructs a new TimeRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Condition.ITimeRange); + + /** TimeRange startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new TimeRange instance using the specified properties. + * @param [properties] Properties to set + * @returns TimeRange instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Condition.ITimeRange): google.cloud.retail.v2alpha.Condition.TimeRange; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TimeRange + * @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.cloud.retail.v2alpha.Condition.TimeRange; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TimeRange + * @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.cloud.retail.v2alpha.Condition.TimeRange; + + /** + * Verifies a TimeRange 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 TimeRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TimeRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Condition.TimeRange; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @param message TimeRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Condition.TimeRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TimeRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TimeRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rule. */ + interface IRule { + + /** Rule boostAction */ + boostAction?: (google.cloud.retail.v2alpha.Rule.IBoostAction|null); + + /** Rule redirectAction */ + redirectAction?: (google.cloud.retail.v2alpha.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction */ + onewaySynonymsAction?: (google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction */ + doNotAssociateAction?: (google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction */ + replacementAction?: (google.cloud.retail.v2alpha.Rule.IReplacementAction|null); + + /** Rule ignoreAction */ + ignoreAction?: (google.cloud.retail.v2alpha.Rule.IIgnoreAction|null); + + /** Rule filterAction */ + filterAction?: (google.cloud.retail.v2alpha.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction */ + twowaySynonymsAction?: (google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction|null); + + /** Rule condition */ + condition?: (google.cloud.retail.v2alpha.ICondition|null); + } + + /** Represents a Rule. */ + class Rule implements IRule { + + /** + * Constructs a new Rule. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRule); + + /** Rule boostAction. */ + public boostAction?: (google.cloud.retail.v2alpha.Rule.IBoostAction|null); + + /** Rule redirectAction. */ + public redirectAction?: (google.cloud.retail.v2alpha.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction. */ + public onewaySynonymsAction?: (google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction. */ + public doNotAssociateAction?: (google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction. */ + public replacementAction?: (google.cloud.retail.v2alpha.Rule.IReplacementAction|null); + + /** Rule ignoreAction. */ + public ignoreAction?: (google.cloud.retail.v2alpha.Rule.IIgnoreAction|null); + + /** Rule filterAction. */ + public filterAction?: (google.cloud.retail.v2alpha.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction. */ + public twowaySynonymsAction?: (google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction|null); + + /** Rule condition. */ + public condition?: (google.cloud.retail.v2alpha.ICondition|null); + + /** Rule action. */ + public action?: ("boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"); + + /** + * Creates a new Rule instance using the specified properties. + * @param [properties] Properties to set + * @returns Rule instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRule): google.cloud.retail.v2alpha.Rule; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rule + * @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.cloud.retail.v2alpha.Rule; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rule + * @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.cloud.retail.v2alpha.Rule; + + /** + * Verifies a Rule 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 Rule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rule + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @param message Rule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Rule { + + /** Properties of a BoostAction. */ + interface IBoostAction { + + /** BoostAction boost */ + boost?: (number|null); + + /** BoostAction productsFilter */ + productsFilter?: (string|null); + } + + /** Represents a BoostAction. */ + class BoostAction implements IBoostAction { + + /** + * Constructs a new BoostAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IBoostAction); + + /** BoostAction boost. */ + public boost: number; + + /** BoostAction productsFilter. */ + public productsFilter: string; + + /** + * Creates a new BoostAction instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IBoostAction): google.cloud.retail.v2alpha.Rule.BoostAction; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostAction + * @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.cloud.retail.v2alpha.Rule.BoostAction; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostAction + * @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.cloud.retail.v2alpha.Rule.BoostAction; + + /** + * Verifies a BoostAction 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 BoostAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.BoostAction; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @param message BoostAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.BoostAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FilterAction. */ + interface IFilterAction { + + /** FilterAction filter */ + filter?: (string|null); + } + + /** Represents a FilterAction. */ + class FilterAction implements IFilterAction { + + /** + * Constructs a new FilterAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IFilterAction); + + /** FilterAction filter. */ + public filter: string; + + /** + * Creates a new FilterAction instance using the specified properties. + * @param [properties] Properties to set + * @returns FilterAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IFilterAction): google.cloud.retail.v2alpha.Rule.FilterAction; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FilterAction + * @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.cloud.retail.v2alpha.Rule.FilterAction; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FilterAction + * @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.cloud.retail.v2alpha.Rule.FilterAction; + + /** + * Verifies a FilterAction 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 FilterAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FilterAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.FilterAction; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @param message FilterAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.FilterAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FilterAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FilterAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RedirectAction. */ + interface IRedirectAction { + + /** RedirectAction redirectUri */ + redirectUri?: (string|null); + } + + /** Represents a RedirectAction. */ + class RedirectAction implements IRedirectAction { + + /** + * Constructs a new RedirectAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IRedirectAction); + + /** RedirectAction redirectUri. */ + public redirectUri: string; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @param [properties] Properties to set + * @returns RedirectAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IRedirectAction): google.cloud.retail.v2alpha.Rule.RedirectAction; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RedirectAction + * @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.cloud.retail.v2alpha.Rule.RedirectAction; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RedirectAction + * @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.cloud.retail.v2alpha.Rule.RedirectAction; + + /** + * Verifies a RedirectAction 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 RedirectAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RedirectAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.RedirectAction; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @param message RedirectAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.RedirectAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RedirectAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RedirectAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TwowaySynonymsAction. */ + interface ITwowaySynonymsAction { + + /** TwowaySynonymsAction synonyms */ + synonyms?: (string[]|null); + } + + /** Represents a TwowaySynonymsAction. */ + class TwowaySynonymsAction implements ITwowaySynonymsAction { + + /** + * Constructs a new TwowaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction); + + /** TwowaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns TwowaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction): google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2alpha.Rule.TwowaySynonymsAction; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2alpha.Rule.TwowaySynonymsAction; + + /** + * Verifies a TwowaySynonymsAction 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 TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TwowaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @param message TwowaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OnewaySynonymsAction. */ + interface IOnewaySynonymsAction { + + /** OnewaySynonymsAction queryTerms */ + queryTerms?: (string[]|null); + + /** OnewaySynonymsAction synonyms */ + synonyms?: (string[]|null); + + /** OnewaySynonymsAction onewayTerms */ + onewayTerms?: (string[]|null); + } + + /** Represents an OnewaySynonymsAction. */ + class OnewaySynonymsAction implements IOnewaySynonymsAction { + + /** + * Constructs a new OnewaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction); + + /** OnewaySynonymsAction queryTerms. */ + public queryTerms: string[]; + + /** OnewaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** OnewaySynonymsAction onewayTerms. */ + public onewayTerms: string[]; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns OnewaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction): google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2alpha.Rule.OnewaySynonymsAction; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2alpha.Rule.OnewaySynonymsAction; + + /** + * Verifies an OnewaySynonymsAction 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 OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OnewaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @param message OnewaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DoNotAssociateAction. */ + interface IDoNotAssociateAction { + + /** DoNotAssociateAction queryTerms */ + queryTerms?: (string[]|null); + + /** DoNotAssociateAction doNotAssociateTerms */ + doNotAssociateTerms?: (string[]|null); + + /** DoNotAssociateAction terms */ + terms?: (string[]|null); + } + + /** Represents a DoNotAssociateAction. */ + class DoNotAssociateAction implements IDoNotAssociateAction { + + /** + * Constructs a new DoNotAssociateAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction); + + /** DoNotAssociateAction queryTerms. */ + public queryTerms: string[]; + + /** DoNotAssociateAction doNotAssociateTerms. */ + public doNotAssociateTerms: string[]; + + /** DoNotAssociateAction terms. */ + public terms: string[]; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @param [properties] Properties to set + * @returns DoNotAssociateAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction): google.cloud.retail.v2alpha.Rule.DoNotAssociateAction; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DoNotAssociateAction + * @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.cloud.retail.v2alpha.Rule.DoNotAssociateAction; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DoNotAssociateAction + * @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.cloud.retail.v2alpha.Rule.DoNotAssociateAction; + + /** + * Verifies a DoNotAssociateAction 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 DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoNotAssociateAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.DoNotAssociateAction; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @param message DoNotAssociateAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.DoNotAssociateAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DoNotAssociateAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplacementAction. */ + interface IReplacementAction { + + /** ReplacementAction queryTerms */ + queryTerms?: (string[]|null); + + /** ReplacementAction replacementTerm */ + replacementTerm?: (string|null); + + /** ReplacementAction term */ + term?: (string|null); + } + + /** Represents a ReplacementAction. */ + class ReplacementAction implements IReplacementAction { + + /** + * Constructs a new ReplacementAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IReplacementAction); + + /** ReplacementAction queryTerms. */ + public queryTerms: string[]; + + /** ReplacementAction replacementTerm. */ + public replacementTerm: string; + + /** ReplacementAction term. */ + public term: string; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplacementAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IReplacementAction): google.cloud.retail.v2alpha.Rule.ReplacementAction; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplacementAction + * @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.cloud.retail.v2alpha.Rule.ReplacementAction; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplacementAction + * @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.cloud.retail.v2alpha.Rule.ReplacementAction; + + /** + * Verifies a ReplacementAction 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 ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplacementAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.ReplacementAction; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @param message ReplacementAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.ReplacementAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplacementAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplacementAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an IgnoreAction. */ + interface IIgnoreAction { + + /** IgnoreAction ignoreTerms */ + ignoreTerms?: (string[]|null); + } + + /** Represents an IgnoreAction. */ + class IgnoreAction implements IIgnoreAction { + + /** + * Constructs a new IgnoreAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Rule.IIgnoreAction); + + /** IgnoreAction ignoreTerms. */ + public ignoreTerms: string[]; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @param [properties] Properties to set + * @returns IgnoreAction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Rule.IIgnoreAction): google.cloud.retail.v2alpha.Rule.IgnoreAction; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IgnoreAction + * @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.cloud.retail.v2alpha.Rule.IgnoreAction; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IgnoreAction + * @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.cloud.retail.v2alpha.Rule.IgnoreAction; + + /** + * Verifies an IgnoreAction 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 IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IgnoreAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rule.IgnoreAction; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @param message IgnoreAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rule.IgnoreAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IgnoreAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IgnoreAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an Audience. */ + interface IAudience { + + /** Audience genders */ + genders?: (string[]|null); + + /** Audience ageGroups */ + ageGroups?: (string[]|null); + } + + /** Represents an Audience. */ + class Audience implements IAudience { + + /** + * Constructs a new Audience. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAudience); + + /** Audience genders. */ + public genders: string[]; + + /** Audience ageGroups. */ + public ageGroups: string[]; + + /** + * Creates a new Audience instance using the specified properties. + * @param [properties] Properties to set + * @returns Audience instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAudience): google.cloud.retail.v2alpha.Audience; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2alpha.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Audience + * @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.cloud.retail.v2alpha.Audience; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Audience + * @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.cloud.retail.v2alpha.Audience; + + /** + * Verifies an Audience 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 Audience message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Audience + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Audience; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @param message Audience + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Audience, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Audience to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Audience + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ColorInfo. */ + interface IColorInfo { + + /** ColorInfo colorFamilies */ + colorFamilies?: (string[]|null); + + /** ColorInfo colors */ + colors?: (string[]|null); + } + + /** Represents a ColorInfo. */ + class ColorInfo implements IColorInfo { + + /** + * Constructs a new ColorInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IColorInfo); + + /** ColorInfo colorFamilies. */ + public colorFamilies: string[]; + + /** ColorInfo colors. */ + public colors: string[]; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns ColorInfo instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IColorInfo): google.cloud.retail.v2alpha.ColorInfo; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ColorInfo + * @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.cloud.retail.v2alpha.ColorInfo; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ColorInfo + * @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.cloud.retail.v2alpha.ColorInfo; + + /** + * Verifies a ColorInfo 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 ColorInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ColorInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ColorInfo; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @param message ColorInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ColorInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ColorInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ColorInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CustomAttribute. */ + interface ICustomAttribute { + + /** CustomAttribute text */ + text?: (string[]|null); + + /** CustomAttribute numbers */ + numbers?: (number[]|null); + + /** CustomAttribute searchable */ + searchable?: (boolean|null); + + /** CustomAttribute indexable */ + indexable?: (boolean|null); + } + + /** Represents a CustomAttribute. */ + class CustomAttribute implements ICustomAttribute { + + /** + * Constructs a new CustomAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICustomAttribute); + + /** CustomAttribute text. */ + public text: string[]; + + /** CustomAttribute numbers. */ + public numbers: number[]; + + /** CustomAttribute searchable. */ + public searchable?: (boolean|null); + + /** CustomAttribute indexable. */ + public indexable?: (boolean|null); + + /** CustomAttribute _searchable. */ + public _searchable?: "searchable"; + + /** CustomAttribute _indexable. */ + public _indexable?: "indexable"; + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomAttribute instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICustomAttribute): google.cloud.retail.v2alpha.CustomAttribute; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2alpha.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomAttribute + * @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.cloud.retail.v2alpha.CustomAttribute; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomAttribute + * @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.cloud.retail.v2alpha.CustomAttribute; + + /** + * Verifies a CustomAttribute 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 CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CustomAttribute; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @param message CustomAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CustomAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FulfillmentInfo. */ + interface IFulfillmentInfo { + + /** FulfillmentInfo type */ + type?: (string|null); + + /** FulfillmentInfo placeIds */ + placeIds?: (string[]|null); + } + + /** Represents a FulfillmentInfo. */ + class FulfillmentInfo implements IFulfillmentInfo { + + /** + * Constructs a new FulfillmentInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IFulfillmentInfo); + + /** FulfillmentInfo type. */ + public type: string; + + /** FulfillmentInfo placeIds. */ + public placeIds: string[]; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns FulfillmentInfo instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IFulfillmentInfo): google.cloud.retail.v2alpha.FulfillmentInfo; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FulfillmentInfo + * @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.cloud.retail.v2alpha.FulfillmentInfo; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FulfillmentInfo + * @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.cloud.retail.v2alpha.FulfillmentInfo; + + /** + * Verifies a FulfillmentInfo 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 FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FulfillmentInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.FulfillmentInfo; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @param message FulfillmentInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.FulfillmentInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FulfillmentInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FulfillmentInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Image. */ + interface IImage { + + /** Image uri */ + uri?: (string|null); + + /** Image height */ + height?: (number|null); + + /** Image width */ + width?: (number|null); + } + + /** Represents an Image. */ + class Image implements IImage { + + /** + * Constructs a new Image. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImage); + + /** Image uri. */ + public uri: string; + + /** Image height. */ + public height: number; + + /** Image width. */ + public width: number; + + /** + * Creates a new Image instance using the specified properties. + * @param [properties] Properties to set + * @returns Image instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImage): google.cloud.retail.v2alpha.Image; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2alpha.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Image message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Image + * @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.cloud.retail.v2alpha.Image; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Image + * @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.cloud.retail.v2alpha.Image; + + /** + * Verifies an Image 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 Image message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Image + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Image; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @param message Image + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Image, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Image to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Image + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Interval. */ + interface IInterval { + + /** Interval minimum */ + minimum?: (number|null); + + /** Interval exclusiveMinimum */ + exclusiveMinimum?: (number|null); + + /** Interval maximum */ + maximum?: (number|null); + + /** Interval exclusiveMaximum */ + exclusiveMaximum?: (number|null); + } + + /** Represents an Interval. */ + class Interval implements IInterval { + + /** + * Constructs a new Interval. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IInterval); + + /** Interval minimum. */ + public minimum?: (number|null); + + /** Interval exclusiveMinimum. */ + public exclusiveMinimum?: (number|null); + + /** Interval maximum. */ + public maximum?: (number|null); + + /** Interval exclusiveMaximum. */ + public exclusiveMaximum?: (number|null); + + /** Interval min. */ + public min?: ("minimum"|"exclusiveMinimum"); + + /** Interval max. */ + public max?: ("maximum"|"exclusiveMaximum"); + + /** + * Creates a new Interval instance using the specified properties. + * @param [properties] Properties to set + * @returns Interval instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IInterval): google.cloud.retail.v2alpha.Interval; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2alpha.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Interval + * @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.cloud.retail.v2alpha.Interval; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Interval + * @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.cloud.retail.v2alpha.Interval; + + /** + * Verifies an Interval 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 Interval message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Interval + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Interval; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @param message Interval + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Interval, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Interval to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Interval + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PriceInfo. */ + interface IPriceInfo { + + /** PriceInfo currencyCode */ + currencyCode?: (string|null); + + /** PriceInfo price */ + price?: (number|null); + + /** PriceInfo originalPrice */ + originalPrice?: (number|null); + + /** PriceInfo cost */ + cost?: (number|null); + + /** PriceInfo priceEffectiveTime */ + priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime */ + priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange */ + priceRange?: (google.cloud.retail.v2alpha.PriceInfo.IPriceRange|null); + } + + /** Represents a PriceInfo. */ + class PriceInfo implements IPriceInfo { + + /** + * Constructs a new PriceInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPriceInfo); + + /** PriceInfo currencyCode. */ + public currencyCode: string; + + /** PriceInfo price. */ + public price: number; + + /** PriceInfo originalPrice. */ + public originalPrice: number; + + /** PriceInfo cost. */ + public cost: number; + + /** PriceInfo priceEffectiveTime. */ + public priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime. */ + public priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange. */ + public priceRange?: (google.cloud.retail.v2alpha.PriceInfo.IPriceRange|null); + + /** + * Creates a new PriceInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceInfo instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPriceInfo): google.cloud.retail.v2alpha.PriceInfo; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceInfo + * @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.cloud.retail.v2alpha.PriceInfo; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceInfo + * @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.cloud.retail.v2alpha.PriceInfo; + + /** + * Verifies a PriceInfo 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 PriceInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PriceInfo; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @param message PriceInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PriceInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PriceInfo { + + /** Properties of a PriceRange. */ + interface IPriceRange { + + /** PriceRange price */ + price?: (google.cloud.retail.v2alpha.IInterval|null); + + /** PriceRange originalPrice */ + originalPrice?: (google.cloud.retail.v2alpha.IInterval|null); + } + + /** Represents a PriceRange. */ + class PriceRange implements IPriceRange { + + /** + * Constructs a new PriceRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.PriceInfo.IPriceRange); + + /** PriceRange price. */ + public price?: (google.cloud.retail.v2alpha.IInterval|null); + + /** PriceRange originalPrice. */ + public originalPrice?: (google.cloud.retail.v2alpha.IInterval|null); + + /** + * Creates a new PriceRange instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceRange instance + */ + public static create(properties?: google.cloud.retail.v2alpha.PriceInfo.IPriceRange): google.cloud.retail.v2alpha.PriceInfo.PriceRange; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceRange + * @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.cloud.retail.v2alpha.PriceInfo.PriceRange; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceRange + * @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.cloud.retail.v2alpha.PriceInfo.PriceRange; + + /** + * Verifies a PriceRange 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 PriceRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PriceInfo.PriceRange; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @param message PriceRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PriceInfo.PriceRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rating. */ + interface IRating { + + /** Rating ratingCount */ + ratingCount?: (number|null); + + /** Rating averageRating */ + averageRating?: (number|null); + + /** Rating ratingHistogram */ + ratingHistogram?: (number[]|null); + } + + /** Represents a Rating. */ + class Rating implements IRating { + + /** + * Constructs a new Rating. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRating); + + /** Rating ratingCount. */ + public ratingCount: number; + + /** Rating averageRating. */ + public averageRating: number; + + /** Rating ratingHistogram. */ + public ratingHistogram: number[]; + + /** + * Creates a new Rating instance using the specified properties. + * @param [properties] Properties to set + * @returns Rating instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRating): google.cloud.retail.v2alpha.Rating; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2alpha.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rating + * @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.cloud.retail.v2alpha.Rating; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rating + * @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.cloud.retail.v2alpha.Rating; + + /** + * Verifies a Rating 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 Rating message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rating + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Rating; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @param message Rating + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Rating, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rating to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rating + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserInfo. */ + interface IUserInfo { + + /** UserInfo userId */ + userId?: (string|null); + + /** UserInfo ipAddress */ + ipAddress?: (string|null); + + /** UserInfo userAgent */ + userAgent?: (string|null); + + /** UserInfo directUserRequest */ + directUserRequest?: (boolean|null); + } + + /** Represents a UserInfo. */ + class UserInfo implements IUserInfo { + + /** + * Constructs a new UserInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUserInfo); + + /** UserInfo userId. */ + public userId: string; + + /** UserInfo ipAddress. */ + public ipAddress: string; + + /** UserInfo userAgent. */ + public userAgent: string; + + /** UserInfo directUserRequest. */ + public directUserRequest: boolean; + + /** + * Creates a new UserInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns UserInfo instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUserInfo): google.cloud.retail.v2alpha.UserInfo; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserInfo + * @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.cloud.retail.v2alpha.UserInfo; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserInfo + * @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.cloud.retail.v2alpha.UserInfo; + + /** + * Verifies a UserInfo 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 UserInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UserInfo; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @param message UserInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UserInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a LocalInventory. */ + interface ILocalInventory { + + /** LocalInventory placeId */ + placeId?: (string|null); + + /** LocalInventory priceInfo */ + priceInfo?: (google.cloud.retail.v2alpha.IPriceInfo|null); + + /** LocalInventory attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }|null); + + /** LocalInventory fulfillmentTypes */ + fulfillmentTypes?: (string[]|null); + } + + /** Represents a LocalInventory. */ + class LocalInventory implements ILocalInventory { + + /** + * Constructs a new LocalInventory. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ILocalInventory); + + /** LocalInventory placeId. */ + public placeId: string; + + /** LocalInventory priceInfo. */ + public priceInfo?: (google.cloud.retail.v2alpha.IPriceInfo|null); + + /** LocalInventory attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }; + + /** LocalInventory fulfillmentTypes. */ + public fulfillmentTypes: string[]; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @param [properties] Properties to set + * @returns LocalInventory instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ILocalInventory): google.cloud.retail.v2alpha.LocalInventory; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2alpha.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LocalInventory + * @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.cloud.retail.v2alpha.LocalInventory; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LocalInventory + * @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.cloud.retail.v2alpha.LocalInventory; + + /** + * Verifies a LocalInventory 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 LocalInventory message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocalInventory + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.LocalInventory; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @param message LocalInventory + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.LocalInventory, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocalInventory to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LocalInventory + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GcsSource. */ + interface IGcsSource { + + /** GcsSource inputUris */ + inputUris?: (string[]|null); + + /** GcsSource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a GcsSource. */ + class GcsSource implements IGcsSource { + + /** + * Constructs a new GcsSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGcsSource); + + /** GcsSource inputUris. */ + public inputUris: string[]; + + /** GcsSource dataSchema. */ + public dataSchema: string; + + /** + * Creates a new GcsSource instance using the specified properties. + * @param [properties] Properties to set + * @returns GcsSource instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGcsSource): google.cloud.retail.v2alpha.GcsSource; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2alpha.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GcsSource + * @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.cloud.retail.v2alpha.GcsSource; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GcsSource + * @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.cloud.retail.v2alpha.GcsSource; + + /** + * Verifies a GcsSource 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 GcsSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GcsSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GcsSource; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @param message GcsSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GcsSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GcsSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GcsSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BigQuerySource. */ + interface IBigQuerySource { + + /** BigQuerySource partitionDate */ + partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId */ + projectId?: (string|null); + + /** BigQuerySource datasetId */ + datasetId?: (string|null); + + /** BigQuerySource tableId */ + tableId?: (string|null); + + /** BigQuerySource gcsStagingDir */ + gcsStagingDir?: (string|null); + + /** BigQuerySource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a BigQuerySource. */ + class BigQuerySource implements IBigQuerySource { + + /** + * Constructs a new BigQuerySource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IBigQuerySource); + + /** BigQuerySource partitionDate. */ + public partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId. */ + public projectId: string; + + /** BigQuerySource datasetId. */ + public datasetId: string; + + /** BigQuerySource tableId. */ + public tableId: string; + + /** BigQuerySource gcsStagingDir. */ + public gcsStagingDir: string; + + /** BigQuerySource dataSchema. */ + public dataSchema: string; + + /** BigQuerySource partition. */ + public partition?: "partitionDate"; + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQuerySource instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IBigQuerySource): google.cloud.retail.v2alpha.BigQuerySource; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2alpha.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQuerySource + * @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.cloud.retail.v2alpha.BigQuerySource; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQuerySource + * @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.cloud.retail.v2alpha.BigQuerySource; + + /** + * Verifies a BigQuerySource 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 BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQuerySource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.BigQuerySource; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @param message BigQuerySource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.BigQuerySource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQuerySource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BigQuerySource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInlineSource. */ + interface IProductInlineSource { + + /** ProductInlineSource products */ + products?: (google.cloud.retail.v2alpha.IProduct[]|null); + } + + /** Represents a ProductInlineSource. */ + class ProductInlineSource implements IProductInlineSource { + + /** + * Constructs a new ProductInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IProductInlineSource); + + /** ProductInlineSource products. */ + public products: google.cloud.retail.v2alpha.IProduct[]; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IProductInlineSource): google.cloud.retail.v2alpha.ProductInlineSource; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInlineSource + * @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.cloud.retail.v2alpha.ProductInlineSource; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInlineSource + * @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.cloud.retail.v2alpha.ProductInlineSource; + + /** + * Verifies a ProductInlineSource 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 ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ProductInlineSource; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @param message ProductInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ProductInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInlineSource. */ + interface IUserEventInlineSource { + + /** UserEventInlineSource userEvents */ + userEvents?: (google.cloud.retail.v2alpha.IUserEvent[]|null); + } + + /** Represents a UserEventInlineSource. */ + class UserEventInlineSource implements IUserEventInlineSource { + + /** + * Constructs a new UserEventInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUserEventInlineSource); + + /** UserEventInlineSource userEvents. */ + public userEvents: google.cloud.retail.v2alpha.IUserEvent[]; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUserEventInlineSource): google.cloud.retail.v2alpha.UserEventInlineSource; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInlineSource + * @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.cloud.retail.v2alpha.UserEventInlineSource; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInlineSource + * @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.cloud.retail.v2alpha.UserEventInlineSource; + + /** + * Verifies a UserEventInlineSource 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 UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UserEventInlineSource; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @param message UserEventInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UserEventInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportErrorsConfig. */ + interface IImportErrorsConfig { + + /** ImportErrorsConfig gcsPrefix */ + gcsPrefix?: (string|null); + } + + /** Represents an ImportErrorsConfig. */ + class ImportErrorsConfig implements IImportErrorsConfig { + + /** + * Constructs a new ImportErrorsConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportErrorsConfig); + + /** ImportErrorsConfig gcsPrefix. */ + public gcsPrefix?: (string|null); + + /** ImportErrorsConfig destination. */ + public destination?: "gcsPrefix"; + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportErrorsConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportErrorsConfig): google.cloud.retail.v2alpha.ImportErrorsConfig; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportErrorsConfig + * @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.cloud.retail.v2alpha.ImportErrorsConfig; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportErrorsConfig + * @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.cloud.retail.v2alpha.ImportErrorsConfig; + + /** + * Verifies an ImportErrorsConfig 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 ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportErrorsConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportErrorsConfig; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @param message ImportErrorsConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportErrorsConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportErrorsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsRequest. */ + interface IImportProductsRequest { + + /** ImportProductsRequest parent */ + parent?: (string|null); + + /** ImportProductsRequest requestId */ + requestId?: (string|null); + + /** ImportProductsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2alpha.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode */ + reconciliationMode?: (google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode|null); + + /** ImportProductsRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + + /** ImportProductsRequest skipDefaultBranchProtection */ + skipDefaultBranchProtection?: (boolean|null); + } + + /** Represents an ImportProductsRequest. */ + class ImportProductsRequest implements IImportProductsRequest { + + /** + * Constructs a new ImportProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportProductsRequest); + + /** ImportProductsRequest parent. */ + public parent: string; + + /** ImportProductsRequest requestId. */ + public requestId: string; + + /** ImportProductsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2alpha.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode. */ + public reconciliationMode: (google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode); + + /** ImportProductsRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** ImportProductsRequest skipDefaultBranchProtection. */ + public skipDefaultBranchProtection: boolean; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportProductsRequest): google.cloud.retail.v2alpha.ImportProductsRequest; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsRequest + * @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.cloud.retail.v2alpha.ImportProductsRequest; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsRequest + * @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.cloud.retail.v2alpha.ImportProductsRequest; + + /** + * Verifies an ImportProductsRequest 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 ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportProductsRequest; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @param message ImportProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ImportProductsRequest { + + /** ReconciliationMode enum. */ + enum ReconciliationMode { + RECONCILIATION_MODE_UNSPECIFIED = 0, + INCREMENTAL = 1, + FULL = 2 + } + } + + /** Properties of an ImportUserEventsRequest. */ + interface IImportUserEventsRequest { + + /** ImportUserEventsRequest parent */ + parent?: (string|null); + + /** ImportUserEventsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2alpha.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + } + + /** Represents an ImportUserEventsRequest. */ + class ImportUserEventsRequest implements IImportUserEventsRequest { + + /** + * Constructs a new ImportUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportUserEventsRequest); + + /** ImportUserEventsRequest parent. */ + public parent: string; + + /** ImportUserEventsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2alpha.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportUserEventsRequest): google.cloud.retail.v2alpha.ImportUserEventsRequest; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2alpha.ImportUserEventsRequest; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2alpha.ImportUserEventsRequest; + + /** + * Verifies an ImportUserEventsRequest 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 ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportUserEventsRequest; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @param message ImportUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataRequest. */ + interface IImportCompletionDataRequest { + + /** ImportCompletionDataRequest parent */ + parent?: (string|null); + + /** ImportCompletionDataRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportCompletionDataRequest. */ + class ImportCompletionDataRequest implements IImportCompletionDataRequest { + + /** + * Constructs a new ImportCompletionDataRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportCompletionDataRequest); + + /** ImportCompletionDataRequest parent. */ + public parent: string; + + /** ImportCompletionDataRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2alpha.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportCompletionDataRequest): google.cloud.retail.v2alpha.ImportCompletionDataRequest; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2alpha.ImportCompletionDataRequest; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2alpha.ImportCompletionDataRequest; + + /** + * Verifies an ImportCompletionDataRequest 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 ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportCompletionDataRequest; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @param message ImportCompletionDataRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportCompletionDataRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInputConfig. */ + interface IProductInputConfig { + + /** ProductInputConfig productInlineSource */ + productInlineSource?: (google.cloud.retail.v2alpha.IProductInlineSource|null); + + /** ProductInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2alpha.IGcsSource|null); + + /** ProductInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + } + + /** Represents a ProductInputConfig. */ + class ProductInputConfig implements IProductInputConfig { + + /** + * Constructs a new ProductInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IProductInputConfig); + + /** ProductInputConfig productInlineSource. */ + public productInlineSource?: (google.cloud.retail.v2alpha.IProductInlineSource|null); + + /** ProductInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2alpha.IGcsSource|null); + + /** ProductInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + + /** ProductInputConfig source. */ + public source?: ("productInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IProductInputConfig): google.cloud.retail.v2alpha.ProductInputConfig; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInputConfig + * @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.cloud.retail.v2alpha.ProductInputConfig; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInputConfig + * @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.cloud.retail.v2alpha.ProductInputConfig; + + /** + * Verifies a ProductInputConfig 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 ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ProductInputConfig; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @param message ProductInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ProductInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInputConfig. */ + interface IUserEventInputConfig { + + /** UserEventInputConfig userEventInlineSource */ + userEventInlineSource?: (google.cloud.retail.v2alpha.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2alpha.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + } + + /** Represents a UserEventInputConfig. */ + class UserEventInputConfig implements IUserEventInputConfig { + + /** + * Constructs a new UserEventInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUserEventInputConfig); + + /** UserEventInputConfig userEventInlineSource. */ + public userEventInlineSource?: (google.cloud.retail.v2alpha.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2alpha.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + + /** UserEventInputConfig source. */ + public source?: ("userEventInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUserEventInputConfig): google.cloud.retail.v2alpha.UserEventInputConfig; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInputConfig + * @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.cloud.retail.v2alpha.UserEventInputConfig; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInputConfig + * @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.cloud.retail.v2alpha.UserEventInputConfig; + + /** + * Verifies a UserEventInputConfig 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 UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UserEventInputConfig; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @param message UserEventInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UserEventInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDataInputConfig. */ + interface ICompletionDataInputConfig { + + /** CompletionDataInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + } + + /** Represents a CompletionDataInputConfig. */ + class CompletionDataInputConfig implements ICompletionDataInputConfig { + + /** + * Constructs a new CompletionDataInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICompletionDataInputConfig); + + /** CompletionDataInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2alpha.IBigQuerySource|null); + + /** CompletionDataInputConfig source. */ + public source?: "bigQuerySource"; + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDataInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICompletionDataInputConfig): google.cloud.retail.v2alpha.CompletionDataInputConfig; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2alpha.CompletionDataInputConfig; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2alpha.CompletionDataInputConfig; + + /** + * Verifies a CompletionDataInputConfig 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 CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDataInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompletionDataInputConfig; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @param message CompletionDataInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompletionDataInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportMetadata. */ + interface IImportMetadata { + + /** ImportMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount */ + successCount?: (number|Long|string|null); + + /** ImportMetadata failureCount */ + failureCount?: (number|Long|string|null); + + /** ImportMetadata requestId */ + requestId?: (string|null); + + /** ImportMetadata notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportMetadata. */ + class ImportMetadata implements IImportMetadata { + + /** + * Constructs a new ImportMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportMetadata); + + /** ImportMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount. */ + public successCount: (number|Long|string); + + /** ImportMetadata failureCount. */ + public failureCount: (number|Long|string); + + /** ImportMetadata requestId. */ + public requestId: string; + + /** ImportMetadata notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportMetadata): google.cloud.retail.v2alpha.ImportMetadata; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportMetadata + * @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.cloud.retail.v2alpha.ImportMetadata; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportMetadata + * @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.cloud.retail.v2alpha.ImportMetadata; + + /** + * Verifies an ImportMetadata 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 ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportMetadata; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @param message ImportMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsResponse. */ + interface IImportProductsResponse { + + /** ImportProductsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportProductsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + } + + /** Represents an ImportProductsResponse. */ + class ImportProductsResponse implements IImportProductsResponse { + + /** + * Constructs a new ImportProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportProductsResponse); + + /** ImportProductsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportProductsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportProductsResponse): google.cloud.retail.v2alpha.ImportProductsResponse; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsResponse + * @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.cloud.retail.v2alpha.ImportProductsResponse; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsResponse + * @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.cloud.retail.v2alpha.ImportProductsResponse; + + /** + * Verifies an ImportProductsResponse 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 ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportProductsResponse; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @param message ImportProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportUserEventsResponse. */ + interface IImportUserEventsResponse { + + /** ImportUserEventsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportUserEventsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary */ + importSummary?: (google.cloud.retail.v2alpha.IUserEventImportSummary|null); + } + + /** Represents an ImportUserEventsResponse. */ + class ImportUserEventsResponse implements IImportUserEventsResponse { + + /** + * Constructs a new ImportUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportUserEventsResponse); + + /** ImportUserEventsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportUserEventsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary. */ + public importSummary?: (google.cloud.retail.v2alpha.IUserEventImportSummary|null); + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportUserEventsResponse): google.cloud.retail.v2alpha.ImportUserEventsResponse; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2alpha.ImportUserEventsResponse; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2alpha.ImportUserEventsResponse; + + /** + * Verifies an ImportUserEventsResponse 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 ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportUserEventsResponse; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @param message ImportUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventImportSummary. */ + interface IUserEventImportSummary { + + /** UserEventImportSummary joinedEventsCount */ + joinedEventsCount?: (number|Long|string|null); + + /** UserEventImportSummary unjoinedEventsCount */ + unjoinedEventsCount?: (number|Long|string|null); + } + + /** Represents a UserEventImportSummary. */ + class UserEventImportSummary implements IUserEventImportSummary { + + /** + * Constructs a new UserEventImportSummary. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUserEventImportSummary); + + /** UserEventImportSummary joinedEventsCount. */ + public joinedEventsCount: (number|Long|string); + + /** UserEventImportSummary unjoinedEventsCount. */ + public unjoinedEventsCount: (number|Long|string); + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventImportSummary instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUserEventImportSummary): google.cloud.retail.v2alpha.UserEventImportSummary; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventImportSummary + * @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.cloud.retail.v2alpha.UserEventImportSummary; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventImportSummary + * @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.cloud.retail.v2alpha.UserEventImportSummary; + + /** + * Verifies a UserEventImportSummary 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 UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventImportSummary + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UserEventImportSummary; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @param message UserEventImportSummary + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UserEventImportSummary, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventImportSummary to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventImportSummary + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataResponse. */ + interface IImportCompletionDataResponse { + + /** ImportCompletionDataResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + } + + /** Represents an ImportCompletionDataResponse. */ + class ImportCompletionDataResponse implements IImportCompletionDataResponse { + + /** + * Constructs a new ImportCompletionDataResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IImportCompletionDataResponse); + + /** ImportCompletionDataResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IImportCompletionDataResponse): google.cloud.retail.v2alpha.ImportCompletionDataResponse; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2alpha.ImportCompletionDataResponse; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2alpha.ImportCompletionDataResponse; + + /** + * Verifies an ImportCompletionDataResponse 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 ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ImportCompletionDataResponse; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @param message ImportCompletionDataResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ImportCompletionDataResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Product. */ + interface IProduct { + + /** Product expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl */ + ttl?: (google.protobuf.IDuration|null); + + /** Product name */ + name?: (string|null); + + /** Product id */ + id?: (string|null); + + /** Product type */ + type?: (google.cloud.retail.v2alpha.Product.Type|keyof typeof google.cloud.retail.v2alpha.Product.Type|null); + + /** Product primaryProductId */ + primaryProductId?: (string|null); + + /** Product collectionMemberIds */ + collectionMemberIds?: (string[]|null); + + /** Product gtin */ + gtin?: (string|null); + + /** Product categories */ + categories?: (string[]|null); + + /** Product title */ + title?: (string|null); + + /** Product brands */ + brands?: (string[]|null); + + /** Product description */ + description?: (string|null); + + /** Product languageCode */ + languageCode?: (string|null); + + /** Product attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }|null); + + /** Product tags */ + tags?: (string[]|null); + + /** Product priceInfo */ + priceInfo?: (google.cloud.retail.v2alpha.IPriceInfo|null); + + /** Product rating */ + rating?: (google.cloud.retail.v2alpha.IRating|null); + + /** Product availableTime */ + availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability */ + availability?: (google.cloud.retail.v2alpha.Product.Availability|keyof typeof google.cloud.retail.v2alpha.Product.Availability|null); + + /** Product availableQuantity */ + availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo */ + fulfillmentInfo?: (google.cloud.retail.v2alpha.IFulfillmentInfo[]|null); + + /** Product uri */ + uri?: (string|null); + + /** Product images */ + images?: (google.cloud.retail.v2alpha.IImage[]|null); + + /** Product audience */ + audience?: (google.cloud.retail.v2alpha.IAudience|null); + + /** Product colorInfo */ + colorInfo?: (google.cloud.retail.v2alpha.IColorInfo|null); + + /** Product sizes */ + sizes?: (string[]|null); + + /** Product materials */ + materials?: (string[]|null); + + /** Product patterns */ + patterns?: (string[]|null); + + /** Product conditions */ + conditions?: (string[]|null); + + /** Product promotions */ + promotions?: (google.cloud.retail.v2alpha.IPromotion[]|null); + + /** Product publishTime */ + publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields */ + retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants */ + variants?: (google.cloud.retail.v2alpha.IProduct[]|null); + } + + /** Represents a Product. */ + class Product implements IProduct { + + /** + * Constructs a new Product. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IProduct); + + /** Product expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl. */ + public ttl?: (google.protobuf.IDuration|null); + + /** Product name. */ + public name: string; + + /** Product id. */ + public id: string; + + /** Product type. */ + public type: (google.cloud.retail.v2alpha.Product.Type|keyof typeof google.cloud.retail.v2alpha.Product.Type); + + /** Product primaryProductId. */ + public primaryProductId: string; + + /** Product collectionMemberIds. */ + public collectionMemberIds: string[]; + + /** Product gtin. */ + public gtin: string; + + /** Product categories. */ + public categories: string[]; + + /** Product title. */ + public title: string; + + /** Product brands. */ + public brands: string[]; + + /** Product description. */ + public description: string; + + /** Product languageCode. */ + public languageCode: string; + + /** Product attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }; + + /** Product tags. */ + public tags: string[]; + + /** Product priceInfo. */ + public priceInfo?: (google.cloud.retail.v2alpha.IPriceInfo|null); + + /** Product rating. */ + public rating?: (google.cloud.retail.v2alpha.IRating|null); + + /** Product availableTime. */ + public availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability. */ + public availability: (google.cloud.retail.v2alpha.Product.Availability|keyof typeof google.cloud.retail.v2alpha.Product.Availability); + + /** Product availableQuantity. */ + public availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo. */ + public fulfillmentInfo: google.cloud.retail.v2alpha.IFulfillmentInfo[]; + + /** Product uri. */ + public uri: string; + + /** Product images. */ + public images: google.cloud.retail.v2alpha.IImage[]; + + /** Product audience. */ + public audience?: (google.cloud.retail.v2alpha.IAudience|null); + + /** Product colorInfo. */ + public colorInfo?: (google.cloud.retail.v2alpha.IColorInfo|null); + + /** Product sizes. */ + public sizes: string[]; + + /** Product materials. */ + public materials: string[]; + + /** Product patterns. */ + public patterns: string[]; + + /** Product conditions. */ + public conditions: string[]; + + /** Product promotions. */ + public promotions: google.cloud.retail.v2alpha.IPromotion[]; + + /** Product publishTime. */ + public publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields. */ + public retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants. */ + public variants: google.cloud.retail.v2alpha.IProduct[]; + + /** Product expiration. */ + public expiration?: ("expireTime"|"ttl"); + + /** + * Creates a new Product instance using the specified properties. + * @param [properties] Properties to set + * @returns Product instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IProduct): google.cloud.retail.v2alpha.Product; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2alpha.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Product message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Product + * @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.cloud.retail.v2alpha.Product; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Product + * @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.cloud.retail.v2alpha.Product; + + /** + * Verifies a Product 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 Product message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Product + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Product; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @param message Product + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Product, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Product to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Product + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Product { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + PRIMARY = 1, + VARIANT = 2, + COLLECTION = 3 + } + + /** Availability enum. */ + enum Availability { + AVAILABILITY_UNSPECIFIED = 0, + IN_STOCK = 1, + OUT_OF_STOCK = 2, + PREORDER = 3, + BACKORDER = 4 + } + } + + /** Properties of a Promotion. */ + interface IPromotion { + + /** Promotion promotionId */ + promotionId?: (string|null); + } + + /** Represents a Promotion. */ + class Promotion implements IPromotion { + + /** + * Constructs a new Promotion. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPromotion); + + /** Promotion promotionId. */ + public promotionId: string; + + /** + * Creates a new Promotion instance using the specified properties. + * @param [properties] Properties to set + * @returns Promotion instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPromotion): google.cloud.retail.v2alpha.Promotion; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2alpha.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Promotion + * @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.cloud.retail.v2alpha.Promotion; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Promotion + * @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.cloud.retail.v2alpha.Promotion; + + /** + * Verifies a Promotion 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 Promotion message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Promotion + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Promotion; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @param message Promotion + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Promotion, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Promotion to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Promotion + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEvent. */ + interface IUserEvent { + + /** UserEvent eventType */ + eventType?: (string|null); + + /** UserEvent visitorId */ + visitorId?: (string|null); + + /** UserEvent sessionId */ + sessionId?: (string|null); + + /** UserEvent eventTime */ + eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds */ + experimentIds?: (string[]|null); + + /** UserEvent attributionToken */ + attributionToken?: (string|null); + + /** UserEvent productDetails */ + productDetails?: (google.cloud.retail.v2alpha.IProductDetail[]|null); + + /** UserEvent completionDetail */ + completionDetail?: (google.cloud.retail.v2alpha.ICompletionDetail|null); + + /** UserEvent attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }|null); + + /** UserEvent cartId */ + cartId?: (string|null); + + /** UserEvent purchaseTransaction */ + purchaseTransaction?: (google.cloud.retail.v2alpha.IPurchaseTransaction|null); + + /** UserEvent searchQuery */ + searchQuery?: (string|null); + + /** UserEvent filter */ + filter?: (string|null); + + /** UserEvent orderBy */ + orderBy?: (string|null); + + /** UserEvent offset */ + offset?: (number|null); + + /** UserEvent pageCategories */ + pageCategories?: (string[]|null); + + /** UserEvent userInfo */ + userInfo?: (google.cloud.retail.v2alpha.IUserInfo|null); + + /** UserEvent uri */ + uri?: (string|null); + + /** UserEvent referrerUri */ + referrerUri?: (string|null); + + /** UserEvent pageViewId */ + pageViewId?: (string|null); + } + + /** Represents a UserEvent. */ + class UserEvent implements IUserEvent { + + /** + * Constructs a new UserEvent. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUserEvent); + + /** UserEvent eventType. */ + public eventType: string; + + /** UserEvent visitorId. */ + public visitorId: string; + + /** UserEvent sessionId. */ + public sessionId: string; + + /** UserEvent eventTime. */ + public eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds. */ + public experimentIds: string[]; + + /** UserEvent attributionToken. */ + public attributionToken: string; + + /** UserEvent productDetails. */ + public productDetails: google.cloud.retail.v2alpha.IProductDetail[]; + + /** UserEvent completionDetail. */ + public completionDetail?: (google.cloud.retail.v2alpha.ICompletionDetail|null); + + /** UserEvent attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }; + + /** UserEvent cartId. */ + public cartId: string; + + /** UserEvent purchaseTransaction. */ + public purchaseTransaction?: (google.cloud.retail.v2alpha.IPurchaseTransaction|null); + + /** UserEvent searchQuery. */ + public searchQuery: string; + + /** UserEvent filter. */ + public filter: string; + + /** UserEvent orderBy. */ + public orderBy: string; + + /** UserEvent offset. */ + public offset: number; + + /** UserEvent pageCategories. */ + public pageCategories: string[]; + + /** UserEvent userInfo. */ + public userInfo?: (google.cloud.retail.v2alpha.IUserInfo|null); + + /** UserEvent uri. */ + public uri: string; + + /** UserEvent referrerUri. */ + public referrerUri: string; + + /** UserEvent pageViewId. */ + public pageViewId: string; + + /** + * Creates a new UserEvent instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEvent instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUserEvent): google.cloud.retail.v2alpha.UserEvent; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEvent + * @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.cloud.retail.v2alpha.UserEvent; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEvent + * @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.cloud.retail.v2alpha.UserEvent; + + /** + * Verifies a UserEvent 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 UserEvent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEvent + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UserEvent; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @param message UserEvent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UserEvent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEvent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEvent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductDetail. */ + interface IProductDetail { + + /** ProductDetail product */ + product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** ProductDetail quantity */ + quantity?: (google.protobuf.IInt32Value|null); + } + + /** Represents a ProductDetail. */ + class ProductDetail implements IProductDetail { + + /** + * Constructs a new ProductDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IProductDetail); + + /** ProductDetail product. */ + public product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** ProductDetail quantity. */ + public quantity?: (google.protobuf.IInt32Value|null); + + /** + * Creates a new ProductDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductDetail instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IProductDetail): google.cloud.retail.v2alpha.ProductDetail; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductDetail + * @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.cloud.retail.v2alpha.ProductDetail; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductDetail + * @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.cloud.retail.v2alpha.ProductDetail; + + /** + * Verifies a ProductDetail 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 ProductDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ProductDetail; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @param message ProductDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ProductDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDetail. */ + interface ICompletionDetail { + + /** CompletionDetail completionAttributionToken */ + completionAttributionToken?: (string|null); + + /** CompletionDetail selectedSuggestion */ + selectedSuggestion?: (string|null); + + /** CompletionDetail selectedPosition */ + selectedPosition?: (number|null); + } + + /** Represents a CompletionDetail. */ + class CompletionDetail implements ICompletionDetail { + + /** + * Constructs a new CompletionDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICompletionDetail); + + /** CompletionDetail completionAttributionToken. */ + public completionAttributionToken: string; + + /** CompletionDetail selectedSuggestion. */ + public selectedSuggestion: string; + + /** CompletionDetail selectedPosition. */ + public selectedPosition: number; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDetail instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICompletionDetail): google.cloud.retail.v2alpha.CompletionDetail; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDetail + * @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.cloud.retail.v2alpha.CompletionDetail; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDetail + * @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.cloud.retail.v2alpha.CompletionDetail; + + /** + * Verifies a CompletionDetail 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 CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompletionDetail; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @param message CompletionDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompletionDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurchaseTransaction. */ + interface IPurchaseTransaction { + + /** PurchaseTransaction id */ + id?: (string|null); + + /** PurchaseTransaction revenue */ + revenue?: (number|null); + + /** PurchaseTransaction tax */ + tax?: (number|null); + + /** PurchaseTransaction cost */ + cost?: (number|null); + + /** PurchaseTransaction currencyCode */ + currencyCode?: (string|null); + } + + /** Represents a PurchaseTransaction. */ + class PurchaseTransaction implements IPurchaseTransaction { + + /** + * Constructs a new PurchaseTransaction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurchaseTransaction); + + /** PurchaseTransaction id. */ + public id: string; + + /** PurchaseTransaction revenue. */ + public revenue: number; + + /** PurchaseTransaction tax. */ + public tax: number; + + /** PurchaseTransaction cost. */ + public cost: number; + + /** PurchaseTransaction currencyCode. */ + public currencyCode: string; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @param [properties] Properties to set + * @returns PurchaseTransaction instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurchaseTransaction): google.cloud.retail.v2alpha.PurchaseTransaction; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2alpha.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurchaseTransaction + * @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.cloud.retail.v2alpha.PurchaseTransaction; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurchaseTransaction + * @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.cloud.retail.v2alpha.PurchaseTransaction; + + /** + * Verifies a PurchaseTransaction 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 PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurchaseTransaction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurchaseTransaction; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @param message PurchaseTransaction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurchaseTransaction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurchaseTransaction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurchaseTransaction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CatalogService */ + class CatalogService extends $protobuf.rpc.Service { + + /** + * Constructs a new CatalogService 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 CatalogService 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): CatalogService; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCatalogsResponse + */ + public listCatalogs(request: google.cloud.retail.v2alpha.IListCatalogsRequest, callback: google.cloud.retail.v2alpha.CatalogService.ListCatalogsCallback): void; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @returns Promise + */ + public listCatalogs(request: google.cloud.retail.v2alpha.IListCatalogsRequest): Promise; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Catalog + */ + public updateCatalog(request: google.cloud.retail.v2alpha.IUpdateCatalogRequest, callback: google.cloud.retail.v2alpha.CatalogService.UpdateCatalogCallback): void; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @returns Promise + */ + public updateCatalog(request: google.cloud.retail.v2alpha.IUpdateCatalogRequest): Promise; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public setDefaultBranch(request: google.cloud.retail.v2alpha.ISetDefaultBranchRequest, callback: google.cloud.retail.v2alpha.CatalogService.SetDefaultBranchCallback): void; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @returns Promise + */ + public setDefaultBranch(request: google.cloud.retail.v2alpha.ISetDefaultBranchRequest): Promise; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + */ + public getDefaultBranch(request: google.cloud.retail.v2alpha.IGetDefaultBranchRequest, callback: google.cloud.retail.v2alpha.CatalogService.GetDefaultBranchCallback): void; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @returns Promise + */ + public getDefaultBranch(request: google.cloud.retail.v2alpha.IGetDefaultBranchRequest): Promise; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public getCompletionConfig(request: google.cloud.retail.v2alpha.IGetCompletionConfigRequest, callback: google.cloud.retail.v2alpha.CatalogService.GetCompletionConfigCallback): void; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @returns Promise + */ + public getCompletionConfig(request: google.cloud.retail.v2alpha.IGetCompletionConfigRequest): Promise; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public updateCompletionConfig(request: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, callback: google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfigCallback): void; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @returns Promise + */ + public updateCompletionConfig(request: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest): Promise; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public getAttributesConfig(request: google.cloud.retail.v2alpha.IGetAttributesConfigRequest, callback: google.cloud.retail.v2alpha.CatalogService.GetAttributesConfigCallback): void; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @returns Promise + */ + public getAttributesConfig(request: google.cloud.retail.v2alpha.IGetAttributesConfigRequest): Promise; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public updateAttributesConfig(request: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, callback: google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfigCallback): void; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @returns Promise + */ + public updateAttributesConfig(request: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest): Promise; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public addCatalogAttribute(request: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, callback: google.cloud.retail.v2alpha.CatalogService.AddCatalogAttributeCallback): void; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @returns Promise + */ + public addCatalogAttribute(request: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest): Promise; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public removeCatalogAttribute(request: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, callback: google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttributeCallback): void; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @returns Promise + */ + public removeCatalogAttribute(request: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest): Promise; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, callback: google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttributeCallback): void; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @returns Promise + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest): Promise; + } + + namespace CatalogService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|listCatalogs}. + * @param error Error, if any + * @param [response] ListCatalogsResponse + */ + type ListCatalogsCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ListCatalogsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateCatalog}. + * @param error Error, if any + * @param [response] Catalog + */ + type UpdateCatalogCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Catalog) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|setDefaultBranch}. + * @param error Error, if any + * @param [response] Empty + */ + type SetDefaultBranchCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getDefaultBranch}. + * @param error Error, if any + * @param [response] GetDefaultBranchResponse + */ + type GetDefaultBranchCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.GetDefaultBranchResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type GetCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type UpdateCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type GetAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type UpdateAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|addCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type AddCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|removeCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type RemoveCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|replaceCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type ReplaceCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.AttributesConfig) => void; + } + + /** Properties of a ListCatalogsRequest. */ + interface IListCatalogsRequest { + + /** ListCatalogsRequest parent */ + parent?: (string|null); + + /** ListCatalogsRequest pageSize */ + pageSize?: (number|null); + + /** ListCatalogsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCatalogsRequest. */ + class ListCatalogsRequest implements IListCatalogsRequest { + + /** + * Constructs a new ListCatalogsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListCatalogsRequest); + + /** ListCatalogsRequest parent. */ + public parent: string; + + /** ListCatalogsRequest pageSize. */ + public pageSize: number; + + /** ListCatalogsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListCatalogsRequest): google.cloud.retail.v2alpha.ListCatalogsRequest; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsRequest + * @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.cloud.retail.v2alpha.ListCatalogsRequest; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsRequest + * @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.cloud.retail.v2alpha.ListCatalogsRequest; + + /** + * Verifies a ListCatalogsRequest 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListCatalogsRequest; + + /** + * Creates a plain object from a ListCatalogsRequest message. Also converts values to other types if specified. + * @param message ListCatalogsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListCatalogsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCatalogsResponse. */ + interface IListCatalogsResponse { + + /** ListCatalogsResponse catalogs */ + catalogs?: (google.cloud.retail.v2alpha.ICatalog[]|null); + + /** ListCatalogsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCatalogsResponse. */ + class ListCatalogsResponse implements IListCatalogsResponse { + + /** + * Constructs a new ListCatalogsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListCatalogsResponse); + + /** ListCatalogsResponse catalogs. */ + public catalogs: google.cloud.retail.v2alpha.ICatalog[]; + + /** ListCatalogsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListCatalogsResponse): google.cloud.retail.v2alpha.ListCatalogsResponse; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsResponse + * @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.cloud.retail.v2alpha.ListCatalogsResponse; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsResponse + * @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.cloud.retail.v2alpha.ListCatalogsResponse; + + /** + * Verifies a ListCatalogsResponse 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 ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListCatalogsResponse; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @param message ListCatalogsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListCatalogsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCatalogRequest. */ + interface IUpdateCatalogRequest { + + /** UpdateCatalogRequest catalog */ + catalog?: (google.cloud.retail.v2alpha.ICatalog|null); + + /** UpdateCatalogRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCatalogRequest. */ + class UpdateCatalogRequest implements IUpdateCatalogRequest { + + /** + * Constructs a new UpdateCatalogRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateCatalogRequest); + + /** UpdateCatalogRequest catalog. */ + public catalog?: (google.cloud.retail.v2alpha.ICatalog|null); + + /** UpdateCatalogRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCatalogRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateCatalogRequest): google.cloud.retail.v2alpha.UpdateCatalogRequest; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2alpha.UpdateCatalogRequest; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2alpha.UpdateCatalogRequest; + + /** + * Verifies an UpdateCatalogRequest 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 UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCatalogRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateCatalogRequest; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @param message UpdateCatalogRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateCatalogRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetDefaultBranchRequest. */ + interface ISetDefaultBranchRequest { + + /** SetDefaultBranchRequest catalog */ + catalog?: (string|null); + + /** SetDefaultBranchRequest branchId */ + branchId?: (string|null); + + /** SetDefaultBranchRequest note */ + note?: (string|null); + + /** SetDefaultBranchRequest force */ + force?: (boolean|null); + } + + /** Represents a SetDefaultBranchRequest. */ + class SetDefaultBranchRequest implements ISetDefaultBranchRequest { + + /** + * Constructs a new SetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISetDefaultBranchRequest); + + /** SetDefaultBranchRequest catalog. */ + public catalog: string; + + /** SetDefaultBranchRequest branchId. */ + public branchId: string; + + /** SetDefaultBranchRequest note. */ + public note: string; + + /** SetDefaultBranchRequest force. */ + public force: boolean; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISetDefaultBranchRequest): google.cloud.retail.v2alpha.SetDefaultBranchRequest; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2alpha.SetDefaultBranchRequest; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2alpha.SetDefaultBranchRequest; + + /** + * Verifies a SetDefaultBranchRequest 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 SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SetDefaultBranchRequest; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message SetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchRequest. */ + interface IGetDefaultBranchRequest { + + /** GetDefaultBranchRequest catalog */ + catalog?: (string|null); + } + + /** Represents a GetDefaultBranchRequest. */ + class GetDefaultBranchRequest implements IGetDefaultBranchRequest { + + /** + * Constructs a new GetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetDefaultBranchRequest); + + /** GetDefaultBranchRequest catalog. */ + public catalog: string; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetDefaultBranchRequest): google.cloud.retail.v2alpha.GetDefaultBranchRequest; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2alpha.GetDefaultBranchRequest; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2alpha.GetDefaultBranchRequest; + + /** + * Verifies a GetDefaultBranchRequest 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 GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetDefaultBranchRequest; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message GetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchResponse. */ + interface IGetDefaultBranchResponse { + + /** GetDefaultBranchResponse branch */ + branch?: (string|null); + + /** GetDefaultBranchResponse setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note */ + note?: (string|null); + } + + /** Represents a GetDefaultBranchResponse. */ + class GetDefaultBranchResponse implements IGetDefaultBranchResponse { + + /** + * Constructs a new GetDefaultBranchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetDefaultBranchResponse); + + /** GetDefaultBranchResponse branch. */ + public branch: string; + + /** GetDefaultBranchResponse setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note. */ + public note: string; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetDefaultBranchResponse): google.cloud.retail.v2alpha.GetDefaultBranchResponse; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2alpha.GetDefaultBranchResponse; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2alpha.GetDefaultBranchResponse; + + /** + * Verifies a GetDefaultBranchResponse 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 GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetDefaultBranchResponse; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @param message GetDefaultBranchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetDefaultBranchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetCompletionConfigRequest. */ + interface IGetCompletionConfigRequest { + + /** GetCompletionConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetCompletionConfigRequest. */ + class GetCompletionConfigRequest implements IGetCompletionConfigRequest { + + /** + * Constructs a new GetCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetCompletionConfigRequest); + + /** GetCompletionConfigRequest name. */ + public name: string; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetCompletionConfigRequest): google.cloud.retail.v2alpha.GetCompletionConfigRequest; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2alpha.GetCompletionConfigRequest; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2alpha.GetCompletionConfigRequest; + + /** + * Verifies a GetCompletionConfigRequest 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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetCompletionConfigRequest; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @param message GetCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCompletionConfigRequest. */ + interface IUpdateCompletionConfigRequest { + + /** UpdateCompletionConfigRequest completionConfig */ + completionConfig?: (google.cloud.retail.v2alpha.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCompletionConfigRequest. */ + class UpdateCompletionConfigRequest implements IUpdateCompletionConfigRequest { + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest); + + /** UpdateCompletionConfigRequest completionConfig. */ + public completionConfig?: (google.cloud.retail.v2alpha.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest): google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2alpha.UpdateCompletionConfigRequest; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2alpha.UpdateCompletionConfigRequest; + + /** + * Verifies an UpdateCompletionConfigRequest 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 UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateCompletionConfigRequest; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @param message UpdateCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetAttributesConfigRequest. */ + interface IGetAttributesConfigRequest { + + /** GetAttributesConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetAttributesConfigRequest. */ + class GetAttributesConfigRequest implements IGetAttributesConfigRequest { + + /** + * Constructs a new GetAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetAttributesConfigRequest); + + /** GetAttributesConfigRequest name. */ + public name: string; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetAttributesConfigRequest): google.cloud.retail.v2alpha.GetAttributesConfigRequest; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2alpha.GetAttributesConfigRequest; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2alpha.GetAttributesConfigRequest; + + /** + * Verifies a GetAttributesConfigRequest 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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetAttributesConfigRequest; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @param message GetAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateAttributesConfigRequest. */ + interface IUpdateAttributesConfigRequest { + + /** UpdateAttributesConfigRequest attributesConfig */ + attributesConfig?: (google.cloud.retail.v2alpha.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateAttributesConfigRequest. */ + class UpdateAttributesConfigRequest implements IUpdateAttributesConfigRequest { + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest); + + /** UpdateAttributesConfigRequest attributesConfig. */ + public attributesConfig?: (google.cloud.retail.v2alpha.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest): google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2alpha.UpdateAttributesConfigRequest; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2alpha.UpdateAttributesConfigRequest; + + /** + * Verifies an UpdateAttributesConfigRequest 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 UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateAttributesConfigRequest; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @param message UpdateAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddCatalogAttributeRequest. */ + interface IAddCatalogAttributeRequest { + + /** AddCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** AddCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2alpha.ICatalogAttribute|null); + } + + /** Represents an AddCatalogAttributeRequest. */ + class AddCatalogAttributeRequest implements IAddCatalogAttributeRequest { + + /** + * Constructs a new AddCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest); + + /** AddCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** AddCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2alpha.ICatalogAttribute|null); + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest): google.cloud.retail.v2alpha.AddCatalogAttributeRequest; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2alpha.AddCatalogAttributeRequest; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2alpha.AddCatalogAttributeRequest; + + /** + * Verifies an AddCatalogAttributeRequest 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 AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddCatalogAttributeRequest; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message AddCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveCatalogAttributeRequest. */ + interface IRemoveCatalogAttributeRequest { + + /** RemoveCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** RemoveCatalogAttributeRequest key */ + key?: (string|null); + } + + /** Represents a RemoveCatalogAttributeRequest. */ + class RemoveCatalogAttributeRequest implements IRemoveCatalogAttributeRequest { + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest); + + /** RemoveCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** RemoveCatalogAttributeRequest key. */ + public key: string; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest): google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + + /** + * Verifies a RemoveCatalogAttributeRequest 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 RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message RemoveCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplaceCatalogAttributeRequest. */ + interface IReplaceCatalogAttributeRequest { + + /** ReplaceCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** ReplaceCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2alpha.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a ReplaceCatalogAttributeRequest. */ + class ReplaceCatalogAttributeRequest implements IReplaceCatalogAttributeRequest { + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest); + + /** ReplaceCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** ReplaceCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2alpha.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplaceCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest): google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; + + /** + * Verifies a ReplaceCatalogAttributeRequest 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 ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplaceCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message ReplaceCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CompletionService */ + class CompletionService extends $protobuf.rpc.Service { + + /** + * Constructs a new CompletionService 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 CompletionService 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): CompletionService; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompleteQueryResponse + */ + public completeQuery(request: google.cloud.retail.v2alpha.ICompleteQueryRequest, callback: google.cloud.retail.v2alpha.CompletionService.CompleteQueryCallback): void; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @returns Promise + */ + public completeQuery(request: google.cloud.retail.v2alpha.ICompleteQueryRequest): Promise; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importCompletionData(request: google.cloud.retail.v2alpha.IImportCompletionDataRequest, callback: google.cloud.retail.v2alpha.CompletionService.ImportCompletionDataCallback): void; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @returns Promise + */ + public importCompletionData(request: google.cloud.retail.v2alpha.IImportCompletionDataRequest): Promise; + } + + namespace CompletionService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CompletionService|completeQuery}. + * @param error Error, if any + * @param [response] CompleteQueryResponse + */ + type CompleteQueryCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.CompleteQueryResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CompletionService|importCompletionData}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportCompletionDataCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CompleteQueryRequest. */ + interface ICompleteQueryRequest { + + /** CompleteQueryRequest catalog */ + catalog?: (string|null); + + /** CompleteQueryRequest query */ + query?: (string|null); + + /** CompleteQueryRequest visitorId */ + visitorId?: (string|null); + + /** CompleteQueryRequest languageCodes */ + languageCodes?: (string[]|null); + + /** CompleteQueryRequest deviceType */ + deviceType?: (string|null); + + /** CompleteQueryRequest dataset */ + dataset?: (string|null); + + /** CompleteQueryRequest maxSuggestions */ + maxSuggestions?: (number|null); + } + + /** Represents a CompleteQueryRequest. */ + class CompleteQueryRequest implements ICompleteQueryRequest { + + /** + * Constructs a new CompleteQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICompleteQueryRequest); + + /** CompleteQueryRequest catalog. */ + public catalog: string; + + /** CompleteQueryRequest query. */ + public query: string; + + /** CompleteQueryRequest visitorId. */ + public visitorId: string; + + /** CompleteQueryRequest languageCodes. */ + public languageCodes: string[]; + + /** CompleteQueryRequest deviceType. */ + public deviceType: string; + + /** CompleteQueryRequest dataset. */ + public dataset: string; + + /** CompleteQueryRequest maxSuggestions. */ + public maxSuggestions: number; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICompleteQueryRequest): google.cloud.retail.v2alpha.CompleteQueryRequest; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryRequest + * @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.cloud.retail.v2alpha.CompleteQueryRequest; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryRequest + * @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.cloud.retail.v2alpha.CompleteQueryRequest; + + /** + * Verifies a CompleteQueryRequest 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 CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompleteQueryRequest; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @param message CompleteQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompleteQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompleteQueryResponse. */ + interface ICompleteQueryResponse { + + /** CompleteQueryResponse completionResults */ + completionResults?: (google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult[]|null); + + /** CompleteQueryResponse attributionToken */ + attributionToken?: (string|null); + + /** CompleteQueryResponse recentSearchResults */ + recentSearchResults?: (google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult[]|null); + } + + /** Represents a CompleteQueryResponse. */ + class CompleteQueryResponse implements ICompleteQueryResponse { + + /** + * Constructs a new CompleteQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICompleteQueryResponse); + + /** CompleteQueryResponse completionResults. */ + public completionResults: google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult[]; + + /** CompleteQueryResponse attributionToken. */ + public attributionToken: string; + + /** CompleteQueryResponse recentSearchResults. */ + public recentSearchResults: google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult[]; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICompleteQueryResponse): google.cloud.retail.v2alpha.CompleteQueryResponse; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryResponse + * @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.cloud.retail.v2alpha.CompleteQueryResponse; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryResponse + * @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.cloud.retail.v2alpha.CompleteQueryResponse; + + /** + * Verifies a CompleteQueryResponse 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 CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompleteQueryResponse; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @param message CompleteQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompleteQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CompleteQueryResponse { + + /** Properties of a CompletionResult. */ + interface ICompletionResult { + + /** CompletionResult suggestion */ + suggestion?: (string|null); + + /** CompletionResult attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }|null); + } + + /** Represents a CompletionResult. */ + class CompletionResult implements ICompletionResult { + + /** + * Constructs a new CompletionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult); + + /** CompletionResult suggestion. */ + public suggestion: string; + + /** CompletionResult attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2alpha.ICustomAttribute }; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult): google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionResult + * @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.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionResult + * @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.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult; + + /** + * Verifies a CompletionResult 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 CompletionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @param message CompletionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecentSearchResult. */ + interface IRecentSearchResult { + + /** RecentSearchResult recentSearch */ + recentSearch?: (string|null); + } + + /** Represents a RecentSearchResult. */ + class RecentSearchResult implements IRecentSearchResult { + + /** + * Constructs a new RecentSearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult); + + /** RecentSearchResult recentSearch. */ + public recentSearch: string; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentSearchResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult): google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentSearchResult + * @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.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentSearchResult + * @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.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult; + + /** + * Verifies a RecentSearchResult 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 RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentSearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @param message RecentSearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentSearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecentSearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Control. */ + interface IControl { + + /** Control facetSpec */ + facetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IFacetSpec|null); + + /** Control rule */ + rule?: (google.cloud.retail.v2alpha.IRule|null); + + /** Control name */ + name?: (string|null); + + /** Control displayName */ + displayName?: (string|null); + + /** Control associatedServingConfigIds */ + associatedServingConfigIds?: (string[]|null); + + /** Control solutionTypes */ + solutionTypes?: (google.cloud.retail.v2alpha.SolutionType[]|null); + + /** Control searchSolutionUseCase */ + searchSolutionUseCase?: (google.cloud.retail.v2alpha.SearchSolutionUseCase[]|null); + } + + /** Represents a Control. */ + class Control implements IControl { + + /** + * Constructs a new Control. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IControl); + + /** Control facetSpec. */ + public facetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IFacetSpec|null); + + /** Control rule. */ + public rule?: (google.cloud.retail.v2alpha.IRule|null); + + /** Control name. */ + public name: string; + + /** Control displayName. */ + public displayName: string; + + /** Control associatedServingConfigIds. */ + public associatedServingConfigIds: string[]; + + /** Control solutionTypes. */ + public solutionTypes: google.cloud.retail.v2alpha.SolutionType[]; + + /** Control searchSolutionUseCase. */ + public searchSolutionUseCase: google.cloud.retail.v2alpha.SearchSolutionUseCase[]; + + /** Control control. */ + public control?: ("facetSpec"|"rule"); + + /** + * Creates a new Control instance using the specified properties. + * @param [properties] Properties to set + * @returns Control instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IControl): google.cloud.retail.v2alpha.Control; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2alpha.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Control message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Control + * @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.cloud.retail.v2alpha.Control; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Control + * @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.cloud.retail.v2alpha.Control; + + /** + * Verifies a Control 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 Control message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Control + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Control; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @param message Control + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Control, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Control to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Control + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a SearchService */ + class SearchService extends $protobuf.rpc.Service { + + /** + * Constructs a new SearchService 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 SearchService 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): SearchService; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SearchResponse + */ + public search(request: google.cloud.retail.v2alpha.ISearchRequest, callback: google.cloud.retail.v2alpha.SearchService.SearchCallback): void; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @returns Promise + */ + public search(request: google.cloud.retail.v2alpha.ISearchRequest): Promise; + } + + namespace SearchService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.SearchService|search}. + * @param error Error, if any + * @param [response] SearchResponse + */ + type SearchCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.SearchResponse) => void; + } + + /** Properties of a SearchRequest. */ + interface ISearchRequest { + + /** SearchRequest placement */ + placement?: (string|null); + + /** SearchRequest branch */ + branch?: (string|null); + + /** SearchRequest query */ + query?: (string|null); + + /** SearchRequest visitorId */ + visitorId?: (string|null); + + /** SearchRequest userInfo */ + userInfo?: (google.cloud.retail.v2alpha.IUserInfo|null); + + /** SearchRequest pageSize */ + pageSize?: (number|null); + + /** SearchRequest pageToken */ + pageToken?: (string|null); + + /** SearchRequest offset */ + offset?: (number|null); + + /** SearchRequest filter */ + filter?: (string|null); + + /** SearchRequest canonicalFilter */ + canonicalFilter?: (string|null); + + /** SearchRequest orderBy */ + orderBy?: (string|null); + + /** SearchRequest facetSpecs */ + facetSpecs?: (google.cloud.retail.v2alpha.SearchRequest.IFacetSpec[]|null); + + /** SearchRequest dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec */ + boostSpec?: (google.cloud.retail.v2alpha.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec */ + queryExpansionSpec?: (google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest relevanceThreshold */ + relevanceThreshold?: (google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold|keyof typeof google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold|null); + + /** SearchRequest variantRollupKeys */ + variantRollupKeys?: (string[]|null); + + /** SearchRequest pageCategories */ + pageCategories?: (string[]|null); + + /** SearchRequest searchMode */ + searchMode?: (google.cloud.retail.v2alpha.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.SearchMode|null); + + /** SearchRequest personalizationSpec */ + personalizationSpec?: (google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** SearchRequest spellCorrectionSpec */ + spellCorrectionSpec?: (google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec|null); + } + + /** Represents a SearchRequest. */ + class SearchRequest implements ISearchRequest { + + /** + * Constructs a new SearchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISearchRequest); + + /** SearchRequest placement. */ + public placement: string; + + /** SearchRequest branch. */ + public branch: string; + + /** SearchRequest query. */ + public query: string; + + /** SearchRequest visitorId. */ + public visitorId: string; + + /** SearchRequest userInfo. */ + public userInfo?: (google.cloud.retail.v2alpha.IUserInfo|null); + + /** SearchRequest pageSize. */ + public pageSize: number; + + /** SearchRequest pageToken. */ + public pageToken: string; + + /** SearchRequest offset. */ + public offset: number; + + /** SearchRequest filter. */ + public filter: string; + + /** SearchRequest canonicalFilter. */ + public canonicalFilter: string; + + /** SearchRequest orderBy. */ + public orderBy: string; + + /** SearchRequest facetSpecs. */ + public facetSpecs: google.cloud.retail.v2alpha.SearchRequest.IFacetSpec[]; + + /** SearchRequest dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec. */ + public boostSpec?: (google.cloud.retail.v2alpha.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec. */ + public queryExpansionSpec?: (google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest relevanceThreshold. */ + public relevanceThreshold: (google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold|keyof typeof google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold); + + /** SearchRequest variantRollupKeys. */ + public variantRollupKeys: string[]; + + /** SearchRequest pageCategories. */ + public pageCategories: string[]; + + /** SearchRequest searchMode. */ + public searchMode: (google.cloud.retail.v2alpha.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.SearchMode); + + /** SearchRequest personalizationSpec. */ + public personalizationSpec?: (google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels. */ + public labels: { [k: string]: string }; + + /** SearchRequest spellCorrectionSpec. */ + public spellCorrectionSpec?: (google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec|null); + + /** SearchRequest _spellCorrectionSpec. */ + public _spellCorrectionSpec?: "spellCorrectionSpec"; + + /** + * Creates a new SearchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISearchRequest): google.cloud.retail.v2alpha.SearchRequest; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchRequest + * @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.cloud.retail.v2alpha.SearchRequest; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchRequest + * @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.cloud.retail.v2alpha.SearchRequest; + + /** + * Verifies a SearchRequest 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 SearchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @param message SearchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchRequest { + + /** Properties of a FacetSpec. */ + interface IFacetSpec { + + /** FacetSpec facetKey */ + facetKey?: (google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit */ + limit?: (number|null); + + /** FacetSpec excludedFilterKeys */ + excludedFilterKeys?: (string[]|null); + + /** FacetSpec enableDynamicPosition */ + enableDynamicPosition?: (boolean|null); + } + + /** Represents a FacetSpec. */ + class FacetSpec implements IFacetSpec { + + /** + * Constructs a new FacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.IFacetSpec); + + /** FacetSpec facetKey. */ + public facetKey?: (google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit. */ + public limit: number; + + /** FacetSpec excludedFilterKeys. */ + public excludedFilterKeys: string[]; + + /** FacetSpec enableDynamicPosition. */ + public enableDynamicPosition: boolean; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.IFacetSpec): google.cloud.retail.v2alpha.SearchRequest.FacetSpec; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetSpec + * @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.cloud.retail.v2alpha.SearchRequest.FacetSpec; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetSpec + * @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.cloud.retail.v2alpha.SearchRequest.FacetSpec; + + /** + * Verifies a FacetSpec 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 FacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.FacetSpec; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @param message FacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.FacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FacetSpec { + + /** Properties of a FacetKey. */ + interface IFacetKey { + + /** FacetKey key */ + key?: (string|null); + + /** FacetKey intervals */ + intervals?: (google.cloud.retail.v2alpha.IInterval[]|null); + + /** FacetKey restrictedValues */ + restrictedValues?: (string[]|null); + + /** FacetKey prefixes */ + prefixes?: (string[]|null); + + /** FacetKey contains */ + contains?: (string[]|null); + + /** FacetKey caseInsensitive */ + caseInsensitive?: (boolean|null); + + /** FacetKey orderBy */ + orderBy?: (string|null); + + /** FacetKey query */ + query?: (string|null); + + /** FacetKey returnMinMax */ + returnMinMax?: (boolean|null); + } + + /** Represents a FacetKey. */ + class FacetKey implements IFacetKey { + + /** + * Constructs a new FacetKey. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey); + + /** FacetKey key. */ + public key: string; + + /** FacetKey intervals. */ + public intervals: google.cloud.retail.v2alpha.IInterval[]; + + /** FacetKey restrictedValues. */ + public restrictedValues: string[]; + + /** FacetKey prefixes. */ + public prefixes: string[]; + + /** FacetKey contains. */ + public contains: string[]; + + /** FacetKey caseInsensitive. */ + public caseInsensitive: boolean; + + /** FacetKey orderBy. */ + public orderBy: string; + + /** FacetKey query. */ + public query: string; + + /** FacetKey returnMinMax. */ + public returnMinMax: boolean; + + /** + * Creates a new FacetKey instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetKey instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey): google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetKey + * @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.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetKey + * @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.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey; + + /** + * Verifies a FacetKey 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 FacetKey message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetKey + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @param message FacetKey + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetKey to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetKey + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a DynamicFacetSpec. */ + interface IDynamicFacetSpec { + + /** DynamicFacetSpec mode */ + mode?: (google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode|null); + } + + /** Represents a DynamicFacetSpec. */ + class DynamicFacetSpec implements IDynamicFacetSpec { + + /** + * Constructs a new DynamicFacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec); + + /** DynamicFacetSpec mode. */ + public mode: (google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode); + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns DynamicFacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec): google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DynamicFacetSpec + * @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.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DynamicFacetSpec + * @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.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec; + + /** + * Verifies a DynamicFacetSpec 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 DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DynamicFacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @param message DynamicFacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DynamicFacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DynamicFacetSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + DISABLED = 1, + ENABLED = 2 + } + } + + /** Properties of a BoostSpec. */ + interface IBoostSpec { + + /** BoostSpec conditionBoostSpecs */ + conditionBoostSpecs?: (google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + + /** BoostSpec skipBoostSpecValidation */ + skipBoostSpecValidation?: (boolean|null); + } + + /** Represents a BoostSpec. */ + class BoostSpec implements IBoostSpec { + + /** + * Constructs a new BoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.IBoostSpec); + + /** BoostSpec conditionBoostSpecs. */ + public conditionBoostSpecs: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** BoostSpec skipBoostSpecValidation. */ + public skipBoostSpecValidation?: (boolean|null); + + /** BoostSpec _skipBoostSpecValidation. */ + public _skipBoostSpecValidation?: "skipBoostSpecValidation"; + + /** + * Creates a new BoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.IBoostSpec): google.cloud.retail.v2alpha.SearchRequest.BoostSpec; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostSpec + * @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.cloud.retail.v2alpha.SearchRequest.BoostSpec; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostSpec + * @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.cloud.retail.v2alpha.SearchRequest.BoostSpec; + + /** + * Verifies a BoostSpec 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 BoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.BoostSpec; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @param message BoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.BoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace BoostSpec { + + /** Properties of a ConditionBoostSpec. */ + interface IConditionBoostSpec { + + /** ConditionBoostSpec condition */ + condition?: (string|null); + + /** ConditionBoostSpec boost */ + boost?: (number|null); + } + + /** Represents a ConditionBoostSpec. */ + class ConditionBoostSpec implements IConditionBoostSpec { + + /** + * Constructs a new ConditionBoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec); + + /** ConditionBoostSpec condition. */ + public condition: string; + + /** ConditionBoostSpec boost. */ + public boost: number; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns ConditionBoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec): google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ConditionBoostSpec + * @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.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ConditionBoostSpec + * @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.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Verifies a ConditionBoostSpec 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 ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ConditionBoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @param message ConditionBoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ConditionBoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionSpec. */ + interface IQueryExpansionSpec { + + /** QueryExpansionSpec condition */ + condition?: (google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition|null); + + /** QueryExpansionSpec pinUnexpandedResults */ + pinUnexpandedResults?: (boolean|null); + } + + /** Represents a QueryExpansionSpec. */ + class QueryExpansionSpec implements IQueryExpansionSpec { + + /** + * Constructs a new QueryExpansionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec); + + /** QueryExpansionSpec condition. */ + public condition: (google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition); + + /** QueryExpansionSpec pinUnexpandedResults. */ + public pinUnexpandedResults: boolean; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec): google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionSpec + * @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.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionSpec + * @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.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec; + + /** + * Verifies a QueryExpansionSpec 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 QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @param message QueryExpansionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace QueryExpansionSpec { + + /** Condition enum. */ + enum Condition { + CONDITION_UNSPECIFIED = 0, + DISABLED = 1, + AUTO = 3 + } + } + + /** Properties of a PersonalizationSpec. */ + interface IPersonalizationSpec { + + /** PersonalizationSpec mode */ + mode?: (google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode|null); + } + + /** Represents a PersonalizationSpec. */ + class PersonalizationSpec implements IPersonalizationSpec { + + /** + * Constructs a new PersonalizationSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec); + + /** PersonalizationSpec mode. */ + public mode: (google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode); + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns PersonalizationSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec): google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PersonalizationSpec + * @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.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PersonalizationSpec + * @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.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec; + + /** + * Verifies a PersonalizationSpec 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 PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PersonalizationSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @param message PersonalizationSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PersonalizationSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PersonalizationSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PersonalizationSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + AUTO = 1, + DISABLED = 2 + } + } + + /** Properties of a SpellCorrectionSpec. */ + interface ISpellCorrectionSpec { + + /** SpellCorrectionSpec mode */ + mode?: (google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode|null); + } + + /** Represents a SpellCorrectionSpec. */ + class SpellCorrectionSpec implements ISpellCorrectionSpec { + + /** + * Constructs a new SpellCorrectionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec); + + /** SpellCorrectionSpec mode. */ + public mode: (google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode); + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns SpellCorrectionSpec instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec): google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec; + + /** + * Verifies a SpellCorrectionSpec 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 SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpellCorrectionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @param message SpellCorrectionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SpellCorrectionSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + SUGGESTION_ONLY = 1, + AUTO = 2 + } + } + + /** RelevanceThreshold enum. */ + enum RelevanceThreshold { + RELEVANCE_THRESHOLD_UNSPECIFIED = 0, + HIGH = 1, + MEDIUM = 2, + LOW = 3, + LOWEST = 4 + } + + /** SearchMode enum. */ + enum SearchMode { + SEARCH_MODE_UNSPECIFIED = 0, + PRODUCT_SEARCH_ONLY = 1, + FACETED_SEARCH_ONLY = 2 + } + } + + /** Properties of a SearchResponse. */ + interface ISearchResponse { + + /** SearchResponse results */ + results?: (google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]|null); + + /** SearchResponse facets */ + facets?: (google.cloud.retail.v2alpha.SearchResponse.IFacet[]|null); + + /** SearchResponse totalSize */ + totalSize?: (number|null); + + /** SearchResponse correctedQuery */ + correctedQuery?: (string|null); + + /** SearchResponse attributionToken */ + attributionToken?: (string|null); + + /** SearchResponse nextPageToken */ + nextPageToken?: (string|null); + + /** SearchResponse queryExpansionInfo */ + queryExpansionInfo?: (google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri */ + redirectUri?: (string|null); + + /** SearchResponse appliedControls */ + appliedControls?: (string[]|null); + + /** SearchResponse invalidConditionBoostSpecs */ + invalidConditionBoostSpecs?: (google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + } + + /** Represents a SearchResponse. */ + class SearchResponse implements ISearchResponse { + + /** + * Constructs a new SearchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISearchResponse); + + /** SearchResponse results. */ + public results: google.cloud.retail.v2alpha.SearchResponse.ISearchResult[]; + + /** SearchResponse facets. */ + public facets: google.cloud.retail.v2alpha.SearchResponse.IFacet[]; + + /** SearchResponse totalSize. */ + public totalSize: number; + + /** SearchResponse correctedQuery. */ + public correctedQuery: string; + + /** SearchResponse attributionToken. */ + public attributionToken: string; + + /** SearchResponse nextPageToken. */ + public nextPageToken: string; + + /** SearchResponse queryExpansionInfo. */ + public queryExpansionInfo?: (google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri. */ + public redirectUri: string; + + /** SearchResponse appliedControls. */ + public appliedControls: string[]; + + /** SearchResponse invalidConditionBoostSpecs. */ + public invalidConditionBoostSpecs: google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISearchResponse): google.cloud.retail.v2alpha.SearchResponse; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResponse + * @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.cloud.retail.v2alpha.SearchResponse; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResponse + * @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.cloud.retail.v2alpha.SearchResponse; + + /** + * Verifies a SearchResponse 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 SearchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchResponse; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @param message SearchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchResponse { + + /** Properties of a SearchResult. */ + interface ISearchResult { + + /** SearchResult id */ + id?: (string|null); + + /** SearchResult product */ + product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** SearchResult matchingVariantCount */ + matchingVariantCount?: (number|null); + + /** SearchResult matchingVariantFields */ + matchingVariantFields?: ({ [k: string]: google.protobuf.IFieldMask }|null); + + /** SearchResult variantRollupValues */ + variantRollupValues?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a SearchResult. */ + class SearchResult implements ISearchResult { + + /** + * Constructs a new SearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchResponse.ISearchResult); + + /** SearchResult id. */ + public id: string; + + /** SearchResult product. */ + public product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** SearchResult matchingVariantCount. */ + public matchingVariantCount: number; + + /** SearchResult matchingVariantFields. */ + public matchingVariantFields: { [k: string]: google.protobuf.IFieldMask }; + + /** SearchResult variantRollupValues. */ + public variantRollupValues: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a new SearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchResponse.ISearchResult): google.cloud.retail.v2alpha.SearchResponse.SearchResult; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResult + * @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.cloud.retail.v2alpha.SearchResponse.SearchResult; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResult + * @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.cloud.retail.v2alpha.SearchResponse.SearchResult; + + /** + * Verifies a SearchResult 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 SearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchResponse.SearchResult; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @param message SearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchResponse.SearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Facet. */ + interface IFacet { + + /** Facet key */ + key?: (string|null); + + /** Facet values */ + values?: (google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue[]|null); + + /** Facet dynamicFacet */ + dynamicFacet?: (boolean|null); + } + + /** Represents a Facet. */ + class Facet implements IFacet { + + /** + * Constructs a new Facet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchResponse.IFacet); + + /** Facet key. */ + public key: string; + + /** Facet values. */ + public values: google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue[]; + + /** Facet dynamicFacet. */ + public dynamicFacet: boolean; + + /** + * Creates a new Facet instance using the specified properties. + * @param [properties] Properties to set + * @returns Facet instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchResponse.IFacet): google.cloud.retail.v2alpha.SearchResponse.Facet; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Facet + * @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.cloud.retail.v2alpha.SearchResponse.Facet; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Facet + * @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.cloud.retail.v2alpha.SearchResponse.Facet; + + /** + * Verifies a Facet 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 Facet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Facet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchResponse.Facet; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @param message Facet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchResponse.Facet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Facet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Facet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Facet { + + /** Properties of a FacetValue. */ + interface IFacetValue { + + /** FacetValue value */ + value?: (string|null); + + /** FacetValue interval */ + interval?: (google.cloud.retail.v2alpha.IInterval|null); + + /** FacetValue count */ + count?: (number|Long|string|null); + + /** FacetValue minValue */ + minValue?: (number|null); + + /** FacetValue maxValue */ + maxValue?: (number|null); + } + + /** Represents a FacetValue. */ + class FacetValue implements IFacetValue { + + /** + * Constructs a new FacetValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue); + + /** FacetValue value. */ + public value?: (string|null); + + /** FacetValue interval. */ + public interval?: (google.cloud.retail.v2alpha.IInterval|null); + + /** FacetValue count. */ + public count: (number|Long|string); + + /** FacetValue minValue. */ + public minValue: number; + + /** FacetValue maxValue. */ + public maxValue: number; + + /** FacetValue facetValue. */ + public facetValue?: ("value"|"interval"); + + /** + * Creates a new FacetValue instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetValue instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue): google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetValue + * @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.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetValue + * @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.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue; + + /** + * Verifies a FacetValue 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 FacetValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetValue + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @param message FacetValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionInfo. */ + interface IQueryExpansionInfo { + + /** QueryExpansionInfo expandedQuery */ + expandedQuery?: (boolean|null); + + /** QueryExpansionInfo pinnedResultCount */ + pinnedResultCount?: (number|Long|string|null); + } + + /** Represents a QueryExpansionInfo. */ + class QueryExpansionInfo implements IQueryExpansionInfo { + + /** + * Constructs a new QueryExpansionInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo); + + /** QueryExpansionInfo expandedQuery. */ + public expandedQuery: boolean; + + /** QueryExpansionInfo pinnedResultCount. */ + public pinnedResultCount: (number|Long|string); + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionInfo instance + */ + public static create(properties?: google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo): google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionInfo + * @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.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionInfo + * @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.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo; + + /** + * Verifies a QueryExpansionInfo 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 QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @param message QueryExpansionInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Represents a ControlService */ + class ControlService extends $protobuf.rpc.Service { + + /** + * Constructs a new ControlService 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 ControlService 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): ControlService; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public createControl(request: google.cloud.retail.v2alpha.ICreateControlRequest, callback: google.cloud.retail.v2alpha.ControlService.CreateControlCallback): void; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @returns Promise + */ + public createControl(request: google.cloud.retail.v2alpha.ICreateControlRequest): Promise; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteControl(request: google.cloud.retail.v2alpha.IDeleteControlRequest, callback: google.cloud.retail.v2alpha.ControlService.DeleteControlCallback): void; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @returns Promise + */ + public deleteControl(request: google.cloud.retail.v2alpha.IDeleteControlRequest): Promise; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public updateControl(request: google.cloud.retail.v2alpha.IUpdateControlRequest, callback: google.cloud.retail.v2alpha.ControlService.UpdateControlCallback): void; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @returns Promise + */ + public updateControl(request: google.cloud.retail.v2alpha.IUpdateControlRequest): Promise; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public getControl(request: google.cloud.retail.v2alpha.IGetControlRequest, callback: google.cloud.retail.v2alpha.ControlService.GetControlCallback): void; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @returns Promise + */ + public getControl(request: google.cloud.retail.v2alpha.IGetControlRequest): Promise; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListControlsResponse + */ + public listControls(request: google.cloud.retail.v2alpha.IListControlsRequest, callback: google.cloud.retail.v2alpha.ControlService.ListControlsCallback): void; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @returns Promise + */ + public listControls(request: google.cloud.retail.v2alpha.IListControlsRequest): Promise; + } + + namespace ControlService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|createControl}. + * @param error Error, if any + * @param [response] Control + */ + type CreateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|deleteControl}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteControlCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|updateControl}. + * @param error Error, if any + * @param [response] Control + */ + type UpdateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|getControl}. + * @param error Error, if any + * @param [response] Control + */ + type GetControlCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|listControls}. + * @param error Error, if any + * @param [response] ListControlsResponse + */ + type ListControlsCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ListControlsResponse) => void; + } + + /** Properties of a CreateControlRequest. */ + interface ICreateControlRequest { + + /** CreateControlRequest parent */ + parent?: (string|null); + + /** CreateControlRequest control */ + control?: (google.cloud.retail.v2alpha.IControl|null); + + /** CreateControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a CreateControlRequest. */ + class CreateControlRequest implements ICreateControlRequest { + + /** + * Constructs a new CreateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICreateControlRequest); + + /** CreateControlRequest parent. */ + public parent: string; + + /** CreateControlRequest control. */ + public control?: (google.cloud.retail.v2alpha.IControl|null); + + /** CreateControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICreateControlRequest): google.cloud.retail.v2alpha.CreateControlRequest; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateControlRequest + * @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.cloud.retail.v2alpha.CreateControlRequest; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateControlRequest + * @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.cloud.retail.v2alpha.CreateControlRequest; + + /** + * Verifies a CreateControlRequest 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 CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CreateControlRequest; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @param message CreateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CreateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateControlRequest. */ + interface IUpdateControlRequest { + + /** UpdateControlRequest control */ + control?: (google.cloud.retail.v2alpha.IControl|null); + + /** UpdateControlRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateControlRequest. */ + class UpdateControlRequest implements IUpdateControlRequest { + + /** + * Constructs a new UpdateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateControlRequest); + + /** UpdateControlRequest control. */ + public control?: (google.cloud.retail.v2alpha.IControl|null); + + /** UpdateControlRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateControlRequest): google.cloud.retail.v2alpha.UpdateControlRequest; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateControlRequest + * @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.cloud.retail.v2alpha.UpdateControlRequest; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateControlRequest + * @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.cloud.retail.v2alpha.UpdateControlRequest; + + /** + * Verifies an UpdateControlRequest 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 UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateControlRequest; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @param message UpdateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteControlRequest. */ + interface IDeleteControlRequest { + + /** DeleteControlRequest name */ + name?: (string|null); + } + + /** Represents a DeleteControlRequest. */ + class DeleteControlRequest implements IDeleteControlRequest { + + /** + * Constructs a new DeleteControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IDeleteControlRequest); + + /** DeleteControlRequest name. */ + public name: string; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IDeleteControlRequest): google.cloud.retail.v2alpha.DeleteControlRequest; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteControlRequest + * @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.cloud.retail.v2alpha.DeleteControlRequest; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteControlRequest + * @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.cloud.retail.v2alpha.DeleteControlRequest; + + /** + * Verifies a DeleteControlRequest 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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.DeleteControlRequest; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @param message DeleteControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.DeleteControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetControlRequest. */ + interface IGetControlRequest { + + /** GetControlRequest name */ + name?: (string|null); + } + + /** Represents a GetControlRequest. */ + class GetControlRequest implements IGetControlRequest { + + /** + * Constructs a new GetControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetControlRequest); + + /** GetControlRequest name. */ + public name: string; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetControlRequest): google.cloud.retail.v2alpha.GetControlRequest; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetControlRequest + * @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.cloud.retail.v2alpha.GetControlRequest; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetControlRequest + * @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.cloud.retail.v2alpha.GetControlRequest; + + /** + * Verifies a GetControlRequest 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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetControlRequest; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @param message GetControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsRequest. */ + interface IListControlsRequest { + + /** ListControlsRequest parent */ + parent?: (string|null); + + /** ListControlsRequest pageSize */ + pageSize?: (number|null); + + /** ListControlsRequest pageToken */ + pageToken?: (string|null); + + /** ListControlsRequest filter */ + filter?: (string|null); + } + + /** Represents a ListControlsRequest. */ + class ListControlsRequest implements IListControlsRequest { + + /** + * Constructs a new ListControlsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListControlsRequest); + + /** ListControlsRequest parent. */ + public parent: string; + + /** ListControlsRequest pageSize. */ + public pageSize: number; + + /** ListControlsRequest pageToken. */ + public pageToken: string; + + /** ListControlsRequest filter. */ + public filter: string; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListControlsRequest): google.cloud.retail.v2alpha.ListControlsRequest; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsRequest + * @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.cloud.retail.v2alpha.ListControlsRequest; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsRequest + * @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.cloud.retail.v2alpha.ListControlsRequest; + + /** + * Verifies a ListControlsRequest 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 ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListControlsRequest; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @param message ListControlsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListControlsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsResponse. */ + interface IListControlsResponse { + + /** ListControlsResponse controls */ + controls?: (google.cloud.retail.v2alpha.IControl[]|null); + + /** ListControlsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListControlsResponse. */ + class ListControlsResponse implements IListControlsResponse { + + /** + * Constructs a new ListControlsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListControlsResponse); + + /** ListControlsResponse controls. */ + public controls: google.cloud.retail.v2alpha.IControl[]; + + /** ListControlsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListControlsResponse): google.cloud.retail.v2alpha.ListControlsResponse; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsResponse + * @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.cloud.retail.v2alpha.ListControlsResponse; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsResponse + * @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.cloud.retail.v2alpha.ListControlsResponse; + + /** + * Verifies a ListControlsResponse 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 ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListControlsResponse; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @param message ListControlsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListControlsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportErrorsConfig. */ + interface IExportErrorsConfig { + + /** ExportErrorsConfig gcsPrefix */ + gcsPrefix?: (string|null); + } + + /** Represents an ExportErrorsConfig. */ + class ExportErrorsConfig implements IExportErrorsConfig { + + /** + * Constructs a new ExportErrorsConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IExportErrorsConfig); + + /** ExportErrorsConfig gcsPrefix. */ + public gcsPrefix?: (string|null); + + /** ExportErrorsConfig destination. */ + public destination?: "gcsPrefix"; + + /** + * Creates a new ExportErrorsConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportErrorsConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IExportErrorsConfig): google.cloud.retail.v2alpha.ExportErrorsConfig; + + /** + * Encodes the specified ExportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportErrorsConfig.verify|verify} messages. + * @param message ExportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IExportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportErrorsConfig.verify|verify} messages. + * @param message ExportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IExportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportErrorsConfig + * @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.cloud.retail.v2alpha.ExportErrorsConfig; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportErrorsConfig + * @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.cloud.retail.v2alpha.ExportErrorsConfig; + + /** + * Verifies an ExportErrorsConfig 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 ExportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportErrorsConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ExportErrorsConfig; + + /** + * Creates a plain object from an ExportErrorsConfig message. Also converts values to other types if specified. + * @param message ExportErrorsConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ExportErrorsConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportErrorsConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportErrorsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportMetadata. */ + interface IExportMetadata { + + /** ExportMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ExportMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents an ExportMetadata. */ + class ExportMetadata implements IExportMetadata { + + /** + * Constructs a new ExportMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IExportMetadata); + + /** ExportMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ExportMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new ExportMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IExportMetadata): google.cloud.retail.v2alpha.ExportMetadata; + + /** + * Encodes the specified ExportMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportMetadata.verify|verify} messages. + * @param message ExportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IExportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportMetadata.verify|verify} messages. + * @param message ExportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IExportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportMetadata + * @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.cloud.retail.v2alpha.ExportMetadata; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportMetadata + * @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.cloud.retail.v2alpha.ExportMetadata; + + /** + * Verifies an ExportMetadata 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 ExportMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ExportMetadata; + + /** + * Creates a plain object from an ExportMetadata message. Also converts values to other types if specified. + * @param message ExportMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ExportMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportProductsResponse. */ + interface IExportProductsResponse { + + /** ExportProductsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ExportProductsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IExportErrorsConfig|null); + + /** ExportProductsResponse outputResult */ + outputResult?: (google.cloud.retail.v2alpha.IOutputResult|null); + } + + /** Represents an ExportProductsResponse. */ + class ExportProductsResponse implements IExportProductsResponse { + + /** + * Constructs a new ExportProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IExportProductsResponse); + + /** ExportProductsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ExportProductsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IExportErrorsConfig|null); + + /** ExportProductsResponse outputResult. */ + public outputResult?: (google.cloud.retail.v2alpha.IOutputResult|null); + + /** + * Creates a new ExportProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IExportProductsResponse): google.cloud.retail.v2alpha.ExportProductsResponse; + + /** + * Encodes the specified ExportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportProductsResponse.verify|verify} messages. + * @param message ExportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IExportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportProductsResponse.verify|verify} messages. + * @param message ExportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IExportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportProductsResponse + * @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.cloud.retail.v2alpha.ExportProductsResponse; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportProductsResponse + * @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.cloud.retail.v2alpha.ExportProductsResponse; + + /** + * Verifies an ExportProductsResponse 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 ExportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ExportProductsResponse; + + /** + * Creates a plain object from an ExportProductsResponse message. Also converts values to other types if specified. + * @param message ExportProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ExportProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportUserEventsResponse. */ + interface IExportUserEventsResponse { + + /** ExportUserEventsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ExportUserEventsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2alpha.IExportErrorsConfig|null); + + /** ExportUserEventsResponse outputResult */ + outputResult?: (google.cloud.retail.v2alpha.IOutputResult|null); + } + + /** Represents an ExportUserEventsResponse. */ + class ExportUserEventsResponse implements IExportUserEventsResponse { + + /** + * Constructs a new ExportUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IExportUserEventsResponse); + + /** ExportUserEventsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ExportUserEventsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2alpha.IExportErrorsConfig|null); + + /** ExportUserEventsResponse outputResult. */ + public outputResult?: (google.cloud.retail.v2alpha.IOutputResult|null); + + /** + * Creates a new ExportUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IExportUserEventsResponse): google.cloud.retail.v2alpha.ExportUserEventsResponse; + + /** + * Encodes the specified ExportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportUserEventsResponse.verify|verify} messages. + * @param message ExportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IExportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportUserEventsResponse.verify|verify} messages. + * @param message ExportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IExportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportUserEventsResponse + * @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.cloud.retail.v2alpha.ExportUserEventsResponse; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportUserEventsResponse + * @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.cloud.retail.v2alpha.ExportUserEventsResponse; + + /** + * Verifies an ExportUserEventsResponse 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 ExportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ExportUserEventsResponse; + + /** + * Creates a plain object from an ExportUserEventsResponse message. Also converts values to other types if specified. + * @param message ExportUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ExportUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OutputResult. */ + interface IOutputResult { + + /** OutputResult bigqueryResult */ + bigqueryResult?: (google.cloud.retail.v2alpha.IBigQueryOutputResult[]|null); + } + + /** Represents an OutputResult. */ + class OutputResult implements IOutputResult { + + /** + * Constructs a new OutputResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IOutputResult); + + /** OutputResult bigqueryResult. */ + public bigqueryResult: google.cloud.retail.v2alpha.IBigQueryOutputResult[]; + + /** + * Creates a new OutputResult instance using the specified properties. + * @param [properties] Properties to set + * @returns OutputResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IOutputResult): google.cloud.retail.v2alpha.OutputResult; + + /** + * Encodes the specified OutputResult message. Does not implicitly {@link google.cloud.retail.v2alpha.OutputResult.verify|verify} messages. + * @param message OutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.OutputResult.verify|verify} messages. + * @param message OutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OutputResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OutputResult + * @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.cloud.retail.v2alpha.OutputResult; + + /** + * Decodes an OutputResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OutputResult + * @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.cloud.retail.v2alpha.OutputResult; + + /** + * Verifies an OutputResult 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 OutputResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OutputResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.OutputResult; + + /** + * Creates a plain object from an OutputResult message. Also converts values to other types if specified. + * @param message OutputResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.OutputResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OutputResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OutputResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BigQueryOutputResult. */ + interface IBigQueryOutputResult { + + /** BigQueryOutputResult datasetId */ + datasetId?: (string|null); + + /** BigQueryOutputResult tableId */ + tableId?: (string|null); + } + + /** Represents a BigQueryOutputResult. */ + class BigQueryOutputResult implements IBigQueryOutputResult { + + /** + * Constructs a new BigQueryOutputResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IBigQueryOutputResult); + + /** BigQueryOutputResult datasetId. */ + public datasetId: string; + + /** BigQueryOutputResult tableId. */ + public tableId: string; + + /** + * Creates a new BigQueryOutputResult instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQueryOutputResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IBigQueryOutputResult): google.cloud.retail.v2alpha.BigQueryOutputResult; + + /** + * Encodes the specified BigQueryOutputResult message. Does not implicitly {@link google.cloud.retail.v2alpha.BigQueryOutputResult.verify|verify} messages. + * @param message BigQueryOutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IBigQueryOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQueryOutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.BigQueryOutputResult.verify|verify} messages. + * @param message BigQueryOutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IBigQueryOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQueryOutputResult + * @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.cloud.retail.v2alpha.BigQueryOutputResult; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQueryOutputResult + * @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.cloud.retail.v2alpha.BigQueryOutputResult; + + /** + * Verifies a BigQueryOutputResult 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 BigQueryOutputResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQueryOutputResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.BigQueryOutputResult; + + /** + * Creates a plain object from a BigQueryOutputResult message. Also converts values to other types if specified. + * @param message BigQueryOutputResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.BigQueryOutputResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQueryOutputResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BigQueryOutputResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Model. */ + interface IModel { + + /** Model pageOptimizationConfig */ + pageOptimizationConfig?: (google.cloud.retail.v2alpha.Model.IPageOptimizationConfig|null); + + /** Model name */ + name?: (string|null); + + /** Model displayName */ + displayName?: (string|null); + + /** Model trainingState */ + trainingState?: (google.cloud.retail.v2alpha.Model.TrainingState|keyof typeof google.cloud.retail.v2alpha.Model.TrainingState|null); + + /** Model servingState */ + servingState?: (google.cloud.retail.v2alpha.Model.ServingState|keyof typeof google.cloud.retail.v2alpha.Model.ServingState|null); + + /** Model createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Model updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** Model type */ + type?: (string|null); + + /** Model optimizationObjective */ + optimizationObjective?: (string|null); + + /** Model periodicTuningState */ + periodicTuningState?: (google.cloud.retail.v2alpha.Model.PeriodicTuningState|keyof typeof google.cloud.retail.v2alpha.Model.PeriodicTuningState|null); + + /** Model lastTuneTime */ + lastTuneTime?: (google.protobuf.ITimestamp|null); + + /** Model tuningOperation */ + tuningOperation?: (string|null); + + /** Model dataState */ + dataState?: (google.cloud.retail.v2alpha.Model.DataState|keyof typeof google.cloud.retail.v2alpha.Model.DataState|null); + + /** Model filteringOption */ + filteringOption?: (google.cloud.retail.v2alpha.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2alpha.RecommendationsFilteringOption|null); + + /** Model servingConfigLists */ + servingConfigLists?: (google.cloud.retail.v2alpha.Model.IServingConfigList[]|null); + } + + /** Represents a Model. */ + class Model implements IModel { + + /** + * Constructs a new Model. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IModel); + + /** Model pageOptimizationConfig. */ + public pageOptimizationConfig?: (google.cloud.retail.v2alpha.Model.IPageOptimizationConfig|null); + + /** Model name. */ + public name: string; + + /** Model displayName. */ + public displayName: string; + + /** Model trainingState. */ + public trainingState: (google.cloud.retail.v2alpha.Model.TrainingState|keyof typeof google.cloud.retail.v2alpha.Model.TrainingState); + + /** Model servingState. */ + public servingState: (google.cloud.retail.v2alpha.Model.ServingState|keyof typeof google.cloud.retail.v2alpha.Model.ServingState); + + /** Model createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Model updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Model type. */ + public type: string; + + /** Model optimizationObjective. */ + public optimizationObjective: string; + + /** Model periodicTuningState. */ + public periodicTuningState: (google.cloud.retail.v2alpha.Model.PeriodicTuningState|keyof typeof google.cloud.retail.v2alpha.Model.PeriodicTuningState); + + /** Model lastTuneTime. */ + public lastTuneTime?: (google.protobuf.ITimestamp|null); + + /** Model tuningOperation. */ + public tuningOperation: string; + + /** Model dataState. */ + public dataState: (google.cloud.retail.v2alpha.Model.DataState|keyof typeof google.cloud.retail.v2alpha.Model.DataState); + + /** Model filteringOption. */ + public filteringOption: (google.cloud.retail.v2alpha.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2alpha.RecommendationsFilteringOption); + + /** Model servingConfigLists. */ + public servingConfigLists: google.cloud.retail.v2alpha.Model.IServingConfigList[]; + + /** Model trainingConfig. */ + public trainingConfig?: "pageOptimizationConfig"; + + /** + * Creates a new Model instance using the specified properties. + * @param [properties] Properties to set + * @returns Model instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IModel): google.cloud.retail.v2alpha.Model; + + /** + * Encodes the specified Model message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.verify|verify} messages. + * @param message Model message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IModel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Model message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.verify|verify} messages. + * @param message Model message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IModel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Model message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Model + * @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.cloud.retail.v2alpha.Model; + + /** + * Decodes a Model message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Model + * @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.cloud.retail.v2alpha.Model; + + /** + * Verifies a Model 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 Model message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Model + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Model; + + /** + * Creates a plain object from a Model message. Also converts values to other types if specified. + * @param message Model + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Model, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Model to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Model + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Model { + + /** Properties of a PageOptimizationConfig. */ + interface IPageOptimizationConfig { + + /** PageOptimizationConfig pageOptimizationEventType */ + pageOptimizationEventType?: (string|null); + + /** PageOptimizationConfig panels */ + panels?: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel[]|null); + + /** PageOptimizationConfig restriction */ + restriction?: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction|keyof typeof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction|null); + } + + /** Represents a PageOptimizationConfig. */ + class PageOptimizationConfig implements IPageOptimizationConfig { + + /** + * Constructs a new PageOptimizationConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Model.IPageOptimizationConfig); + + /** PageOptimizationConfig pageOptimizationEventType. */ + public pageOptimizationEventType: string; + + /** PageOptimizationConfig panels. */ + public panels: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel[]; + + /** PageOptimizationConfig restriction. */ + public restriction: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction|keyof typeof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction); + + /** + * Creates a new PageOptimizationConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns PageOptimizationConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Model.IPageOptimizationConfig): google.cloud.retail.v2alpha.Model.PageOptimizationConfig; + + /** + * Encodes the specified PageOptimizationConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.verify|verify} messages. + * @param message PageOptimizationConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Model.IPageOptimizationConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PageOptimizationConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.verify|verify} messages. + * @param message PageOptimizationConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Model.IPageOptimizationConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PageOptimizationConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PageOptimizationConfig + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig; + + /** + * Decodes a PageOptimizationConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PageOptimizationConfig + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig; + + /** + * Verifies a PageOptimizationConfig 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 PageOptimizationConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PageOptimizationConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Model.PageOptimizationConfig; + + /** + * Creates a plain object from a PageOptimizationConfig message. Also converts values to other types if specified. + * @param message PageOptimizationConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PageOptimizationConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PageOptimizationConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PageOptimizationConfig { + + /** Properties of a Candidate. */ + interface ICandidate { + + /** Candidate servingConfigId */ + servingConfigId?: (string|null); + } + + /** Represents a Candidate. */ + class Candidate implements ICandidate { + + /** + * Constructs a new Candidate. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate); + + /** Candidate servingConfigId. */ + public servingConfigId?: (string|null); + + /** Candidate candidate. */ + public candidate?: "servingConfigId"; + + /** + * Creates a new Candidate instance using the specified properties. + * @param [properties] Properties to set + * @returns Candidate instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate): google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate; + + /** + * Encodes the specified Candidate message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify|verify} messages. + * @param message Candidate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Candidate message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify|verify} messages. + * @param message Candidate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Candidate message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Candidate + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate; + + /** + * Decodes a Candidate message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Candidate + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate; + + /** + * Verifies a Candidate 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 Candidate message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Candidate + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate; + + /** + * Creates a plain object from a Candidate message. Also converts values to other types if specified. + * @param message Candidate + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Candidate to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Candidate + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Panel. */ + interface IPanel { + + /** Panel displayName */ + displayName?: (string|null); + + /** Panel candidates */ + candidates?: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate[]|null); + + /** Panel defaultCandidate */ + defaultCandidate?: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate|null); + } + + /** Represents a Panel. */ + class Panel implements IPanel { + + /** + * Constructs a new Panel. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel); + + /** Panel displayName. */ + public displayName: string; + + /** Panel candidates. */ + public candidates: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate[]; + + /** Panel defaultCandidate. */ + public defaultCandidate?: (google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate|null); + + /** + * Creates a new Panel instance using the specified properties. + * @param [properties] Properties to set + * @returns Panel instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel): google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel; + + /** + * Encodes the specified Panel message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.verify|verify} messages. + * @param message Panel message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Panel message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.verify|verify} messages. + * @param message Panel message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Panel message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Panel + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel; + + /** + * Decodes a Panel message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Panel + * @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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel; + + /** + * Verifies a Panel 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 Panel message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Panel + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel; + + /** + * Creates a plain object from a Panel message. Also converts values to other types if specified. + * @param message Panel + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Panel to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Panel + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Restriction enum. */ + enum Restriction { + RESTRICTION_UNSPECIFIED = 0, + NO_RESTRICTION = 1, + UNIQUE_SERVING_CONFIG_RESTRICTION = 2, + UNIQUE_MODEL_RESTRICTION = 3, + UNIQUE_MODEL_TYPE_RESTRICTION = 4 + } + } + + /** Properties of a ServingConfigList. */ + interface IServingConfigList { + + /** ServingConfigList servingConfigIds */ + servingConfigIds?: (string[]|null); + } + + /** Represents a ServingConfigList. */ + class ServingConfigList implements IServingConfigList { + + /** + * Constructs a new ServingConfigList. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.Model.IServingConfigList); + + /** ServingConfigList servingConfigIds. */ + public servingConfigIds: string[]; + + /** + * Creates a new ServingConfigList instance using the specified properties. + * @param [properties] Properties to set + * @returns ServingConfigList instance + */ + public static create(properties?: google.cloud.retail.v2alpha.Model.IServingConfigList): google.cloud.retail.v2alpha.Model.ServingConfigList; + + /** + * Encodes the specified ServingConfigList message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.ServingConfigList.verify|verify} messages. + * @param message ServingConfigList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.Model.IServingConfigList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServingConfigList message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.ServingConfigList.verify|verify} messages. + * @param message ServingConfigList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.Model.IServingConfigList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServingConfigList + * @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.cloud.retail.v2alpha.Model.ServingConfigList; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServingConfigList + * @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.cloud.retail.v2alpha.Model.ServingConfigList; + + /** + * Verifies a ServingConfigList 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 ServingConfigList message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServingConfigList + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.Model.ServingConfigList; + + /** + * Creates a plain object from a ServingConfigList message. Also converts values to other types if specified. + * @param message ServingConfigList + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.Model.ServingConfigList, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServingConfigList to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServingConfigList + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** ServingState enum. */ + enum ServingState { + SERVING_STATE_UNSPECIFIED = 0, + INACTIVE = 1, + ACTIVE = 2, + TUNED = 3 + } + + /** TrainingState enum. */ + enum TrainingState { + TRAINING_STATE_UNSPECIFIED = 0, + PAUSED = 1, + TRAINING = 2 + } + + /** PeriodicTuningState enum. */ + enum PeriodicTuningState { + PERIODIC_TUNING_STATE_UNSPECIFIED = 0, + PERIODIC_TUNING_DISABLED = 1, + ALL_TUNING_DISABLED = 3, + PERIODIC_TUNING_ENABLED = 2 + } + + /** DataState enum. */ + enum DataState { + DATA_STATE_UNSPECIFIED = 0, + DATA_OK = 1, + DATA_ERROR = 2 + } + } + + /** Represents a ModelService */ + class ModelService extends $protobuf.rpc.Service { + + /** + * Constructs a new ModelService 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 ModelService 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): ModelService; + + /** + * Calls CreateModel. + * @param request CreateModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createModel(request: google.cloud.retail.v2alpha.ICreateModelRequest, callback: google.cloud.retail.v2alpha.ModelService.CreateModelCallback): void; + + /** + * Calls CreateModel. + * @param request CreateModelRequest message or plain object + * @returns Promise + */ + public createModel(request: google.cloud.retail.v2alpha.ICreateModelRequest): Promise; + + /** + * Calls PauseModel. + * @param request PauseModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public pauseModel(request: google.cloud.retail.v2alpha.IPauseModelRequest, callback: google.cloud.retail.v2alpha.ModelService.PauseModelCallback): void; + + /** + * Calls PauseModel. + * @param request PauseModelRequest message or plain object + * @returns Promise + */ + public pauseModel(request: google.cloud.retail.v2alpha.IPauseModelRequest): Promise; + + /** + * Calls ResumeModel. + * @param request ResumeModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public resumeModel(request: google.cloud.retail.v2alpha.IResumeModelRequest, callback: google.cloud.retail.v2alpha.ModelService.ResumeModelCallback): void; + + /** + * Calls ResumeModel. + * @param request ResumeModelRequest message or plain object + * @returns Promise + */ + public resumeModel(request: google.cloud.retail.v2alpha.IResumeModelRequest): Promise; + + /** + * Calls DeleteModel. + * @param request DeleteModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteModel(request: google.cloud.retail.v2alpha.IDeleteModelRequest, callback: google.cloud.retail.v2alpha.ModelService.DeleteModelCallback): void; + + /** + * Calls DeleteModel. + * @param request DeleteModelRequest message or plain object + * @returns Promise + */ + public deleteModel(request: google.cloud.retail.v2alpha.IDeleteModelRequest): Promise; + + /** + * Calls ListModels. + * @param request ListModelsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListModelsResponse + */ + public listModels(request: google.cloud.retail.v2alpha.IListModelsRequest, callback: google.cloud.retail.v2alpha.ModelService.ListModelsCallback): void; + + /** + * Calls ListModels. + * @param request ListModelsRequest message or plain object + * @returns Promise + */ + public listModels(request: google.cloud.retail.v2alpha.IListModelsRequest): Promise; + + /** + * Calls UpdateModel. + * @param request UpdateModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public updateModel(request: google.cloud.retail.v2alpha.IUpdateModelRequest, callback: google.cloud.retail.v2alpha.ModelService.UpdateModelCallback): void; + + /** + * Calls UpdateModel. + * @param request UpdateModelRequest message or plain object + * @returns Promise + */ + public updateModel(request: google.cloud.retail.v2alpha.IUpdateModelRequest): Promise; + + /** + * Calls TuneModel. + * @param request TuneModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public tuneModel(request: google.cloud.retail.v2alpha.ITuneModelRequest, callback: google.cloud.retail.v2alpha.ModelService.TuneModelCallback): void; + + /** + * Calls TuneModel. + * @param request TuneModelRequest message or plain object + * @returns Promise + */ + public tuneModel(request: google.cloud.retail.v2alpha.ITuneModelRequest): Promise; + } + + namespace ModelService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|createModel}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateModelCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|pauseModel}. + * @param error Error, if any + * @param [response] Model + */ + type PauseModelCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|resumeModel}. + * @param error Error, if any + * @param [response] Model + */ + type ResumeModelCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|deleteModel}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteModelCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|listModels}. + * @param error Error, if any + * @param [response] ListModelsResponse + */ + type ListModelsCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ListModelsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|updateModel}. + * @param error Error, if any + * @param [response] Model + */ + type UpdateModelCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|tuneModel}. + * @param error Error, if any + * @param [response] Operation + */ + type TuneModelCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateModelRequest. */ + interface ICreateModelRequest { + + /** CreateModelRequest parent */ + parent?: (string|null); + + /** CreateModelRequest model */ + model?: (google.cloud.retail.v2alpha.IModel|null); + + /** CreateModelRequest dryRun */ + dryRun?: (boolean|null); + } + + /** Represents a CreateModelRequest. */ + class CreateModelRequest implements ICreateModelRequest { + + /** + * Constructs a new CreateModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICreateModelRequest); + + /** CreateModelRequest parent. */ + public parent: string; + + /** CreateModelRequest model. */ + public model?: (google.cloud.retail.v2alpha.IModel|null); + + /** CreateModelRequest dryRun. */ + public dryRun: boolean; + + /** + * Creates a new CreateModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICreateModelRequest): google.cloud.retail.v2alpha.CreateModelRequest; + + /** + * Encodes the specified CreateModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelRequest.verify|verify} messages. + * @param message CreateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICreateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelRequest.verify|verify} messages. + * @param message CreateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICreateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateModelRequest + * @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.cloud.retail.v2alpha.CreateModelRequest; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateModelRequest + * @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.cloud.retail.v2alpha.CreateModelRequest; + + /** + * Verifies a CreateModelRequest 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 CreateModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CreateModelRequest; + + /** + * Creates a plain object from a CreateModelRequest message. Also converts values to other types if specified. + * @param message CreateModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CreateModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateModelRequest. */ + interface IUpdateModelRequest { + + /** UpdateModelRequest model */ + model?: (google.cloud.retail.v2alpha.IModel|null); + + /** UpdateModelRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateModelRequest. */ + class UpdateModelRequest implements IUpdateModelRequest { + + /** + * Constructs a new UpdateModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateModelRequest); + + /** UpdateModelRequest model. */ + public model?: (google.cloud.retail.v2alpha.IModel|null); + + /** UpdateModelRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateModelRequest): google.cloud.retail.v2alpha.UpdateModelRequest; + + /** + * Encodes the specified UpdateModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateModelRequest.verify|verify} messages. + * @param message UpdateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateModelRequest.verify|verify} messages. + * @param message UpdateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateModelRequest + * @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.cloud.retail.v2alpha.UpdateModelRequest; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateModelRequest + * @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.cloud.retail.v2alpha.UpdateModelRequest; + + /** + * Verifies an UpdateModelRequest 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 UpdateModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateModelRequest; + + /** + * Creates a plain object from an UpdateModelRequest message. Also converts values to other types if specified. + * @param message UpdateModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PauseModelRequest. */ + interface IPauseModelRequest { + + /** PauseModelRequest name */ + name?: (string|null); + } + + /** Represents a PauseModelRequest. */ + class PauseModelRequest implements IPauseModelRequest { + + /** + * Constructs a new PauseModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPauseModelRequest); + + /** PauseModelRequest name. */ + public name: string; + + /** + * Creates a new PauseModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PauseModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPauseModelRequest): google.cloud.retail.v2alpha.PauseModelRequest; + + /** + * Encodes the specified PauseModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PauseModelRequest.verify|verify} messages. + * @param message PauseModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPauseModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PauseModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PauseModelRequest.verify|verify} messages. + * @param message PauseModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPauseModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PauseModelRequest + * @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.cloud.retail.v2alpha.PauseModelRequest; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PauseModelRequest + * @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.cloud.retail.v2alpha.PauseModelRequest; + + /** + * Verifies a PauseModelRequest 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 PauseModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PauseModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PauseModelRequest; + + /** + * Creates a plain object from a PauseModelRequest message. Also converts values to other types if specified. + * @param message PauseModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PauseModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PauseModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PauseModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ResumeModelRequest. */ + interface IResumeModelRequest { + + /** ResumeModelRequest name */ + name?: (string|null); + } + + /** Represents a ResumeModelRequest. */ + class ResumeModelRequest implements IResumeModelRequest { + + /** + * Constructs a new ResumeModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IResumeModelRequest); + + /** ResumeModelRequest name. */ + public name: string; + + /** + * Creates a new ResumeModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ResumeModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IResumeModelRequest): google.cloud.retail.v2alpha.ResumeModelRequest; + + /** + * Encodes the specified ResumeModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ResumeModelRequest.verify|verify} messages. + * @param message ResumeModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IResumeModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ResumeModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ResumeModelRequest.verify|verify} messages. + * @param message ResumeModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IResumeModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ResumeModelRequest + * @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.cloud.retail.v2alpha.ResumeModelRequest; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ResumeModelRequest + * @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.cloud.retail.v2alpha.ResumeModelRequest; + + /** + * Verifies a ResumeModelRequest 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 ResumeModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResumeModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ResumeModelRequest; + + /** + * Creates a plain object from a ResumeModelRequest message. Also converts values to other types if specified. + * @param message ResumeModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ResumeModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResumeModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResumeModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListModelsRequest. */ + interface IListModelsRequest { + + /** ListModelsRequest parent */ + parent?: (string|null); + + /** ListModelsRequest pageSize */ + pageSize?: (number|null); + + /** ListModelsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListModelsRequest. */ + class ListModelsRequest implements IListModelsRequest { + + /** + * Constructs a new ListModelsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListModelsRequest); + + /** ListModelsRequest parent. */ + public parent: string; + + /** ListModelsRequest pageSize. */ + public pageSize: number; + + /** ListModelsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListModelsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListModelsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListModelsRequest): google.cloud.retail.v2alpha.ListModelsRequest; + + /** + * Encodes the specified ListModelsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsRequest.verify|verify} messages. + * @param message ListModelsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListModelsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListModelsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsRequest.verify|verify} messages. + * @param message ListModelsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListModelsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListModelsRequest + * @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.cloud.retail.v2alpha.ListModelsRequest; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListModelsRequest + * @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.cloud.retail.v2alpha.ListModelsRequest; + + /** + * Verifies a ListModelsRequest 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 ListModelsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListModelsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListModelsRequest; + + /** + * Creates a plain object from a ListModelsRequest message. Also converts values to other types if specified. + * @param message ListModelsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListModelsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListModelsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListModelsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteModelRequest. */ + interface IDeleteModelRequest { + + /** DeleteModelRequest name */ + name?: (string|null); + } + + /** Represents a DeleteModelRequest. */ + class DeleteModelRequest implements IDeleteModelRequest { + + /** + * Constructs a new DeleteModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IDeleteModelRequest); + + /** DeleteModelRequest name. */ + public name: string; + + /** + * Creates a new DeleteModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IDeleteModelRequest): google.cloud.retail.v2alpha.DeleteModelRequest; + + /** + * Encodes the specified DeleteModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteModelRequest.verify|verify} messages. + * @param message DeleteModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IDeleteModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteModelRequest.verify|verify} messages. + * @param message DeleteModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IDeleteModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteModelRequest + * @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.cloud.retail.v2alpha.DeleteModelRequest; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteModelRequest + * @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.cloud.retail.v2alpha.DeleteModelRequest; + + /** + * Verifies a DeleteModelRequest 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 DeleteModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.DeleteModelRequest; + + /** + * Creates a plain object from a DeleteModelRequest message. Also converts values to other types if specified. + * @param message DeleteModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.DeleteModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListModelsResponse. */ + interface IListModelsResponse { + + /** ListModelsResponse models */ + models?: (google.cloud.retail.v2alpha.IModel[]|null); + + /** ListModelsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListModelsResponse. */ + class ListModelsResponse implements IListModelsResponse { + + /** + * Constructs a new ListModelsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListModelsResponse); + + /** ListModelsResponse models. */ + public models: google.cloud.retail.v2alpha.IModel[]; + + /** ListModelsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListModelsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListModelsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListModelsResponse): google.cloud.retail.v2alpha.ListModelsResponse; + + /** + * Encodes the specified ListModelsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsResponse.verify|verify} messages. + * @param message ListModelsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListModelsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListModelsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsResponse.verify|verify} messages. + * @param message ListModelsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListModelsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListModelsResponse + * @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.cloud.retail.v2alpha.ListModelsResponse; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListModelsResponse + * @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.cloud.retail.v2alpha.ListModelsResponse; + + /** + * Verifies a ListModelsResponse 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 ListModelsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListModelsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListModelsResponse; + + /** + * Creates a plain object from a ListModelsResponse message. Also converts values to other types if specified. + * @param message ListModelsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListModelsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListModelsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListModelsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelRequest. */ + interface ITuneModelRequest { + + /** TuneModelRequest name */ + name?: (string|null); + } + + /** Represents a TuneModelRequest. */ + class TuneModelRequest implements ITuneModelRequest { + + /** + * Constructs a new TuneModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ITuneModelRequest); + + /** TuneModelRequest name. */ + public name: string; + + /** + * Creates a new TuneModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ITuneModelRequest): google.cloud.retail.v2alpha.TuneModelRequest; + + /** + * Encodes the specified TuneModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelRequest.verify|verify} messages. + * @param message TuneModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ITuneModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelRequest.verify|verify} messages. + * @param message TuneModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ITuneModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelRequest + * @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.cloud.retail.v2alpha.TuneModelRequest; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelRequest + * @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.cloud.retail.v2alpha.TuneModelRequest; + + /** + * Verifies a TuneModelRequest 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 TuneModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.TuneModelRequest; + + /** + * Creates a plain object from a TuneModelRequest message. Also converts values to other types if specified. + * @param message TuneModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.TuneModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreateModelMetadata. */ + interface ICreateModelMetadata { + + /** CreateModelMetadata model */ + model?: (string|null); + } + + /** Represents a CreateModelMetadata. */ + class CreateModelMetadata implements ICreateModelMetadata { + + /** + * Constructs a new CreateModelMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICreateModelMetadata); + + /** CreateModelMetadata model. */ + public model: string; + + /** + * Creates a new CreateModelMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateModelMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICreateModelMetadata): google.cloud.retail.v2alpha.CreateModelMetadata; + + /** + * Encodes the specified CreateModelMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelMetadata.verify|verify} messages. + * @param message CreateModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICreateModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelMetadata.verify|verify} messages. + * @param message CreateModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICreateModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateModelMetadata + * @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.cloud.retail.v2alpha.CreateModelMetadata; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateModelMetadata + * @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.cloud.retail.v2alpha.CreateModelMetadata; + + /** + * Verifies a CreateModelMetadata 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 CreateModelMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateModelMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CreateModelMetadata; + + /** + * Creates a plain object from a CreateModelMetadata message. Also converts values to other types if specified. + * @param message CreateModelMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CreateModelMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateModelMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateModelMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelMetadata. */ + interface ITuneModelMetadata { + + /** TuneModelMetadata model */ + model?: (string|null); + } + + /** Represents a TuneModelMetadata. */ + class TuneModelMetadata implements ITuneModelMetadata { + + /** + * Constructs a new TuneModelMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ITuneModelMetadata); + + /** TuneModelMetadata model. */ + public model: string; + + /** + * Creates a new TuneModelMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ITuneModelMetadata): google.cloud.retail.v2alpha.TuneModelMetadata; + + /** + * Encodes the specified TuneModelMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelMetadata.verify|verify} messages. + * @param message TuneModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ITuneModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelMetadata.verify|verify} messages. + * @param message TuneModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ITuneModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelMetadata + * @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.cloud.retail.v2alpha.TuneModelMetadata; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelMetadata + * @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.cloud.retail.v2alpha.TuneModelMetadata; + + /** + * Verifies a TuneModelMetadata 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 TuneModelMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.TuneModelMetadata; + + /** + * Creates a plain object from a TuneModelMetadata message. Also converts values to other types if specified. + * @param message TuneModelMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.TuneModelMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelResponse. */ + interface ITuneModelResponse { + } + + /** Represents a TuneModelResponse. */ + class TuneModelResponse implements ITuneModelResponse { + + /** + * Constructs a new TuneModelResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ITuneModelResponse); + + /** + * Creates a new TuneModelResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ITuneModelResponse): google.cloud.retail.v2alpha.TuneModelResponse; + + /** + * Encodes the specified TuneModelResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelResponse.verify|verify} messages. + * @param message TuneModelResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ITuneModelResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelResponse.verify|verify} messages. + * @param message TuneModelResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ITuneModelResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelResponse + * @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.cloud.retail.v2alpha.TuneModelResponse; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelResponse + * @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.cloud.retail.v2alpha.TuneModelResponse; + + /** + * Verifies a TuneModelResponse 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 TuneModelResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.TuneModelResponse; + + /** + * Creates a plain object from a TuneModelResponse message. Also converts values to other types if specified. + * @param message TuneModelResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.TuneModelResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a PredictionService */ + class PredictionService extends $protobuf.rpc.Service { + + /** + * Constructs a new PredictionService 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 PredictionService 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): PredictionService; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PredictResponse + */ + public predict(request: google.cloud.retail.v2alpha.IPredictRequest, callback: google.cloud.retail.v2alpha.PredictionService.PredictCallback): void; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @returns Promise + */ + public predict(request: google.cloud.retail.v2alpha.IPredictRequest): Promise; + } + + namespace PredictionService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.PredictionService|predict}. + * @param error Error, if any + * @param [response] PredictResponse + */ + type PredictCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.PredictResponse) => void; + } + + /** Properties of a PredictRequest. */ + interface IPredictRequest { + + /** PredictRequest placement */ + placement?: (string|null); + + /** PredictRequest userEvent */ + userEvent?: (google.cloud.retail.v2alpha.IUserEvent|null); + + /** PredictRequest pageSize */ + pageSize?: (number|null); + + /** PredictRequest pageToken */ + pageToken?: (string|null); + + /** PredictRequest filter */ + filter?: (string|null); + + /** PredictRequest validateOnly */ + validateOnly?: (boolean|null); + + /** PredictRequest params */ + params?: ({ [k: string]: google.protobuf.IValue }|null); + + /** PredictRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a PredictRequest. */ + class PredictRequest implements IPredictRequest { + + /** + * Constructs a new PredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPredictRequest); + + /** PredictRequest placement. */ + public placement: string; + + /** PredictRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2alpha.IUserEvent|null); + + /** PredictRequest pageSize. */ + public pageSize: number; + + /** PredictRequest pageToken. */ + public pageToken: string; + + /** PredictRequest filter. */ + public filter: string; + + /** PredictRequest validateOnly. */ + public validateOnly: boolean; + + /** PredictRequest params. */ + public params: { [k: string]: google.protobuf.IValue }; + + /** PredictRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPredictRequest): google.cloud.retail.v2alpha.PredictRequest; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictRequest + * @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.cloud.retail.v2alpha.PredictRequest; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictRequest + * @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.cloud.retail.v2alpha.PredictRequest; + + /** + * Verifies a PredictRequest 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 PredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PredictRequest; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @param message PredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PredictResponse. */ + interface IPredictResponse { + + /** PredictResponse results */ + results?: (google.cloud.retail.v2alpha.PredictResponse.IPredictionResult[]|null); + + /** PredictResponse attributionToken */ + attributionToken?: (string|null); + + /** PredictResponse missingIds */ + missingIds?: (string[]|null); + + /** PredictResponse validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents a PredictResponse. */ + class PredictResponse implements IPredictResponse { + + /** + * Constructs a new PredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPredictResponse); + + /** PredictResponse results. */ + public results: google.cloud.retail.v2alpha.PredictResponse.IPredictionResult[]; + + /** PredictResponse attributionToken. */ + public attributionToken: string; + + /** PredictResponse missingIds. */ + public missingIds: string[]; + + /** PredictResponse validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPredictResponse): google.cloud.retail.v2alpha.PredictResponse; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictResponse + * @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.cloud.retail.v2alpha.PredictResponse; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictResponse + * @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.cloud.retail.v2alpha.PredictResponse; + + /** + * Verifies a PredictResponse 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 PredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PredictResponse; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @param message PredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PredictResponse { + + /** Properties of a PredictionResult. */ + interface IPredictionResult { + + /** PredictionResult id */ + id?: (string|null); + + /** PredictionResult metadata */ + metadata?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a PredictionResult. */ + class PredictionResult implements IPredictionResult { + + /** + * Constructs a new PredictionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.PredictResponse.IPredictionResult); + + /** PredictionResult id. */ + public id: string; + + /** PredictionResult metadata. */ + public metadata: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictionResult instance + */ + public static create(properties?: google.cloud.retail.v2alpha.PredictResponse.IPredictionResult): google.cloud.retail.v2alpha.PredictResponse.PredictionResult; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictionResult + * @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.cloud.retail.v2alpha.PredictResponse.PredictionResult; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictionResult + * @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.cloud.retail.v2alpha.PredictResponse.PredictionResult; + + /** + * Verifies a PredictionResult 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 PredictionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PredictResponse.PredictionResult; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @param message PredictionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PredictResponse.PredictionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Represents a ProductService */ + class ProductService extends $protobuf.rpc.Service { + + /** + * Constructs a new ProductService 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 ProductService 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): ProductService; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public createProduct(request: google.cloud.retail.v2alpha.ICreateProductRequest, callback: google.cloud.retail.v2alpha.ProductService.CreateProductCallback): void; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @returns Promise + */ + public createProduct(request: google.cloud.retail.v2alpha.ICreateProductRequest): Promise; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public getProduct(request: google.cloud.retail.v2alpha.IGetProductRequest, callback: google.cloud.retail.v2alpha.ProductService.GetProductCallback): void; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @returns Promise + */ + public getProduct(request: google.cloud.retail.v2alpha.IGetProductRequest): Promise; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListProductsResponse + */ + public listProducts(request: google.cloud.retail.v2alpha.IListProductsRequest, callback: google.cloud.retail.v2alpha.ProductService.ListProductsCallback): void; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @returns Promise + */ + public listProducts(request: google.cloud.retail.v2alpha.IListProductsRequest): Promise; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public updateProduct(request: google.cloud.retail.v2alpha.IUpdateProductRequest, callback: google.cloud.retail.v2alpha.ProductService.UpdateProductCallback): void; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @returns Promise + */ + public updateProduct(request: google.cloud.retail.v2alpha.IUpdateProductRequest): Promise; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteProduct(request: google.cloud.retail.v2alpha.IDeleteProductRequest, callback: google.cloud.retail.v2alpha.ProductService.DeleteProductCallback): void; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @returns Promise + */ + public deleteProduct(request: google.cloud.retail.v2alpha.IDeleteProductRequest): Promise; + + /** + * Calls PurgeProducts. + * @param request PurgeProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public purgeProducts(request: google.cloud.retail.v2alpha.IPurgeProductsRequest, callback: google.cloud.retail.v2alpha.ProductService.PurgeProductsCallback): void; + + /** + * Calls PurgeProducts. + * @param request PurgeProductsRequest message or plain object + * @returns Promise + */ + public purgeProducts(request: google.cloud.retail.v2alpha.IPurgeProductsRequest): Promise; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importProducts(request: google.cloud.retail.v2alpha.IImportProductsRequest, callback: google.cloud.retail.v2alpha.ProductService.ImportProductsCallback): void; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @returns Promise + */ + public importProducts(request: google.cloud.retail.v2alpha.IImportProductsRequest): Promise; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public setInventory(request: google.cloud.retail.v2alpha.ISetInventoryRequest, callback: google.cloud.retail.v2alpha.ProductService.SetInventoryCallback): void; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @returns Promise + */ + public setInventory(request: google.cloud.retail.v2alpha.ISetInventoryRequest): Promise; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, callback: google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlacesCallback): void; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest): Promise; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, callback: google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlacesCallback): void; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest): Promise; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addLocalInventories(request: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, callback: google.cloud.retail.v2alpha.ProductService.AddLocalInventoriesCallback): void; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @returns Promise + */ + public addLocalInventories(request: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest): Promise; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeLocalInventories(request: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, callback: google.cloud.retail.v2alpha.ProductService.RemoveLocalInventoriesCallback): void; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @returns Promise + */ + public removeLocalInventories(request: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest): Promise; + } + + namespace ProductService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|createProduct}. + * @param error Error, if any + * @param [response] Product + */ + type CreateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|getProduct}. + * @param error Error, if any + * @param [response] Product + */ + type GetProductCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|listProducts}. + * @param error Error, if any + * @param [response] ListProductsResponse + */ + type ListProductsCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ListProductsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|updateProduct}. + * @param error Error, if any + * @param [response] Product + */ + type UpdateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|deleteProduct}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteProductCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|purgeProducts}. + * @param error Error, if any + * @param [response] Operation + */ + type PurgeProductsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|importProducts}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportProductsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|setInventory}. + * @param error Error, if any + * @param [response] Operation + */ + type SetInventoryCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|addFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type AddFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|removeFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|addLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type AddLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|removeLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateProductRequest. */ + interface ICreateProductRequest { + + /** CreateProductRequest parent */ + parent?: (string|null); + + /** CreateProductRequest product */ + product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** CreateProductRequest productId */ + productId?: (string|null); + } + + /** Represents a CreateProductRequest. */ + class CreateProductRequest implements ICreateProductRequest { + + /** + * Constructs a new CreateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICreateProductRequest); + + /** CreateProductRequest parent. */ + public parent: string; + + /** CreateProductRequest product. */ + public product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** CreateProductRequest productId. */ + public productId: string; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICreateProductRequest): google.cloud.retail.v2alpha.CreateProductRequest; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateProductRequest + * @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.cloud.retail.v2alpha.CreateProductRequest; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateProductRequest + * @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.cloud.retail.v2alpha.CreateProductRequest; + + /** + * Verifies a CreateProductRequest 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 CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CreateProductRequest; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @param message CreateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CreateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetProductRequest. */ + interface IGetProductRequest { + + /** GetProductRequest name */ + name?: (string|null); + } + + /** Represents a GetProductRequest. */ + class GetProductRequest implements IGetProductRequest { + + /** + * Constructs a new GetProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetProductRequest); + + /** GetProductRequest name. */ + public name: string; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetProductRequest): google.cloud.retail.v2alpha.GetProductRequest; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetProductRequest + * @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.cloud.retail.v2alpha.GetProductRequest; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetProductRequest + * @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.cloud.retail.v2alpha.GetProductRequest; + + /** + * Verifies a GetProductRequest 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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetProductRequest; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @param message GetProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateProductRequest. */ + interface IUpdateProductRequest { + + /** UpdateProductRequest product */ + product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** UpdateProductRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an UpdateProductRequest. */ + class UpdateProductRequest implements IUpdateProductRequest { + + /** + * Constructs a new UpdateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateProductRequest); + + /** UpdateProductRequest product. */ + public product?: (google.cloud.retail.v2alpha.IProduct|null); + + /** UpdateProductRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateProductRequest): google.cloud.retail.v2alpha.UpdateProductRequest; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateProductRequest + * @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.cloud.retail.v2alpha.UpdateProductRequest; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateProductRequest + * @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.cloud.retail.v2alpha.UpdateProductRequest; + + /** + * Verifies an UpdateProductRequest 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 UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateProductRequest; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @param message UpdateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteProductRequest. */ + interface IDeleteProductRequest { + + /** DeleteProductRequest name */ + name?: (string|null); + } + + /** Represents a DeleteProductRequest. */ + class DeleteProductRequest implements IDeleteProductRequest { + + /** + * Constructs a new DeleteProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IDeleteProductRequest); + + /** DeleteProductRequest name. */ + public name: string; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IDeleteProductRequest): google.cloud.retail.v2alpha.DeleteProductRequest; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteProductRequest + * @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.cloud.retail.v2alpha.DeleteProductRequest; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteProductRequest + * @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.cloud.retail.v2alpha.DeleteProductRequest; + + /** + * Verifies a DeleteProductRequest 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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.DeleteProductRequest; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @param message DeleteProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.DeleteProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsRequest. */ + interface IListProductsRequest { + + /** ListProductsRequest parent */ + parent?: (string|null); + + /** ListProductsRequest pageSize */ + pageSize?: (number|null); + + /** ListProductsRequest pageToken */ + pageToken?: (string|null); + + /** ListProductsRequest filter */ + filter?: (string|null); + + /** ListProductsRequest readMask */ + readMask?: (google.protobuf.IFieldMask|null); + + /** ListProductsRequest requireTotalSize */ + requireTotalSize?: (boolean|null); + } + + /** Represents a ListProductsRequest. */ + class ListProductsRequest implements IListProductsRequest { + + /** + * Constructs a new ListProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListProductsRequest); + + /** ListProductsRequest parent. */ + public parent: string; + + /** ListProductsRequest pageSize. */ + public pageSize: number; + + /** ListProductsRequest pageToken. */ + public pageToken: string; + + /** ListProductsRequest filter. */ + public filter: string; + + /** ListProductsRequest readMask. */ + public readMask?: (google.protobuf.IFieldMask|null); + + /** ListProductsRequest requireTotalSize. */ + public requireTotalSize: boolean; + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListProductsRequest): google.cloud.retail.v2alpha.ListProductsRequest; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsRequest + * @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.cloud.retail.v2alpha.ListProductsRequest; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsRequest + * @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.cloud.retail.v2alpha.ListProductsRequest; + + /** + * Verifies a ListProductsRequest 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 ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListProductsRequest; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @param message ListProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsResponse. */ + interface IListProductsResponse { + + /** ListProductsResponse products */ + products?: (google.cloud.retail.v2alpha.IProduct[]|null); + + /** ListProductsResponse nextPageToken */ + nextPageToken?: (string|null); + + /** ListProductsResponse totalSize */ + totalSize?: (number|null); + } + + /** Represents a ListProductsResponse. */ + class ListProductsResponse implements IListProductsResponse { + + /** + * Constructs a new ListProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListProductsResponse); + + /** ListProductsResponse products. */ + public products: google.cloud.retail.v2alpha.IProduct[]; + + /** ListProductsResponse nextPageToken. */ + public nextPageToken: string; + + /** ListProductsResponse totalSize. */ + public totalSize: number; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListProductsResponse): google.cloud.retail.v2alpha.ListProductsResponse; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsResponse + * @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.cloud.retail.v2alpha.ListProductsResponse; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsResponse + * @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.cloud.retail.v2alpha.ListProductsResponse; + + /** + * Verifies a ListProductsResponse 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 ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListProductsResponse; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @param message ListProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryRequest. */ + interface ISetInventoryRequest { + + /** SetInventoryRequest inventory */ + inventory?: (google.cloud.retail.v2alpha.IProduct|null); + + /** SetInventoryRequest setMask */ + setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a SetInventoryRequest. */ + class SetInventoryRequest implements ISetInventoryRequest { + + /** + * Constructs a new SetInventoryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISetInventoryRequest); + + /** SetInventoryRequest inventory. */ + public inventory?: (google.cloud.retail.v2alpha.IProduct|null); + + /** SetInventoryRequest setMask. */ + public setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISetInventoryRequest): google.cloud.retail.v2alpha.SetInventoryRequest; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryRequest + * @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.cloud.retail.v2alpha.SetInventoryRequest; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryRequest + * @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.cloud.retail.v2alpha.SetInventoryRequest; + + /** + * Verifies a SetInventoryRequest 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 SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SetInventoryRequest; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @param message SetInventoryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SetInventoryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryMetadata. */ + interface ISetInventoryMetadata { + } + + /** Represents a SetInventoryMetadata. */ + class SetInventoryMetadata implements ISetInventoryMetadata { + + /** + * Constructs a new SetInventoryMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISetInventoryMetadata); + + /** + * Creates a new SetInventoryMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISetInventoryMetadata): google.cloud.retail.v2alpha.SetInventoryMetadata; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryMetadata + * @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.cloud.retail.v2alpha.SetInventoryMetadata; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryMetadata + * @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.cloud.retail.v2alpha.SetInventoryMetadata; + + /** + * Verifies a SetInventoryMetadata 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 SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SetInventoryMetadata; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @param message SetInventoryMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SetInventoryMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryResponse. */ + interface ISetInventoryResponse { + } + + /** Represents a SetInventoryResponse. */ + class SetInventoryResponse implements ISetInventoryResponse { + + /** + * Constructs a new SetInventoryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ISetInventoryResponse); + + /** + * Creates a new SetInventoryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ISetInventoryResponse): google.cloud.retail.v2alpha.SetInventoryResponse; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryResponse + * @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.cloud.retail.v2alpha.SetInventoryResponse; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryResponse + * @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.cloud.retail.v2alpha.SetInventoryResponse; + + /** + * Verifies a SetInventoryResponse 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 SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.SetInventoryResponse; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @param message SetInventoryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.SetInventoryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesRequest. */ + interface IAddFulfillmentPlacesRequest { + + /** AddFulfillmentPlacesRequest product */ + product?: (string|null); + + /** AddFulfillmentPlacesRequest type */ + type?: (string|null); + + /** AddFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** AddFulfillmentPlacesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddFulfillmentPlacesRequest. */ + class AddFulfillmentPlacesRequest implements IAddFulfillmentPlacesRequest { + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest); + + /** AddFulfillmentPlacesRequest product. */ + public product: string; + + /** AddFulfillmentPlacesRequest type. */ + public type: string; + + /** AddFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** AddFulfillmentPlacesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest): google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; + + /** + * Verifies an AddFulfillmentPlacesRequest 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 AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesMetadata. */ + interface IAddFulfillmentPlacesMetadata { + } + + /** Represents an AddFulfillmentPlacesMetadata. */ + class AddFulfillmentPlacesMetadata implements IAddFulfillmentPlacesMetadata { + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata); + + /** + * Creates a new AddFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata): google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; + + /** + * Verifies an AddFulfillmentPlacesMetadata 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 AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesResponse. */ + interface IAddFulfillmentPlacesResponse { + } + + /** Represents an AddFulfillmentPlacesResponse. */ + class AddFulfillmentPlacesResponse implements IAddFulfillmentPlacesResponse { + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse); + + /** + * Creates a new AddFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse): google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; + + /** + * Verifies an AddFulfillmentPlacesResponse 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 AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesRequest. */ + interface IAddLocalInventoriesRequest { + + /** AddLocalInventoriesRequest product */ + product?: (string|null); + + /** AddLocalInventoriesRequest localInventories */ + localInventories?: (google.cloud.retail.v2alpha.ILocalInventory[]|null); + + /** AddLocalInventoriesRequest addMask */ + addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddLocalInventoriesRequest. */ + class AddLocalInventoriesRequest implements IAddLocalInventoriesRequest { + + /** + * Constructs a new AddLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest); + + /** AddLocalInventoriesRequest product. */ + public product: string; + + /** AddLocalInventoriesRequest localInventories. */ + public localInventories: google.cloud.retail.v2alpha.ILocalInventory[]; + + /** AddLocalInventoriesRequest addMask. */ + public addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest): google.cloud.retail.v2alpha.AddLocalInventoriesRequest; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2alpha.AddLocalInventoriesRequest; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2alpha.AddLocalInventoriesRequest; + + /** + * Verifies an AddLocalInventoriesRequest 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 AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddLocalInventoriesRequest; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message AddLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesMetadata. */ + interface IAddLocalInventoriesMetadata { + } + + /** Represents an AddLocalInventoriesMetadata. */ + class AddLocalInventoriesMetadata implements IAddLocalInventoriesMetadata { + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata); + + /** + * Creates a new AddLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata): google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2alpha.AddLocalInventoriesMetadata; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2alpha.AddLocalInventoriesMetadata; + + /** + * Verifies an AddLocalInventoriesMetadata 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 AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddLocalInventoriesMetadata; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message AddLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesResponse. */ + interface IAddLocalInventoriesResponse { + } + + /** Represents an AddLocalInventoriesResponse. */ + class AddLocalInventoriesResponse implements IAddLocalInventoriesResponse { + + /** + * Constructs a new AddLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesResponse); + + /** + * Creates a new AddLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddLocalInventoriesResponse): google.cloud.retail.v2alpha.AddLocalInventoriesResponse; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2alpha.AddLocalInventoriesResponse; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2alpha.AddLocalInventoriesResponse; + + /** + * Verifies an AddLocalInventoriesResponse 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 AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddLocalInventoriesResponse; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message AddLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesRequest. */ + interface IRemoveLocalInventoriesRequest { + + /** RemoveLocalInventoriesRequest product */ + product?: (string|null); + + /** RemoveLocalInventoriesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveLocalInventoriesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveLocalInventoriesRequest. */ + class RemoveLocalInventoriesRequest implements IRemoveLocalInventoriesRequest { + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest); + + /** RemoveLocalInventoriesRequest product. */ + public product: string; + + /** RemoveLocalInventoriesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveLocalInventoriesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest): google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; + + /** + * Verifies a RemoveLocalInventoriesRequest 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 RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesMetadata. */ + interface IRemoveLocalInventoriesMetadata { + } + + /** Represents a RemoveLocalInventoriesMetadata. */ + class RemoveLocalInventoriesMetadata implements IRemoveLocalInventoriesMetadata { + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata); + + /** + * Creates a new RemoveLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata): google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; + + /** + * Verifies a RemoveLocalInventoriesMetadata 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 RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesResponse. */ + interface IRemoveLocalInventoriesResponse { + } + + /** Represents a RemoveLocalInventoriesResponse. */ + class RemoveLocalInventoriesResponse implements IRemoveLocalInventoriesResponse { + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse); + + /** + * Creates a new RemoveLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse): google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + + /** + * Verifies a RemoveLocalInventoriesResponse 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 RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesRequest. */ + interface IRemoveFulfillmentPlacesRequest { + + /** RemoveFulfillmentPlacesRequest product */ + product?: (string|null); + + /** RemoveFulfillmentPlacesRequest type */ + type?: (string|null); + + /** RemoveFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveFulfillmentPlacesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveFulfillmentPlacesRequest. */ + class RemoveFulfillmentPlacesRequest implements IRemoveFulfillmentPlacesRequest { + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest); + + /** RemoveFulfillmentPlacesRequest product. */ + public product: string; + + /** RemoveFulfillmentPlacesRequest type. */ + public type: string; + + /** RemoveFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveFulfillmentPlacesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; + + /** + * Verifies a RemoveFulfillmentPlacesRequest 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 RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesMetadata. */ + interface IRemoveFulfillmentPlacesMetadata { + } + + /** Represents a RemoveFulfillmentPlacesMetadata. */ + class RemoveFulfillmentPlacesMetadata implements IRemoveFulfillmentPlacesMetadata { + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata); + + /** + * Creates a new RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata 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 RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesResponse. */ + interface IRemoveFulfillmentPlacesResponse { + } + + /** Represents a RemoveFulfillmentPlacesResponse. */ + class RemoveFulfillmentPlacesResponse implements IRemoveFulfillmentPlacesResponse { + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse); + + /** + * Creates a new RemoveFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + + /** + * Verifies a RemoveFulfillmentPlacesResponse 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 RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeMetadata. */ + interface IPurgeMetadata { + } + + /** Represents a PurgeMetadata. */ + class PurgeMetadata implements IPurgeMetadata { + + /** + * Constructs a new PurgeMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeMetadata); + + /** + * Creates a new PurgeMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeMetadata): google.cloud.retail.v2alpha.PurgeMetadata; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeMetadata + * @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.cloud.retail.v2alpha.PurgeMetadata; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeMetadata + * @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.cloud.retail.v2alpha.PurgeMetadata; + + /** + * Verifies a PurgeMetadata 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 PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeMetadata; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @param message PurgeMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeProductsMetadata. */ + interface IPurgeProductsMetadata { + + /** PurgeProductsMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** PurgeProductsMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** PurgeProductsMetadata successCount */ + successCount?: (number|Long|string|null); + + /** PurgeProductsMetadata failureCount */ + failureCount?: (number|Long|string|null); + } + + /** Represents a PurgeProductsMetadata. */ + class PurgeProductsMetadata implements IPurgeProductsMetadata { + + /** + * Constructs a new PurgeProductsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeProductsMetadata); + + /** PurgeProductsMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** PurgeProductsMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** PurgeProductsMetadata successCount. */ + public successCount: (number|Long|string); + + /** PurgeProductsMetadata failureCount. */ + public failureCount: (number|Long|string); + + /** + * Creates a new PurgeProductsMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeProductsMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeProductsMetadata): google.cloud.retail.v2alpha.PurgeProductsMetadata; + + /** + * Encodes the specified PurgeProductsMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsMetadata.verify|verify} messages. + * @param message PurgeProductsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeProductsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeProductsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsMetadata.verify|verify} messages. + * @param message PurgeProductsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeProductsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeProductsMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeProductsMetadata + * @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.cloud.retail.v2alpha.PurgeProductsMetadata; + + /** + * Decodes a PurgeProductsMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeProductsMetadata + * @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.cloud.retail.v2alpha.PurgeProductsMetadata; + + /** + * Verifies a PurgeProductsMetadata 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 PurgeProductsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeProductsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeProductsMetadata; + + /** + * Creates a plain object from a PurgeProductsMetadata message. Also converts values to other types if specified. + * @param message PurgeProductsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeProductsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeProductsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeProductsMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeProductsRequest. */ + interface IPurgeProductsRequest { + + /** PurgeProductsRequest parent */ + parent?: (string|null); + + /** PurgeProductsRequest filter */ + filter?: (string|null); + + /** PurgeProductsRequest force */ + force?: (boolean|null); + } + + /** Represents a PurgeProductsRequest. */ + class PurgeProductsRequest implements IPurgeProductsRequest { + + /** + * Constructs a new PurgeProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeProductsRequest); + + /** PurgeProductsRequest parent. */ + public parent: string; + + /** PurgeProductsRequest filter. */ + public filter: string; + + /** PurgeProductsRequest force. */ + public force: boolean; + + /** + * Creates a new PurgeProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeProductsRequest): google.cloud.retail.v2alpha.PurgeProductsRequest; + + /** + * Encodes the specified PurgeProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsRequest.verify|verify} messages. + * @param message PurgeProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsRequest.verify|verify} messages. + * @param message PurgeProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeProductsRequest + * @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.cloud.retail.v2alpha.PurgeProductsRequest; + + /** + * Decodes a PurgeProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeProductsRequest + * @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.cloud.retail.v2alpha.PurgeProductsRequest; + + /** + * Verifies a PurgeProductsRequest 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 PurgeProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeProductsRequest; + + /** + * Creates a plain object from a PurgeProductsRequest message. Also converts values to other types if specified. + * @param message PurgeProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeProductsResponse. */ + interface IPurgeProductsResponse { + + /** PurgeProductsResponse purgeCount */ + purgeCount?: (number|Long|string|null); + + /** PurgeProductsResponse purgeSample */ + purgeSample?: (string[]|null); + } + + /** Represents a PurgeProductsResponse. */ + class PurgeProductsResponse implements IPurgeProductsResponse { + + /** + * Constructs a new PurgeProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeProductsResponse); + + /** PurgeProductsResponse purgeCount. */ + public purgeCount: (number|Long|string); + + /** PurgeProductsResponse purgeSample. */ + public purgeSample: string[]; + + /** + * Creates a new PurgeProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeProductsResponse): google.cloud.retail.v2alpha.PurgeProductsResponse; + + /** + * Encodes the specified PurgeProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsResponse.verify|verify} messages. + * @param message PurgeProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsResponse.verify|verify} messages. + * @param message PurgeProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeProductsResponse + * @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.cloud.retail.v2alpha.PurgeProductsResponse; + + /** + * Decodes a PurgeProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeProductsResponse + * @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.cloud.retail.v2alpha.PurgeProductsResponse; + + /** + * Verifies a PurgeProductsResponse 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 PurgeProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeProductsResponse; + + /** + * Creates a plain object from a PurgeProductsResponse message. Also converts values to other types if specified. + * @param message PurgeProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsRequest. */ + interface IPurgeUserEventsRequest { + + /** PurgeUserEventsRequest parent */ + parent?: (string|null); + + /** PurgeUserEventsRequest filter */ + filter?: (string|null); + + /** PurgeUserEventsRequest force */ + force?: (boolean|null); + } + + /** Represents a PurgeUserEventsRequest. */ + class PurgeUserEventsRequest implements IPurgeUserEventsRequest { + + /** + * Constructs a new PurgeUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeUserEventsRequest); + + /** PurgeUserEventsRequest parent. */ + public parent: string; + + /** PurgeUserEventsRequest filter. */ + public filter: string; + + /** PurgeUserEventsRequest force. */ + public force: boolean; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeUserEventsRequest): google.cloud.retail.v2alpha.PurgeUserEventsRequest; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2alpha.PurgeUserEventsRequest; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2alpha.PurgeUserEventsRequest; + + /** + * Verifies a PurgeUserEventsRequest 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 PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeUserEventsRequest; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @param message PurgeUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsResponse. */ + interface IPurgeUserEventsResponse { + + /** PurgeUserEventsResponse purgedEventsCount */ + purgedEventsCount?: (number|Long|string|null); + } + + /** Represents a PurgeUserEventsResponse. */ + class PurgeUserEventsResponse implements IPurgeUserEventsResponse { + + /** + * Constructs a new PurgeUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IPurgeUserEventsResponse); + + /** PurgeUserEventsResponse purgedEventsCount. */ + public purgedEventsCount: (number|Long|string); + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IPurgeUserEventsResponse): google.cloud.retail.v2alpha.PurgeUserEventsResponse; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2alpha.PurgeUserEventsResponse; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2alpha.PurgeUserEventsResponse; + + /** + * Verifies a PurgeUserEventsResponse 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 PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.PurgeUserEventsResponse; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @param message PurgeUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.PurgeUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ServingConfig. */ + interface IServingConfig { + + /** ServingConfig name */ + name?: (string|null); + + /** ServingConfig displayName */ + displayName?: (string|null); + + /** ServingConfig modelId */ + modelId?: (string|null); + + /** ServingConfig priceRerankingLevel */ + priceRerankingLevel?: (string|null); + + /** ServingConfig facetControlIds */ + facetControlIds?: (string[]|null); + + /** ServingConfig dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds */ + boostControlIds?: (string[]|null); + + /** ServingConfig filterControlIds */ + filterControlIds?: (string[]|null); + + /** ServingConfig redirectControlIds */ + redirectControlIds?: (string[]|null); + + /** ServingConfig twowaySynonymsControlIds */ + twowaySynonymsControlIds?: (string[]|null); + + /** ServingConfig onewaySynonymsControlIds */ + onewaySynonymsControlIds?: (string[]|null); + + /** ServingConfig doNotAssociateControlIds */ + doNotAssociateControlIds?: (string[]|null); + + /** ServingConfig replacementControlIds */ + replacementControlIds?: (string[]|null); + + /** ServingConfig ignoreControlIds */ + ignoreControlIds?: (string[]|null); + + /** ServingConfig diversityLevel */ + diversityLevel?: (string|null); + + /** ServingConfig enableCategoryFilterLevel */ + enableCategoryFilterLevel?: (string|null); + + /** ServingConfig solutionTypes */ + solutionTypes?: (google.cloud.retail.v2alpha.SolutionType[]|null); + } + + /** Represents a ServingConfig. */ + class ServingConfig implements IServingConfig { + + /** + * Constructs a new ServingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IServingConfig); + + /** ServingConfig name. */ + public name: string; + + /** ServingConfig displayName. */ + public displayName: string; + + /** ServingConfig modelId. */ + public modelId: string; + + /** ServingConfig priceRerankingLevel. */ + public priceRerankingLevel: string; + + /** ServingConfig facetControlIds. */ + public facetControlIds: string[]; + + /** ServingConfig dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds. */ + public boostControlIds: string[]; + + /** ServingConfig filterControlIds. */ + public filterControlIds: string[]; + + /** ServingConfig redirectControlIds. */ + public redirectControlIds: string[]; + + /** ServingConfig twowaySynonymsControlIds. */ + public twowaySynonymsControlIds: string[]; + + /** ServingConfig onewaySynonymsControlIds. */ + public onewaySynonymsControlIds: string[]; + + /** ServingConfig doNotAssociateControlIds. */ + public doNotAssociateControlIds: string[]; + + /** ServingConfig replacementControlIds. */ + public replacementControlIds: string[]; + + /** ServingConfig ignoreControlIds. */ + public ignoreControlIds: string[]; + + /** ServingConfig diversityLevel. */ + public diversityLevel: string; + + /** ServingConfig enableCategoryFilterLevel. */ + public enableCategoryFilterLevel: string; + + /** ServingConfig solutionTypes. */ + public solutionTypes: google.cloud.retail.v2alpha.SolutionType[]; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ServingConfig instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IServingConfig): google.cloud.retail.v2alpha.ServingConfig; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServingConfig + * @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.cloud.retail.v2alpha.ServingConfig; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServingConfig + * @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.cloud.retail.v2alpha.ServingConfig; + + /** + * Verifies a ServingConfig 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 ServingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ServingConfig; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @param message ServingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ServingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a ServingConfigService */ + class ServingConfigService extends $protobuf.rpc.Service { + + /** + * Constructs a new ServingConfigService 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 ServingConfigService 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): ServingConfigService; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public createServingConfig(request: google.cloud.retail.v2alpha.ICreateServingConfigRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfigCallback): void; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @returns Promise + */ + public createServingConfig(request: google.cloud.retail.v2alpha.ICreateServingConfigRequest): Promise; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteServingConfig(request: google.cloud.retail.v2alpha.IDeleteServingConfigRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfigCallback): void; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @returns Promise + */ + public deleteServingConfig(request: google.cloud.retail.v2alpha.IDeleteServingConfigRequest): Promise; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public updateServingConfig(request: google.cloud.retail.v2alpha.IUpdateServingConfigRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfigCallback): void; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @returns Promise + */ + public updateServingConfig(request: google.cloud.retail.v2alpha.IUpdateServingConfigRequest): Promise; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public getServingConfig(request: google.cloud.retail.v2alpha.IGetServingConfigRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.GetServingConfigCallback): void; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @returns Promise + */ + public getServingConfig(request: google.cloud.retail.v2alpha.IGetServingConfigRequest): Promise; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListServingConfigsResponse + */ + public listServingConfigs(request: google.cloud.retail.v2alpha.IListServingConfigsRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigsCallback): void; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @returns Promise + */ + public listServingConfigs(request: google.cloud.retail.v2alpha.IListServingConfigsRequest): Promise; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public addControl(request: google.cloud.retail.v2alpha.IAddControlRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.AddControlCallback): void; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @returns Promise + */ + public addControl(request: google.cloud.retail.v2alpha.IAddControlRequest): Promise; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public removeControl(request: google.cloud.retail.v2alpha.IRemoveControlRequest, callback: google.cloud.retail.v2alpha.ServingConfigService.RemoveControlCallback): void; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @returns Promise + */ + public removeControl(request: google.cloud.retail.v2alpha.IRemoveControlRequest): Promise; + } + + namespace ServingConfigService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|createServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type CreateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|deleteServingConfig}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteServingConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|updateServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type UpdateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|getServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type GetServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|listServingConfigs}. + * @param error Error, if any + * @param [response] ListServingConfigsResponse + */ + type ListServingConfigsCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ListServingConfigsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|addControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type AddControlCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|removeControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type RemoveControlCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.ServingConfig) => void; + } + + /** Properties of a CreateServingConfigRequest. */ + interface ICreateServingConfigRequest { + + /** CreateServingConfigRequest parent */ + parent?: (string|null); + + /** CreateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2alpha.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId */ + servingConfigId?: (string|null); + } + + /** Represents a CreateServingConfigRequest. */ + class CreateServingConfigRequest implements ICreateServingConfigRequest { + + /** + * Constructs a new CreateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICreateServingConfigRequest); + + /** CreateServingConfigRequest parent. */ + public parent: string; + + /** CreateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2alpha.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId. */ + public servingConfigId: string; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICreateServingConfigRequest): google.cloud.retail.v2alpha.CreateServingConfigRequest; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2alpha.CreateServingConfigRequest; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2alpha.CreateServingConfigRequest; + + /** + * Verifies a CreateServingConfigRequest 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 CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CreateServingConfigRequest; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @param message CreateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CreateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateServingConfigRequest. */ + interface IUpdateServingConfigRequest { + + /** UpdateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2alpha.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateServingConfigRequest. */ + class UpdateServingConfigRequest implements IUpdateServingConfigRequest { + + /** + * Constructs a new UpdateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IUpdateServingConfigRequest); + + /** UpdateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2alpha.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IUpdateServingConfigRequest): google.cloud.retail.v2alpha.UpdateServingConfigRequest; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2alpha.UpdateServingConfigRequest; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2alpha.UpdateServingConfigRequest; + + /** + * Verifies an UpdateServingConfigRequest 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 UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.UpdateServingConfigRequest; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @param message UpdateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.UpdateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteServingConfigRequest. */ + interface IDeleteServingConfigRequest { + + /** DeleteServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a DeleteServingConfigRequest. */ + class DeleteServingConfigRequest implements IDeleteServingConfigRequest { + + /** + * Constructs a new DeleteServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IDeleteServingConfigRequest); + + /** DeleteServingConfigRequest name. */ + public name: string; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IDeleteServingConfigRequest): google.cloud.retail.v2alpha.DeleteServingConfigRequest; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2alpha.DeleteServingConfigRequest; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2alpha.DeleteServingConfigRequest; + + /** + * Verifies a DeleteServingConfigRequest 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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.DeleteServingConfigRequest; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @param message DeleteServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.DeleteServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetServingConfigRequest. */ + interface IGetServingConfigRequest { + + /** GetServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetServingConfigRequest. */ + class GetServingConfigRequest implements IGetServingConfigRequest { + + /** + * Constructs a new GetServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IGetServingConfigRequest); + + /** GetServingConfigRequest name. */ + public name: string; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IGetServingConfigRequest): google.cloud.retail.v2alpha.GetServingConfigRequest; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetServingConfigRequest + * @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.cloud.retail.v2alpha.GetServingConfigRequest; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetServingConfigRequest + * @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.cloud.retail.v2alpha.GetServingConfigRequest; + + /** + * Verifies a GetServingConfigRequest 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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.GetServingConfigRequest; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @param message GetServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.GetServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsRequest. */ + interface IListServingConfigsRequest { + + /** ListServingConfigsRequest parent */ + parent?: (string|null); + + /** ListServingConfigsRequest pageSize */ + pageSize?: (number|null); + + /** ListServingConfigsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListServingConfigsRequest. */ + class ListServingConfigsRequest implements IListServingConfigsRequest { + + /** + * Constructs a new ListServingConfigsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListServingConfigsRequest); + + /** ListServingConfigsRequest parent. */ + public parent: string; + + /** ListServingConfigsRequest pageSize. */ + public pageSize: number; + + /** ListServingConfigsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListServingConfigsRequest): google.cloud.retail.v2alpha.ListServingConfigsRequest; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2alpha.ListServingConfigsRequest; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2alpha.ListServingConfigsRequest; + + /** + * Verifies a ListServingConfigsRequest 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListServingConfigsRequest; + + /** + * Creates a plain object from a ListServingConfigsRequest message. Also converts values to other types if specified. + * @param message ListServingConfigsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListServingConfigsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsResponse. */ + interface IListServingConfigsResponse { + + /** ListServingConfigsResponse servingConfigs */ + servingConfigs?: (google.cloud.retail.v2alpha.IServingConfig[]|null); + + /** ListServingConfigsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListServingConfigsResponse. */ + class ListServingConfigsResponse implements IListServingConfigsResponse { + + /** + * Constructs a new ListServingConfigsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IListServingConfigsResponse); + + /** ListServingConfigsResponse servingConfigs. */ + public servingConfigs: google.cloud.retail.v2alpha.IServingConfig[]; + + /** ListServingConfigsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IListServingConfigsResponse): google.cloud.retail.v2alpha.ListServingConfigsResponse; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2alpha.ListServingConfigsResponse; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2alpha.ListServingConfigsResponse; + + /** + * Verifies a ListServingConfigsResponse 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 ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.ListServingConfigsResponse; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @param message ListServingConfigsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.ListServingConfigsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddControlRequest. */ + interface IAddControlRequest { + + /** AddControlRequest servingConfig */ + servingConfig?: (string|null); + + /** AddControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents an AddControlRequest. */ + class AddControlRequest implements IAddControlRequest { + + /** + * Constructs a new AddControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IAddControlRequest); + + /** AddControlRequest servingConfig. */ + public servingConfig: string; + + /** AddControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IAddControlRequest): google.cloud.retail.v2alpha.AddControlRequest; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddControlRequest + * @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.cloud.retail.v2alpha.AddControlRequest; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddControlRequest + * @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.cloud.retail.v2alpha.AddControlRequest; + + /** + * Verifies an AddControlRequest 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 AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.AddControlRequest; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @param message AddControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.AddControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveControlRequest. */ + interface IRemoveControlRequest { + + /** RemoveControlRequest servingConfig */ + servingConfig?: (string|null); + + /** RemoveControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a RemoveControlRequest. */ + class RemoveControlRequest implements IRemoveControlRequest { + + /** + * Constructs a new RemoveControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRemoveControlRequest); + + /** RemoveControlRequest servingConfig. */ + public servingConfig: string; + + /** RemoveControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRemoveControlRequest): google.cloud.retail.v2alpha.RemoveControlRequest; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveControlRequest + * @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.cloud.retail.v2alpha.RemoveControlRequest; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveControlRequest + * @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.cloud.retail.v2alpha.RemoveControlRequest; + + /** + * Verifies a RemoveControlRequest 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 RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RemoveControlRequest; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @param message RemoveControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RemoveControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a UserEventService */ + class UserEventService extends $protobuf.rpc.Service { + + /** + * Constructs a new UserEventService 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 UserEventService 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): UserEventService; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and UserEvent + */ + public writeUserEvent(request: google.cloud.retail.v2alpha.IWriteUserEventRequest, callback: google.cloud.retail.v2alpha.UserEventService.WriteUserEventCallback): void; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @returns Promise + */ + public writeUserEvent(request: google.cloud.retail.v2alpha.IWriteUserEventRequest): Promise; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and HttpBody + */ + public collectUserEvent(request: google.cloud.retail.v2alpha.ICollectUserEventRequest, callback: google.cloud.retail.v2alpha.UserEventService.CollectUserEventCallback): void; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @returns Promise + */ + public collectUserEvent(request: google.cloud.retail.v2alpha.ICollectUserEventRequest): Promise; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public purgeUserEvents(request: google.cloud.retail.v2alpha.IPurgeUserEventsRequest, callback: google.cloud.retail.v2alpha.UserEventService.PurgeUserEventsCallback): void; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @returns Promise + */ + public purgeUserEvents(request: google.cloud.retail.v2alpha.IPurgeUserEventsRequest): Promise; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importUserEvents(request: google.cloud.retail.v2alpha.IImportUserEventsRequest, callback: google.cloud.retail.v2alpha.UserEventService.ImportUserEventsCallback): void; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @returns Promise + */ + public importUserEvents(request: google.cloud.retail.v2alpha.IImportUserEventsRequest): Promise; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public rejoinUserEvents(request: google.cloud.retail.v2alpha.IRejoinUserEventsRequest, callback: google.cloud.retail.v2alpha.UserEventService.RejoinUserEventsCallback): void; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @returns Promise + */ + public rejoinUserEvents(request: google.cloud.retail.v2alpha.IRejoinUserEventsRequest): Promise; + } + + namespace UserEventService { + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|writeUserEvent}. + * @param error Error, if any + * @param [response] UserEvent + */ + type WriteUserEventCallback = (error: (Error|null), response?: google.cloud.retail.v2alpha.UserEvent) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|collectUserEvent}. + * @param error Error, if any + * @param [response] HttpBody + */ + type CollectUserEventCallback = (error: (Error|null), response?: google.api.HttpBody) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|purgeUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type PurgeUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|importUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|rejoinUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type RejoinUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a WriteUserEventRequest. */ + interface IWriteUserEventRequest { + + /** WriteUserEventRequest parent */ + parent?: (string|null); + + /** WriteUserEventRequest userEvent */ + userEvent?: (google.cloud.retail.v2alpha.IUserEvent|null); + } + + /** Represents a WriteUserEventRequest. */ + class WriteUserEventRequest implements IWriteUserEventRequest { + + /** + * Constructs a new WriteUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IWriteUserEventRequest); + + /** WriteUserEventRequest parent. */ + public parent: string; + + /** WriteUserEventRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2alpha.IUserEvent|null); + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IWriteUserEventRequest): google.cloud.retail.v2alpha.WriteUserEventRequest; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteUserEventRequest + * @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.cloud.retail.v2alpha.WriteUserEventRequest; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteUserEventRequest + * @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.cloud.retail.v2alpha.WriteUserEventRequest; + + /** + * Verifies a WriteUserEventRequest 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 WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.WriteUserEventRequest; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @param message WriteUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.WriteUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WriteUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CollectUserEventRequest. */ + interface ICollectUserEventRequest { + + /** CollectUserEventRequest parent */ + parent?: (string|null); + + /** CollectUserEventRequest userEvent */ + userEvent?: (string|null); + + /** CollectUserEventRequest uri */ + uri?: (string|null); + + /** CollectUserEventRequest ets */ + ets?: (number|Long|string|null); + } + + /** Represents a CollectUserEventRequest. */ + class CollectUserEventRequest implements ICollectUserEventRequest { + + /** + * Constructs a new CollectUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.ICollectUserEventRequest); + + /** CollectUserEventRequest parent. */ + public parent: string; + + /** CollectUserEventRequest userEvent. */ + public userEvent: string; + + /** CollectUserEventRequest uri. */ + public uri: string; + + /** CollectUserEventRequest ets. */ + public ets: (number|Long|string); + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CollectUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.ICollectUserEventRequest): google.cloud.retail.v2alpha.CollectUserEventRequest; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CollectUserEventRequest + * @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.cloud.retail.v2alpha.CollectUserEventRequest; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CollectUserEventRequest + * @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.cloud.retail.v2alpha.CollectUserEventRequest; + + /** + * Verifies a CollectUserEventRequest 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 CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.CollectUserEventRequest; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @param message CollectUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.CollectUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CollectUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsRequest. */ + interface IRejoinUserEventsRequest { + + /** RejoinUserEventsRequest parent */ + parent?: (string|null); + + /** RejoinUserEventsRequest userEventRejoinScope */ + userEventRejoinScope?: (google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope|null); + } + + /** Represents a RejoinUserEventsRequest. */ + class RejoinUserEventsRequest implements IRejoinUserEventsRequest { + + /** + * Constructs a new RejoinUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsRequest); + + /** RejoinUserEventsRequest parent. */ + public parent: string; + + /** RejoinUserEventsRequest userEventRejoinScope. */ + public userEventRejoinScope: (google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope); + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsRequest): google.cloud.retail.v2alpha.RejoinUserEventsRequest; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2alpha.RejoinUserEventsRequest; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2alpha.RejoinUserEventsRequest; + + /** + * Verifies a RejoinUserEventsRequest 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 RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RejoinUserEventsRequest; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @param message RejoinUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RejoinUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace RejoinUserEventsRequest { + + /** UserEventRejoinScope enum. */ + enum UserEventRejoinScope { + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0, + JOINED_EVENTS = 1, + UNJOINED_EVENTS = 2 + } + } + + /** Properties of a RejoinUserEventsResponse. */ + interface IRejoinUserEventsResponse { + + /** RejoinUserEventsResponse rejoinedUserEventsCount */ + rejoinedUserEventsCount?: (number|Long|string|null); + } + + /** Represents a RejoinUserEventsResponse. */ + class RejoinUserEventsResponse implements IRejoinUserEventsResponse { + + /** + * Constructs a new RejoinUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsResponse); + + /** RejoinUserEventsResponse rejoinedUserEventsCount. */ + public rejoinedUserEventsCount: (number|Long|string); + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsResponse): google.cloud.retail.v2alpha.RejoinUserEventsResponse; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2alpha.RejoinUserEventsResponse; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2alpha.RejoinUserEventsResponse; + + /** + * Verifies a RejoinUserEventsResponse 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 RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RejoinUserEventsResponse; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @param message RejoinUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RejoinUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsMetadata. */ + interface IRejoinUserEventsMetadata { + } + + /** Represents a RejoinUserEventsMetadata. */ + class RejoinUserEventsMetadata implements IRejoinUserEventsMetadata { + + /** + * Constructs a new RejoinUserEventsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsMetadata); + + /** + * Creates a new RejoinUserEventsMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsMetadata instance + */ + public static create(properties?: google.cloud.retail.v2alpha.IRejoinUserEventsMetadata): google.cloud.retail.v2alpha.RejoinUserEventsMetadata; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2alpha.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2alpha.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2alpha.RejoinUserEventsMetadata; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2alpha.RejoinUserEventsMetadata; + + /** + * Verifies a RejoinUserEventsMetadata 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 RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2alpha.RejoinUserEventsMetadata; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @param message RejoinUserEventsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2alpha.RejoinUserEventsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace v2beta. */ + namespace v2beta { + + /** Properties of a ProductLevelConfig. */ + interface IProductLevelConfig { + + /** ProductLevelConfig ingestionProductType */ + ingestionProductType?: (string|null); + + /** ProductLevelConfig merchantCenterProductIdField */ + merchantCenterProductIdField?: (string|null); + } + + /** Represents a ProductLevelConfig. */ + class ProductLevelConfig implements IProductLevelConfig { + + /** + * Constructs a new ProductLevelConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IProductLevelConfig); + + /** ProductLevelConfig ingestionProductType. */ + public ingestionProductType: string; + + /** ProductLevelConfig merchantCenterProductIdField. */ + public merchantCenterProductIdField: string; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductLevelConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IProductLevelConfig): google.cloud.retail.v2beta.ProductLevelConfig; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductLevelConfig.verify|verify} messages. + * @param message ProductLevelConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IProductLevelConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductLevelConfig + * @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.cloud.retail.v2beta.ProductLevelConfig; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductLevelConfig + * @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.cloud.retail.v2beta.ProductLevelConfig; + + /** + * Verifies a ProductLevelConfig 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 ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductLevelConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ProductLevelConfig; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @param message ProductLevelConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ProductLevelConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductLevelConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductLevelConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CatalogAttribute. */ + interface ICatalogAttribute { + + /** CatalogAttribute key */ + key?: (string|null); + + /** CatalogAttribute inUse */ + inUse?: (boolean|null); + + /** CatalogAttribute type */ + type?: (google.cloud.retail.v2beta.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.AttributeType|null); + + /** CatalogAttribute indexableOption */ + indexableOption?: (google.cloud.retail.v2beta.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.IndexableOption|null); + + /** CatalogAttribute dynamicFacetableOption */ + dynamicFacetableOption?: (google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption|null); + + /** CatalogAttribute searchableOption */ + searchableOption?: (google.cloud.retail.v2beta.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.SearchableOption|null); + + /** CatalogAttribute recommendationsFilteringOption */ + recommendationsFilteringOption?: (google.cloud.retail.v2beta.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2beta.RecommendationsFilteringOption|null); + + /** CatalogAttribute exactSearchableOption */ + exactSearchableOption?: (google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption|null); + } + + /** Represents a CatalogAttribute. */ + class CatalogAttribute implements ICatalogAttribute { + + /** + * Constructs a new CatalogAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICatalogAttribute); + + /** CatalogAttribute key. */ + public key: string; + + /** CatalogAttribute inUse. */ + public inUse: boolean; + + /** CatalogAttribute type. */ + public type: (google.cloud.retail.v2beta.CatalogAttribute.AttributeType|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.AttributeType); + + /** CatalogAttribute indexableOption. */ + public indexableOption: (google.cloud.retail.v2beta.CatalogAttribute.IndexableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.IndexableOption); + + /** CatalogAttribute dynamicFacetableOption. */ + public dynamicFacetableOption: (google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption); + + /** CatalogAttribute searchableOption. */ + public searchableOption: (google.cloud.retail.v2beta.CatalogAttribute.SearchableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.SearchableOption); + + /** CatalogAttribute recommendationsFilteringOption. */ + public recommendationsFilteringOption: (google.cloud.retail.v2beta.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2beta.RecommendationsFilteringOption); + + /** CatalogAttribute exactSearchableOption. */ + public exactSearchableOption: (google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption|keyof typeof google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption); + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CatalogAttribute instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICatalogAttribute): google.cloud.retail.v2beta.CatalogAttribute; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2beta.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CatalogAttribute.verify|verify} messages. + * @param message CatalogAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICatalogAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CatalogAttribute + * @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.cloud.retail.v2beta.CatalogAttribute; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CatalogAttribute + * @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.cloud.retail.v2beta.CatalogAttribute; + + /** + * Verifies a CatalogAttribute 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 CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CatalogAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CatalogAttribute; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @param message CatalogAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CatalogAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CatalogAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CatalogAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CatalogAttribute { + + /** AttributeType enum. */ + enum AttributeType { + UNKNOWN = 0, + TEXTUAL = 1, + NUMERICAL = 2 + } + + /** IndexableOption enum. */ + enum IndexableOption { + INDEXABLE_OPTION_UNSPECIFIED = 0, + INDEXABLE_ENABLED = 1, + INDEXABLE_DISABLED = 2 + } + + /** DynamicFacetableOption enum. */ + enum DynamicFacetableOption { + DYNAMIC_FACETABLE_OPTION_UNSPECIFIED = 0, + DYNAMIC_FACETABLE_ENABLED = 1, + DYNAMIC_FACETABLE_DISABLED = 2 + } + + /** SearchableOption enum. */ + enum SearchableOption { + SEARCHABLE_OPTION_UNSPECIFIED = 0, + SEARCHABLE_ENABLED = 1, + SEARCHABLE_DISABLED = 2 + } + + /** ExactSearchableOption enum. */ + enum ExactSearchableOption { + EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0, + EXACT_SEARCHABLE_ENABLED = 1, + EXACT_SEARCHABLE_DISABLED = 2 + } + } + + /** Properties of an AttributesConfig. */ + interface IAttributesConfig { + + /** AttributesConfig name */ + name?: (string|null); + + /** AttributesConfig catalogAttributes */ + catalogAttributes?: ({ [k: string]: google.cloud.retail.v2beta.ICatalogAttribute }|null); + + /** AttributesConfig attributeConfigLevel */ + attributeConfigLevel?: (google.cloud.retail.v2beta.AttributeConfigLevel|keyof typeof google.cloud.retail.v2beta.AttributeConfigLevel|null); + } + + /** Represents an AttributesConfig. */ + class AttributesConfig implements IAttributesConfig { + + /** + * Constructs a new AttributesConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAttributesConfig); + + /** AttributesConfig name. */ + public name: string; + + /** AttributesConfig catalogAttributes. */ + public catalogAttributes: { [k: string]: google.cloud.retail.v2beta.ICatalogAttribute }; + + /** AttributesConfig attributeConfigLevel. */ + public attributeConfigLevel: (google.cloud.retail.v2beta.AttributeConfigLevel|keyof typeof google.cloud.retail.v2beta.AttributeConfigLevel); + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns AttributesConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAttributesConfig): google.cloud.retail.v2beta.AttributesConfig; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2beta.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AttributesConfig.verify|verify} messages. + * @param message AttributesConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAttributesConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AttributesConfig + * @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.cloud.retail.v2beta.AttributesConfig; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AttributesConfig + * @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.cloud.retail.v2beta.AttributesConfig; + + /** + * Verifies an AttributesConfig 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 AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AttributesConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AttributesConfig; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @param message AttributesConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AttributesConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AttributesConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AttributesConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionConfig. */ + interface ICompletionConfig { + + /** CompletionConfig name */ + name?: (string|null); + + /** CompletionConfig matchingOrder */ + matchingOrder?: (string|null); + + /** CompletionConfig maxSuggestions */ + maxSuggestions?: (number|null); + + /** CompletionConfig minPrefixLength */ + minPrefixLength?: (number|null); + + /** CompletionConfig autoLearning */ + autoLearning?: (boolean|null); + + /** CompletionConfig suggestionsInputConfig */ + suggestionsInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation */ + lastSuggestionsImportOperation?: (string|null); + + /** CompletionConfig denylistInputConfig */ + denylistInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation */ + lastDenylistImportOperation?: (string|null); + + /** CompletionConfig allowlistInputConfig */ + allowlistInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation */ + lastAllowlistImportOperation?: (string|null); + } + + /** Represents a CompletionConfig. */ + class CompletionConfig implements ICompletionConfig { + + /** + * Constructs a new CompletionConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICompletionConfig); + + /** CompletionConfig name. */ + public name: string; + + /** CompletionConfig matchingOrder. */ + public matchingOrder: string; + + /** CompletionConfig maxSuggestions. */ + public maxSuggestions: number; + + /** CompletionConfig minPrefixLength. */ + public minPrefixLength: number; + + /** CompletionConfig autoLearning. */ + public autoLearning: boolean; + + /** CompletionConfig suggestionsInputConfig. */ + public suggestionsInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastSuggestionsImportOperation. */ + public lastSuggestionsImportOperation: string; + + /** CompletionConfig denylistInputConfig. */ + public denylistInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastDenylistImportOperation. */ + public lastDenylistImportOperation: string; + + /** CompletionConfig allowlistInputConfig. */ + public allowlistInputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** CompletionConfig lastAllowlistImportOperation. */ + public lastAllowlistImportOperation: string; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICompletionConfig): google.cloud.retail.v2beta.CompletionConfig; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionConfig.verify|verify} messages. + * @param message CompletionConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICompletionConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionConfig + * @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.cloud.retail.v2beta.CompletionConfig; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionConfig + * @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.cloud.retail.v2beta.CompletionConfig; + + /** + * Verifies a CompletionConfig 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 CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompletionConfig; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @param message CompletionConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompletionConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MerchantCenterLink. */ + interface IMerchantCenterLink { + + /** MerchantCenterLink merchantCenterAccountId */ + merchantCenterAccountId?: (number|Long|string|null); + + /** MerchantCenterLink branchId */ + branchId?: (string|null); + + /** MerchantCenterLink destinations */ + destinations?: (string[]|null); + + /** MerchantCenterLink regionCode */ + regionCode?: (string|null); + + /** MerchantCenterLink languageCode */ + languageCode?: (string|null); + } + + /** Represents a MerchantCenterLink. */ + class MerchantCenterLink implements IMerchantCenterLink { + + /** + * Constructs a new MerchantCenterLink. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IMerchantCenterLink); + + /** MerchantCenterLink merchantCenterAccountId. */ + public merchantCenterAccountId: (number|Long|string); + + /** MerchantCenterLink branchId. */ + public branchId: string; + + /** MerchantCenterLink destinations. */ + public destinations: string[]; + + /** MerchantCenterLink regionCode. */ + public regionCode: string; + + /** MerchantCenterLink languageCode. */ + public languageCode: string; + + /** + * Creates a new MerchantCenterLink instance using the specified properties. + * @param [properties] Properties to set + * @returns MerchantCenterLink instance + */ + public static create(properties?: google.cloud.retail.v2beta.IMerchantCenterLink): google.cloud.retail.v2beta.MerchantCenterLink; + + /** + * Encodes the specified MerchantCenterLink message. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLink.verify|verify} messages. + * @param message MerchantCenterLink message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IMerchantCenterLink, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MerchantCenterLink message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLink.verify|verify} messages. + * @param message MerchantCenterLink message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IMerchantCenterLink, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MerchantCenterLink + * @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.cloud.retail.v2beta.MerchantCenterLink; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MerchantCenterLink + * @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.cloud.retail.v2beta.MerchantCenterLink; + + /** + * Verifies a MerchantCenterLink 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 MerchantCenterLink message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MerchantCenterLink + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.MerchantCenterLink; + + /** + * Creates a plain object from a MerchantCenterLink message. Also converts values to other types if specified. + * @param message MerchantCenterLink + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.MerchantCenterLink, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MerchantCenterLink to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MerchantCenterLink + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MerchantCenterLinkingConfig. */ + interface IMerchantCenterLinkingConfig { + + /** MerchantCenterLinkingConfig links */ + links?: (google.cloud.retail.v2beta.IMerchantCenterLink[]|null); + } + + /** Represents a MerchantCenterLinkingConfig. */ + class MerchantCenterLinkingConfig implements IMerchantCenterLinkingConfig { + + /** + * Constructs a new MerchantCenterLinkingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IMerchantCenterLinkingConfig); + + /** MerchantCenterLinkingConfig links. */ + public links: google.cloud.retail.v2beta.IMerchantCenterLink[]; + + /** + * Creates a new MerchantCenterLinkingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns MerchantCenterLinkingConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IMerchantCenterLinkingConfig): google.cloud.retail.v2beta.MerchantCenterLinkingConfig; + + /** + * Encodes the specified MerchantCenterLinkingConfig message. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLinkingConfig.verify|verify} messages. + * @param message MerchantCenterLinkingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IMerchantCenterLinkingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MerchantCenterLinkingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLinkingConfig.verify|verify} messages. + * @param message MerchantCenterLinkingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IMerchantCenterLinkingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MerchantCenterLinkingConfig + * @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.cloud.retail.v2beta.MerchantCenterLinkingConfig; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MerchantCenterLinkingConfig + * @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.cloud.retail.v2beta.MerchantCenterLinkingConfig; + + /** + * Verifies a MerchantCenterLinkingConfig 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 MerchantCenterLinkingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MerchantCenterLinkingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.MerchantCenterLinkingConfig; + + /** + * Creates a plain object from a MerchantCenterLinkingConfig message. Also converts values to other types if specified. + * @param message MerchantCenterLinkingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.MerchantCenterLinkingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MerchantCenterLinkingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MerchantCenterLinkingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Catalog. */ + interface ICatalog { + + /** Catalog name */ + name?: (string|null); + + /** Catalog displayName */ + displayName?: (string|null); + + /** Catalog productLevelConfig */ + productLevelConfig?: (google.cloud.retail.v2beta.IProductLevelConfig|null); + + /** Catalog merchantCenterLinkingConfig */ + merchantCenterLinkingConfig?: (google.cloud.retail.v2beta.IMerchantCenterLinkingConfig|null); + } + + /** Represents a Catalog. */ + class Catalog implements ICatalog { + + /** + * Constructs a new Catalog. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICatalog); + + /** Catalog name. */ + public name: string; + + /** Catalog displayName. */ + public displayName: string; + + /** Catalog productLevelConfig. */ + public productLevelConfig?: (google.cloud.retail.v2beta.IProductLevelConfig|null); + + /** Catalog merchantCenterLinkingConfig. */ + public merchantCenterLinkingConfig?: (google.cloud.retail.v2beta.IMerchantCenterLinkingConfig|null); + + /** + * Creates a new Catalog instance using the specified properties. + * @param [properties] Properties to set + * @returns Catalog instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICatalog): google.cloud.retail.v2beta.Catalog; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2beta.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Catalog.verify|verify} messages. + * @param message Catalog message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICatalog, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Catalog + * @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.cloud.retail.v2beta.Catalog; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Catalog + * @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.cloud.retail.v2beta.Catalog; + + /** + * Verifies a Catalog 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 Catalog message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Catalog + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Catalog; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @param message Catalog + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Catalog, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Catalog to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Catalog + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** AttributeConfigLevel enum. */ + enum AttributeConfigLevel { + ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED = 0, + PRODUCT_LEVEL_ATTRIBUTE_CONFIG = 1, + CATALOG_LEVEL_ATTRIBUTE_CONFIG = 2 + } + + /** SolutionType enum. */ + enum SolutionType { + SOLUTION_TYPE_UNSPECIFIED = 0, + SOLUTION_TYPE_RECOMMENDATION = 1, + SOLUTION_TYPE_SEARCH = 2 + } + + /** RecommendationsFilteringOption enum. */ + enum RecommendationsFilteringOption { + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0, + RECOMMENDATIONS_FILTERING_DISABLED = 1, + RECOMMENDATIONS_FILTERING_ENABLED = 3 + } + + /** SearchSolutionUseCase enum. */ + enum SearchSolutionUseCase { + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0, + SEARCH_SOLUTION_USE_CASE_SEARCH = 1, + SEARCH_SOLUTION_USE_CASE_BROWSE = 2 + } + + /** Properties of a Condition. */ + interface ICondition { + + /** Condition queryTerms */ + queryTerms?: (google.cloud.retail.v2beta.Condition.IQueryTerm[]|null); + + /** Condition activeTimeRange */ + activeTimeRange?: (google.cloud.retail.v2beta.Condition.ITimeRange[]|null); + } + + /** Represents a Condition. */ + class Condition implements ICondition { + + /** + * Constructs a new Condition. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICondition); + + /** Condition queryTerms. */ + public queryTerms: google.cloud.retail.v2beta.Condition.IQueryTerm[]; + + /** Condition activeTimeRange. */ + public activeTimeRange: google.cloud.retail.v2beta.Condition.ITimeRange[]; + + /** + * Creates a new Condition instance using the specified properties. + * @param [properties] Properties to set + * @returns Condition instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICondition): google.cloud.retail.v2beta.Condition; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.verify|verify} messages. + * @param message Condition message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICondition, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Condition + * @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.cloud.retail.v2beta.Condition; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Condition + * @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.cloud.retail.v2beta.Condition; + + /** + * Verifies a Condition 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 Condition message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Condition + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Condition; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @param message Condition + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Condition, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Condition to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Condition + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Condition { + + /** Properties of a QueryTerm. */ + interface IQueryTerm { + + /** QueryTerm value */ + value?: (string|null); + + /** QueryTerm fullMatch */ + fullMatch?: (boolean|null); + } + + /** Represents a QueryTerm. */ + class QueryTerm implements IQueryTerm { + + /** + * Constructs a new QueryTerm. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Condition.IQueryTerm); + + /** QueryTerm value. */ + public value: string; + + /** QueryTerm fullMatch. */ + public fullMatch: boolean; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryTerm instance + */ + public static create(properties?: google.cloud.retail.v2beta.Condition.IQueryTerm): google.cloud.retail.v2beta.Condition.QueryTerm; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.QueryTerm.verify|verify} messages. + * @param message QueryTerm message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Condition.IQueryTerm, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryTerm + * @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.cloud.retail.v2beta.Condition.QueryTerm; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryTerm + * @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.cloud.retail.v2beta.Condition.QueryTerm; + + /** + * Verifies a QueryTerm 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 QueryTerm message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryTerm + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Condition.QueryTerm; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @param message QueryTerm + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Condition.QueryTerm, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryTerm to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryTerm + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TimeRange. */ + interface ITimeRange { + + /** TimeRange startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime */ + endTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a TimeRange. */ + class TimeRange implements ITimeRange { + + /** + * Constructs a new TimeRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Condition.ITimeRange); + + /** TimeRange startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** TimeRange endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new TimeRange instance using the specified properties. + * @param [properties] Properties to set + * @returns TimeRange instance + */ + public static create(properties?: google.cloud.retail.v2beta.Condition.ITimeRange): google.cloud.retail.v2beta.Condition.TimeRange; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.TimeRange.verify|verify} messages. + * @param message TimeRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Condition.ITimeRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TimeRange + * @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.cloud.retail.v2beta.Condition.TimeRange; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TimeRange + * @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.cloud.retail.v2beta.Condition.TimeRange; + + /** + * Verifies a TimeRange 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 TimeRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TimeRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Condition.TimeRange; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @param message TimeRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Condition.TimeRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TimeRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TimeRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rule. */ + interface IRule { + + /** Rule boostAction */ + boostAction?: (google.cloud.retail.v2beta.Rule.IBoostAction|null); + + /** Rule redirectAction */ + redirectAction?: (google.cloud.retail.v2beta.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction */ + onewaySynonymsAction?: (google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction */ + doNotAssociateAction?: (google.cloud.retail.v2beta.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction */ + replacementAction?: (google.cloud.retail.v2beta.Rule.IReplacementAction|null); + + /** Rule ignoreAction */ + ignoreAction?: (google.cloud.retail.v2beta.Rule.IIgnoreAction|null); + + /** Rule filterAction */ + filterAction?: (google.cloud.retail.v2beta.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction */ + twowaySynonymsAction?: (google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction|null); + + /** Rule condition */ + condition?: (google.cloud.retail.v2beta.ICondition|null); + } + + /** Represents a Rule. */ + class Rule implements IRule { + + /** + * Constructs a new Rule. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRule); + + /** Rule boostAction. */ + public boostAction?: (google.cloud.retail.v2beta.Rule.IBoostAction|null); + + /** Rule redirectAction. */ + public redirectAction?: (google.cloud.retail.v2beta.Rule.IRedirectAction|null); + + /** Rule onewaySynonymsAction. */ + public onewaySynonymsAction?: (google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction|null); + + /** Rule doNotAssociateAction. */ + public doNotAssociateAction?: (google.cloud.retail.v2beta.Rule.IDoNotAssociateAction|null); + + /** Rule replacementAction. */ + public replacementAction?: (google.cloud.retail.v2beta.Rule.IReplacementAction|null); + + /** Rule ignoreAction. */ + public ignoreAction?: (google.cloud.retail.v2beta.Rule.IIgnoreAction|null); + + /** Rule filterAction. */ + public filterAction?: (google.cloud.retail.v2beta.Rule.IFilterAction|null); + + /** Rule twowaySynonymsAction. */ + public twowaySynonymsAction?: (google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction|null); + + /** Rule condition. */ + public condition?: (google.cloud.retail.v2beta.ICondition|null); + + /** Rule action. */ + public action?: ("boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"); + + /** + * Creates a new Rule instance using the specified properties. + * @param [properties] Properties to set + * @returns Rule instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRule): google.cloud.retail.v2beta.Rule; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.verify|verify} messages. + * @param message Rule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rule + * @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.cloud.retail.v2beta.Rule; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rule + * @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.cloud.retail.v2beta.Rule; + + /** + * Verifies a Rule 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 Rule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rule + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @param message Rule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Rule { + + /** Properties of a BoostAction. */ + interface IBoostAction { + + /** BoostAction boost */ + boost?: (number|null); + + /** BoostAction productsFilter */ + productsFilter?: (string|null); + } + + /** Represents a BoostAction. */ + class BoostAction implements IBoostAction { + + /** + * Constructs a new BoostAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IBoostAction); + + /** BoostAction boost. */ + public boost: number; + + /** BoostAction productsFilter. */ + public productsFilter: string; + + /** + * Creates a new BoostAction instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IBoostAction): google.cloud.retail.v2beta.Rule.BoostAction; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.BoostAction.verify|verify} messages. + * @param message BoostAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IBoostAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostAction + * @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.cloud.retail.v2beta.Rule.BoostAction; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostAction + * @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.cloud.retail.v2beta.Rule.BoostAction; + + /** + * Verifies a BoostAction 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 BoostAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.BoostAction; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @param message BoostAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.BoostAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FilterAction. */ + interface IFilterAction { + + /** FilterAction filter */ + filter?: (string|null); + } + + /** Represents a FilterAction. */ + class FilterAction implements IFilterAction { + + /** + * Constructs a new FilterAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IFilterAction); + + /** FilterAction filter. */ + public filter: string; + + /** + * Creates a new FilterAction instance using the specified properties. + * @param [properties] Properties to set + * @returns FilterAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IFilterAction): google.cloud.retail.v2beta.Rule.FilterAction; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.FilterAction.verify|verify} messages. + * @param message FilterAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IFilterAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FilterAction + * @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.cloud.retail.v2beta.Rule.FilterAction; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FilterAction + * @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.cloud.retail.v2beta.Rule.FilterAction; + + /** + * Verifies a FilterAction 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 FilterAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FilterAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.FilterAction; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @param message FilterAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.FilterAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FilterAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FilterAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RedirectAction. */ + interface IRedirectAction { + + /** RedirectAction redirectUri */ + redirectUri?: (string|null); + } + + /** Represents a RedirectAction. */ + class RedirectAction implements IRedirectAction { + + /** + * Constructs a new RedirectAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IRedirectAction); + + /** RedirectAction redirectUri. */ + public redirectUri: string; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @param [properties] Properties to set + * @returns RedirectAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IRedirectAction): google.cloud.retail.v2beta.Rule.RedirectAction; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.RedirectAction.verify|verify} messages. + * @param message RedirectAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IRedirectAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RedirectAction + * @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.cloud.retail.v2beta.Rule.RedirectAction; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RedirectAction + * @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.cloud.retail.v2beta.Rule.RedirectAction; + + /** + * Verifies a RedirectAction 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 RedirectAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RedirectAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.RedirectAction; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @param message RedirectAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.RedirectAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RedirectAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RedirectAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TwowaySynonymsAction. */ + interface ITwowaySynonymsAction { + + /** TwowaySynonymsAction synonyms */ + synonyms?: (string[]|null); + } + + /** Represents a TwowaySynonymsAction. */ + class TwowaySynonymsAction implements ITwowaySynonymsAction { + + /** + * Constructs a new TwowaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction); + + /** TwowaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns TwowaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction): google.cloud.retail.v2beta.Rule.TwowaySynonymsAction; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.verify|verify} messages. + * @param message TwowaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2beta.Rule.TwowaySynonymsAction; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TwowaySynonymsAction + * @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.cloud.retail.v2beta.Rule.TwowaySynonymsAction; + + /** + * Verifies a TwowaySynonymsAction 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 TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TwowaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.TwowaySynonymsAction; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @param message TwowaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.TwowaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OnewaySynonymsAction. */ + interface IOnewaySynonymsAction { + + /** OnewaySynonymsAction queryTerms */ + queryTerms?: (string[]|null); + + /** OnewaySynonymsAction synonyms */ + synonyms?: (string[]|null); + + /** OnewaySynonymsAction onewayTerms */ + onewayTerms?: (string[]|null); + } + + /** Represents an OnewaySynonymsAction. */ + class OnewaySynonymsAction implements IOnewaySynonymsAction { + + /** + * Constructs a new OnewaySynonymsAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction); + + /** OnewaySynonymsAction queryTerms. */ + public queryTerms: string[]; + + /** OnewaySynonymsAction synonyms. */ + public synonyms: string[]; + + /** OnewaySynonymsAction onewayTerms. */ + public onewayTerms: string[]; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns OnewaySynonymsAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction): google.cloud.retail.v2beta.Rule.OnewaySynonymsAction; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.verify|verify} messages. + * @param message OnewaySynonymsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2beta.Rule.OnewaySynonymsAction; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OnewaySynonymsAction + * @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.cloud.retail.v2beta.Rule.OnewaySynonymsAction; + + /** + * Verifies an OnewaySynonymsAction 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 OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OnewaySynonymsAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.OnewaySynonymsAction; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @param message OnewaySynonymsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.OnewaySynonymsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DoNotAssociateAction. */ + interface IDoNotAssociateAction { + + /** DoNotAssociateAction queryTerms */ + queryTerms?: (string[]|null); + + /** DoNotAssociateAction doNotAssociateTerms */ + doNotAssociateTerms?: (string[]|null); + + /** DoNotAssociateAction terms */ + terms?: (string[]|null); + } + + /** Represents a DoNotAssociateAction. */ + class DoNotAssociateAction implements IDoNotAssociateAction { + + /** + * Constructs a new DoNotAssociateAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IDoNotAssociateAction); + + /** DoNotAssociateAction queryTerms. */ + public queryTerms: string[]; + + /** DoNotAssociateAction doNotAssociateTerms. */ + public doNotAssociateTerms: string[]; + + /** DoNotAssociateAction terms. */ + public terms: string[]; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @param [properties] Properties to set + * @returns DoNotAssociateAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IDoNotAssociateAction): google.cloud.retail.v2beta.Rule.DoNotAssociateAction; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.DoNotAssociateAction.verify|verify} messages. + * @param message DoNotAssociateAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IDoNotAssociateAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DoNotAssociateAction + * @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.cloud.retail.v2beta.Rule.DoNotAssociateAction; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DoNotAssociateAction + * @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.cloud.retail.v2beta.Rule.DoNotAssociateAction; + + /** + * Verifies a DoNotAssociateAction 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 DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoNotAssociateAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.DoNotAssociateAction; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @param message DoNotAssociateAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.DoNotAssociateAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DoNotAssociateAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplacementAction. */ + interface IReplacementAction { + + /** ReplacementAction queryTerms */ + queryTerms?: (string[]|null); + + /** ReplacementAction replacementTerm */ + replacementTerm?: (string|null); + + /** ReplacementAction term */ + term?: (string|null); + } + + /** Represents a ReplacementAction. */ + class ReplacementAction implements IReplacementAction { + + /** + * Constructs a new ReplacementAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IReplacementAction); + + /** ReplacementAction queryTerms. */ + public queryTerms: string[]; + + /** ReplacementAction replacementTerm. */ + public replacementTerm: string; + + /** ReplacementAction term. */ + public term: string; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplacementAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IReplacementAction): google.cloud.retail.v2beta.Rule.ReplacementAction; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.ReplacementAction.verify|verify} messages. + * @param message ReplacementAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IReplacementAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplacementAction + * @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.cloud.retail.v2beta.Rule.ReplacementAction; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplacementAction + * @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.cloud.retail.v2beta.Rule.ReplacementAction; + + /** + * Verifies a ReplacementAction 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 ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplacementAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.ReplacementAction; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @param message ReplacementAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.ReplacementAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplacementAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplacementAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an IgnoreAction. */ + interface IIgnoreAction { + + /** IgnoreAction ignoreTerms */ + ignoreTerms?: (string[]|null); + } + + /** Represents an IgnoreAction. */ + class IgnoreAction implements IIgnoreAction { + + /** + * Constructs a new IgnoreAction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Rule.IIgnoreAction); + + /** IgnoreAction ignoreTerms. */ + public ignoreTerms: string[]; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @param [properties] Properties to set + * @returns IgnoreAction instance + */ + public static create(properties?: google.cloud.retail.v2beta.Rule.IIgnoreAction): google.cloud.retail.v2beta.Rule.IgnoreAction; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.IgnoreAction.verify|verify} messages. + * @param message IgnoreAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Rule.IIgnoreAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IgnoreAction + * @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.cloud.retail.v2beta.Rule.IgnoreAction; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IgnoreAction + * @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.cloud.retail.v2beta.Rule.IgnoreAction; + + /** + * Verifies an IgnoreAction 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 IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IgnoreAction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rule.IgnoreAction; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @param message IgnoreAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rule.IgnoreAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IgnoreAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IgnoreAction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an Audience. */ + interface IAudience { + + /** Audience genders */ + genders?: (string[]|null); + + /** Audience ageGroups */ + ageGroups?: (string[]|null); + } + + /** Represents an Audience. */ + class Audience implements IAudience { + + /** + * Constructs a new Audience. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAudience); + + /** Audience genders. */ + public genders: string[]; + + /** Audience ageGroups. */ + public ageGroups: string[]; + + /** + * Creates a new Audience instance using the specified properties. + * @param [properties] Properties to set + * @returns Audience instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAudience): google.cloud.retail.v2beta.Audience; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2beta.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Audience.verify|verify} messages. + * @param message Audience message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAudience, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Audience + * @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.cloud.retail.v2beta.Audience; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Audience + * @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.cloud.retail.v2beta.Audience; + + /** + * Verifies an Audience 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 Audience message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Audience + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Audience; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @param message Audience + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Audience, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Audience to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Audience + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ColorInfo. */ + interface IColorInfo { + + /** ColorInfo colorFamilies */ + colorFamilies?: (string[]|null); + + /** ColorInfo colors */ + colors?: (string[]|null); + } + + /** Represents a ColorInfo. */ + class ColorInfo implements IColorInfo { + + /** + * Constructs a new ColorInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IColorInfo); + + /** ColorInfo colorFamilies. */ + public colorFamilies: string[]; + + /** ColorInfo colors. */ + public colors: string[]; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns ColorInfo instance + */ + public static create(properties?: google.cloud.retail.v2beta.IColorInfo): google.cloud.retail.v2beta.ColorInfo; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2beta.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ColorInfo.verify|verify} messages. + * @param message ColorInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IColorInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ColorInfo + * @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.cloud.retail.v2beta.ColorInfo; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ColorInfo + * @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.cloud.retail.v2beta.ColorInfo; + + /** + * Verifies a ColorInfo 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 ColorInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ColorInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ColorInfo; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @param message ColorInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ColorInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ColorInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ColorInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CustomAttribute. */ + interface ICustomAttribute { + + /** CustomAttribute text */ + text?: (string[]|null); + + /** CustomAttribute numbers */ + numbers?: (number[]|null); + + /** CustomAttribute searchable */ + searchable?: (boolean|null); + + /** CustomAttribute indexable */ + indexable?: (boolean|null); + } + + /** Represents a CustomAttribute. */ + class CustomAttribute implements ICustomAttribute { + + /** + * Constructs a new CustomAttribute. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICustomAttribute); + + /** CustomAttribute text. */ + public text: string[]; + + /** CustomAttribute numbers. */ + public numbers: number[]; + + /** CustomAttribute searchable. */ + public searchable?: (boolean|null); + + /** CustomAttribute indexable. */ + public indexable?: (boolean|null); + + /** CustomAttribute _searchable. */ + public _searchable?: "searchable"; + + /** CustomAttribute _indexable. */ + public _indexable?: "indexable"; + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomAttribute instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICustomAttribute): google.cloud.retail.v2beta.CustomAttribute; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2beta.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CustomAttribute.verify|verify} messages. + * @param message CustomAttribute message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICustomAttribute, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomAttribute + * @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.cloud.retail.v2beta.CustomAttribute; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomAttribute + * @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.cloud.retail.v2beta.CustomAttribute; + + /** + * Verifies a CustomAttribute 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 CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomAttribute + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CustomAttribute; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @param message CustomAttribute + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CustomAttribute, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomAttribute to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomAttribute + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FulfillmentInfo. */ + interface IFulfillmentInfo { + + /** FulfillmentInfo type */ + type?: (string|null); + + /** FulfillmentInfo placeIds */ + placeIds?: (string[]|null); + } + + /** Represents a FulfillmentInfo. */ + class FulfillmentInfo implements IFulfillmentInfo { + + /** + * Constructs a new FulfillmentInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IFulfillmentInfo); + + /** FulfillmentInfo type. */ + public type: string; + + /** FulfillmentInfo placeIds. */ + public placeIds: string[]; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns FulfillmentInfo instance + */ + public static create(properties?: google.cloud.retail.v2beta.IFulfillmentInfo): google.cloud.retail.v2beta.FulfillmentInfo; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2beta.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.FulfillmentInfo.verify|verify} messages. + * @param message FulfillmentInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IFulfillmentInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FulfillmentInfo + * @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.cloud.retail.v2beta.FulfillmentInfo; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FulfillmentInfo + * @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.cloud.retail.v2beta.FulfillmentInfo; + + /** + * Verifies a FulfillmentInfo 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 FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FulfillmentInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.FulfillmentInfo; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @param message FulfillmentInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.FulfillmentInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FulfillmentInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FulfillmentInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Image. */ + interface IImage { + + /** Image uri */ + uri?: (string|null); + + /** Image height */ + height?: (number|null); + + /** Image width */ + width?: (number|null); + } + + /** Represents an Image. */ + class Image implements IImage { + + /** + * Constructs a new Image. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImage); + + /** Image uri. */ + public uri: string; + + /** Image height. */ + public height: number; + + /** Image width. */ + public width: number; + + /** + * Creates a new Image instance using the specified properties. + * @param [properties] Properties to set + * @returns Image instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImage): google.cloud.retail.v2beta.Image; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2beta.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Image.verify|verify} messages. + * @param message Image message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Image message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Image + * @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.cloud.retail.v2beta.Image; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Image + * @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.cloud.retail.v2beta.Image; + + /** + * Verifies an Image 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 Image message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Image + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Image; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @param message Image + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Image, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Image to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Image + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Interval. */ + interface IInterval { + + /** Interval minimum */ + minimum?: (number|null); + + /** Interval exclusiveMinimum */ + exclusiveMinimum?: (number|null); + + /** Interval maximum */ + maximum?: (number|null); + + /** Interval exclusiveMaximum */ + exclusiveMaximum?: (number|null); + } + + /** Represents an Interval. */ + class Interval implements IInterval { + + /** + * Constructs a new Interval. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IInterval); + + /** Interval minimum. */ + public minimum?: (number|null); + + /** Interval exclusiveMinimum. */ + public exclusiveMinimum?: (number|null); + + /** Interval maximum. */ + public maximum?: (number|null); + + /** Interval exclusiveMaximum. */ + public exclusiveMaximum?: (number|null); + + /** Interval min. */ + public min?: ("minimum"|"exclusiveMinimum"); + + /** Interval max. */ + public max?: ("maximum"|"exclusiveMaximum"); + + /** + * Creates a new Interval instance using the specified properties. + * @param [properties] Properties to set + * @returns Interval instance + */ + public static create(properties?: google.cloud.retail.v2beta.IInterval): google.cloud.retail.v2beta.Interval; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2beta.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Interval.verify|verify} messages. + * @param message Interval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IInterval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Interval + * @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.cloud.retail.v2beta.Interval; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Interval + * @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.cloud.retail.v2beta.Interval; + + /** + * Verifies an Interval 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 Interval message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Interval + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Interval; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @param message Interval + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Interval, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Interval to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Interval + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PriceInfo. */ + interface IPriceInfo { + + /** PriceInfo currencyCode */ + currencyCode?: (string|null); + + /** PriceInfo price */ + price?: (number|null); + + /** PriceInfo originalPrice */ + originalPrice?: (number|null); + + /** PriceInfo cost */ + cost?: (number|null); + + /** PriceInfo priceEffectiveTime */ + priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime */ + priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange */ + priceRange?: (google.cloud.retail.v2beta.PriceInfo.IPriceRange|null); + } + + /** Represents a PriceInfo. */ + class PriceInfo implements IPriceInfo { + + /** + * Constructs a new PriceInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPriceInfo); + + /** PriceInfo currencyCode. */ + public currencyCode: string; + + /** PriceInfo price. */ + public price: number; + + /** PriceInfo originalPrice. */ + public originalPrice: number; + + /** PriceInfo cost. */ + public cost: number; + + /** PriceInfo priceEffectiveTime. */ + public priceEffectiveTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceExpireTime. */ + public priceExpireTime?: (google.protobuf.ITimestamp|null); + + /** PriceInfo priceRange. */ + public priceRange?: (google.cloud.retail.v2beta.PriceInfo.IPriceRange|null); + + /** + * Creates a new PriceInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceInfo instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPriceInfo): google.cloud.retail.v2beta.PriceInfo; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.verify|verify} messages. + * @param message PriceInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPriceInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceInfo + * @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.cloud.retail.v2beta.PriceInfo; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceInfo + * @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.cloud.retail.v2beta.PriceInfo; + + /** + * Verifies a PriceInfo 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 PriceInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PriceInfo; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @param message PriceInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PriceInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PriceInfo { + + /** Properties of a PriceRange. */ + interface IPriceRange { + + /** PriceRange price */ + price?: (google.cloud.retail.v2beta.IInterval|null); + + /** PriceRange originalPrice */ + originalPrice?: (google.cloud.retail.v2beta.IInterval|null); + } + + /** Represents a PriceRange. */ + class PriceRange implements IPriceRange { + + /** + * Constructs a new PriceRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.PriceInfo.IPriceRange); + + /** PriceRange price. */ + public price?: (google.cloud.retail.v2beta.IInterval|null); + + /** PriceRange originalPrice. */ + public originalPrice?: (google.cloud.retail.v2beta.IInterval|null); + + /** + * Creates a new PriceRange instance using the specified properties. + * @param [properties] Properties to set + * @returns PriceRange instance + */ + public static create(properties?: google.cloud.retail.v2beta.PriceInfo.IPriceRange): google.cloud.retail.v2beta.PriceInfo.PriceRange; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.PriceRange.verify|verify} messages. + * @param message PriceRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.PriceInfo.IPriceRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PriceRange + * @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.cloud.retail.v2beta.PriceInfo.PriceRange; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PriceRange + * @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.cloud.retail.v2beta.PriceInfo.PriceRange; + + /** + * Verifies a PriceRange 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 PriceRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PriceRange + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PriceInfo.PriceRange; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @param message PriceRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PriceInfo.PriceRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PriceRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PriceRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Rating. */ + interface IRating { + + /** Rating ratingCount */ + ratingCount?: (number|null); + + /** Rating averageRating */ + averageRating?: (number|null); + + /** Rating ratingHistogram */ + ratingHistogram?: (number[]|null); + } + + /** Represents a Rating. */ + class Rating implements IRating { + + /** + * Constructs a new Rating. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRating); + + /** Rating ratingCount. */ + public ratingCount: number; + + /** Rating averageRating. */ + public averageRating: number; + + /** Rating ratingHistogram. */ + public ratingHistogram: number[]; + + /** + * Creates a new Rating instance using the specified properties. + * @param [properties] Properties to set + * @returns Rating instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRating): google.cloud.retail.v2beta.Rating; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2beta.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rating.verify|verify} messages. + * @param message Rating message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRating, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Rating + * @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.cloud.retail.v2beta.Rating; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Rating + * @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.cloud.retail.v2beta.Rating; + + /** + * Verifies a Rating 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 Rating message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Rating + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Rating; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @param message Rating + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Rating, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Rating to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Rating + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserInfo. */ + interface IUserInfo { + + /** UserInfo userId */ + userId?: (string|null); + + /** UserInfo ipAddress */ + ipAddress?: (string|null); + + /** UserInfo userAgent */ + userAgent?: (string|null); + + /** UserInfo directUserRequest */ + directUserRequest?: (boolean|null); + } + + /** Represents a UserInfo. */ + class UserInfo implements IUserInfo { + + /** + * Constructs a new UserInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUserInfo); + + /** UserInfo userId. */ + public userId: string; + + /** UserInfo ipAddress. */ + public ipAddress: string; + + /** UserInfo userAgent. */ + public userAgent: string; + + /** UserInfo directUserRequest. */ + public directUserRequest: boolean; + + /** + * Creates a new UserInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns UserInfo instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUserInfo): google.cloud.retail.v2beta.UserInfo; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2beta.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserInfo.verify|verify} messages. + * @param message UserInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserInfo + * @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.cloud.retail.v2beta.UserInfo; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserInfo + * @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.cloud.retail.v2beta.UserInfo; + + /** + * Verifies a UserInfo 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 UserInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UserInfo; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @param message UserInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UserInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a LocalInventory. */ + interface ILocalInventory { + + /** LocalInventory placeId */ + placeId?: (string|null); + + /** LocalInventory priceInfo */ + priceInfo?: (google.cloud.retail.v2beta.IPriceInfo|null); + + /** LocalInventory attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2beta.ICustomAttribute }|null); + + /** LocalInventory fulfillmentTypes */ + fulfillmentTypes?: (string[]|null); + } + + /** Represents a LocalInventory. */ + class LocalInventory implements ILocalInventory { + + /** + * Constructs a new LocalInventory. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ILocalInventory); + + /** LocalInventory placeId. */ + public placeId: string; + + /** LocalInventory priceInfo. */ + public priceInfo?: (google.cloud.retail.v2beta.IPriceInfo|null); + + /** LocalInventory attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2beta.ICustomAttribute }; + + /** LocalInventory fulfillmentTypes. */ + public fulfillmentTypes: string[]; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @param [properties] Properties to set + * @returns LocalInventory instance + */ + public static create(properties?: google.cloud.retail.v2beta.ILocalInventory): google.cloud.retail.v2beta.LocalInventory; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2beta.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.LocalInventory.verify|verify} messages. + * @param message LocalInventory message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ILocalInventory, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LocalInventory + * @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.cloud.retail.v2beta.LocalInventory; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LocalInventory + * @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.cloud.retail.v2beta.LocalInventory; + + /** + * Verifies a LocalInventory 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 LocalInventory message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocalInventory + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.LocalInventory; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @param message LocalInventory + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.LocalInventory, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocalInventory to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LocalInventory + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GcsSource. */ + interface IGcsSource { + + /** GcsSource inputUris */ + inputUris?: (string[]|null); + + /** GcsSource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a GcsSource. */ + class GcsSource implements IGcsSource { + + /** + * Constructs a new GcsSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGcsSource); + + /** GcsSource inputUris. */ + public inputUris: string[]; + + /** GcsSource dataSchema. */ + public dataSchema: string; + + /** + * Creates a new GcsSource instance using the specified properties. + * @param [properties] Properties to set + * @returns GcsSource instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGcsSource): google.cloud.retail.v2beta.GcsSource; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2beta.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GcsSource.verify|verify} messages. + * @param message GcsSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGcsSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GcsSource + * @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.cloud.retail.v2beta.GcsSource; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GcsSource + * @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.cloud.retail.v2beta.GcsSource; + + /** + * Verifies a GcsSource 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 GcsSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GcsSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GcsSource; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @param message GcsSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GcsSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GcsSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GcsSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BigQuerySource. */ + interface IBigQuerySource { + + /** BigQuerySource partitionDate */ + partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId */ + projectId?: (string|null); + + /** BigQuerySource datasetId */ + datasetId?: (string|null); + + /** BigQuerySource tableId */ + tableId?: (string|null); + + /** BigQuerySource gcsStagingDir */ + gcsStagingDir?: (string|null); + + /** BigQuerySource dataSchema */ + dataSchema?: (string|null); + } + + /** Represents a BigQuerySource. */ + class BigQuerySource implements IBigQuerySource { + + /** + * Constructs a new BigQuerySource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IBigQuerySource); + + /** BigQuerySource partitionDate. */ + public partitionDate?: (google.type.IDate|null); + + /** BigQuerySource projectId. */ + public projectId: string; + + /** BigQuerySource datasetId. */ + public datasetId: string; + + /** BigQuerySource tableId. */ + public tableId: string; + + /** BigQuerySource gcsStagingDir. */ + public gcsStagingDir: string; + + /** BigQuerySource dataSchema. */ + public dataSchema: string; + + /** BigQuerySource partition. */ + public partition?: "partitionDate"; + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQuerySource instance + */ + public static create(properties?: google.cloud.retail.v2beta.IBigQuerySource): google.cloud.retail.v2beta.BigQuerySource; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2beta.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BigQuerySource.verify|verify} messages. + * @param message BigQuerySource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IBigQuerySource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQuerySource + * @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.cloud.retail.v2beta.BigQuerySource; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQuerySource + * @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.cloud.retail.v2beta.BigQuerySource; + + /** + * Verifies a BigQuerySource 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 BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQuerySource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.BigQuerySource; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @param message BigQuerySource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.BigQuerySource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQuerySource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BigQuerySource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInlineSource. */ + interface IProductInlineSource { + + /** ProductInlineSource products */ + products?: (google.cloud.retail.v2beta.IProduct[]|null); + } + + /** Represents a ProductInlineSource. */ + class ProductInlineSource implements IProductInlineSource { + + /** + * Constructs a new ProductInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IProductInlineSource); + + /** ProductInlineSource products. */ + public products: google.cloud.retail.v2beta.IProduct[]; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2beta.IProductInlineSource): google.cloud.retail.v2beta.ProductInlineSource; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2beta.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductInlineSource.verify|verify} messages. + * @param message ProductInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IProductInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInlineSource + * @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.cloud.retail.v2beta.ProductInlineSource; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInlineSource + * @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.cloud.retail.v2beta.ProductInlineSource; + + /** + * Verifies a ProductInlineSource 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 ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ProductInlineSource; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @param message ProductInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ProductInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInlineSource. */ + interface IUserEventInlineSource { + + /** UserEventInlineSource userEvents */ + userEvents?: (google.cloud.retail.v2beta.IUserEvent[]|null); + } + + /** Represents a UserEventInlineSource. */ + class UserEventInlineSource implements IUserEventInlineSource { + + /** + * Constructs a new UserEventInlineSource. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUserEventInlineSource); + + /** UserEventInlineSource userEvents. */ + public userEvents: google.cloud.retail.v2beta.IUserEvent[]; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInlineSource instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUserEventInlineSource): google.cloud.retail.v2beta.UserEventInlineSource; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInlineSource.verify|verify} messages. + * @param message UserEventInlineSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUserEventInlineSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInlineSource + * @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.cloud.retail.v2beta.UserEventInlineSource; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInlineSource + * @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.cloud.retail.v2beta.UserEventInlineSource; + + /** + * Verifies a UserEventInlineSource 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 UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInlineSource + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UserEventInlineSource; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @param message UserEventInlineSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UserEventInlineSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInlineSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInlineSource + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportErrorsConfig. */ + interface IImportErrorsConfig { + + /** ImportErrorsConfig gcsPrefix */ + gcsPrefix?: (string|null); + } + + /** Represents an ImportErrorsConfig. */ + class ImportErrorsConfig implements IImportErrorsConfig { + + /** + * Constructs a new ImportErrorsConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportErrorsConfig); + + /** ImportErrorsConfig gcsPrefix. */ + public gcsPrefix?: (string|null); + + /** ImportErrorsConfig destination. */ + public destination?: "gcsPrefix"; + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportErrorsConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportErrorsConfig): google.cloud.retail.v2beta.ImportErrorsConfig; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportErrorsConfig.verify|verify} messages. + * @param message ImportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportErrorsConfig + * @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.cloud.retail.v2beta.ImportErrorsConfig; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportErrorsConfig + * @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.cloud.retail.v2beta.ImportErrorsConfig; + + /** + * Verifies an ImportErrorsConfig 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 ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportErrorsConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportErrorsConfig; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @param message ImportErrorsConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportErrorsConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportErrorsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsRequest. */ + interface IImportProductsRequest { + + /** ImportProductsRequest parent */ + parent?: (string|null); + + /** ImportProductsRequest requestId */ + requestId?: (string|null); + + /** ImportProductsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2beta.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode */ + reconciliationMode?: (google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode|null); + + /** ImportProductsRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportProductsRequest. */ + class ImportProductsRequest implements IImportProductsRequest { + + /** + * Constructs a new ImportProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportProductsRequest); + + /** ImportProductsRequest parent. */ + public parent: string; + + /** ImportProductsRequest requestId. */ + public requestId: string; + + /** ImportProductsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2beta.IProductInputConfig|null); + + /** ImportProductsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** ImportProductsRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** ImportProductsRequest reconciliationMode. */ + public reconciliationMode: (google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode|keyof typeof google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode); + + /** ImportProductsRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportProductsRequest): google.cloud.retail.v2beta.ImportProductsRequest; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsRequest.verify|verify} messages. + * @param message ImportProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsRequest + * @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.cloud.retail.v2beta.ImportProductsRequest; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsRequest + * @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.cloud.retail.v2beta.ImportProductsRequest; + + /** + * Verifies an ImportProductsRequest 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 ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportProductsRequest; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @param message ImportProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ImportProductsRequest { + + /** ReconciliationMode enum. */ + enum ReconciliationMode { + RECONCILIATION_MODE_UNSPECIFIED = 0, + INCREMENTAL = 1, + FULL = 2 + } + } + + /** Properties of an ImportUserEventsRequest. */ + interface IImportUserEventsRequest { + + /** ImportUserEventsRequest parent */ + parent?: (string|null); + + /** ImportUserEventsRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2beta.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + } + + /** Represents an ImportUserEventsRequest. */ + class ImportUserEventsRequest implements IImportUserEventsRequest { + + /** + * Constructs a new ImportUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportUserEventsRequest); + + /** ImportUserEventsRequest parent. */ + public parent: string; + + /** ImportUserEventsRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2beta.IUserEventInputConfig|null); + + /** ImportUserEventsRequest errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportUserEventsRequest): google.cloud.retail.v2beta.ImportUserEventsRequest; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsRequest.verify|verify} messages. + * @param message ImportUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2beta.ImportUserEventsRequest; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsRequest + * @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.cloud.retail.v2beta.ImportUserEventsRequest; + + /** + * Verifies an ImportUserEventsRequest 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 ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportUserEventsRequest; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @param message ImportUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataRequest. */ + interface IImportCompletionDataRequest { + + /** ImportCompletionDataRequest parent */ + parent?: (string|null); + + /** ImportCompletionDataRequest inputConfig */ + inputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportCompletionDataRequest. */ + class ImportCompletionDataRequest implements IImportCompletionDataRequest { + + /** + * Constructs a new ImportCompletionDataRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportCompletionDataRequest); + + /** ImportCompletionDataRequest parent. */ + public parent: string; + + /** ImportCompletionDataRequest inputConfig. */ + public inputConfig?: (google.cloud.retail.v2beta.ICompletionDataInputConfig|null); + + /** ImportCompletionDataRequest notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportCompletionDataRequest): google.cloud.retail.v2beta.ImportCompletionDataRequest; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataRequest.verify|verify} messages. + * @param message ImportCompletionDataRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportCompletionDataRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2beta.ImportCompletionDataRequest; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataRequest + * @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.cloud.retail.v2beta.ImportCompletionDataRequest; + + /** + * Verifies an ImportCompletionDataRequest 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 ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportCompletionDataRequest; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @param message ImportCompletionDataRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportCompletionDataRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductInputConfig. */ + interface IProductInputConfig { + + /** ProductInputConfig productInlineSource */ + productInlineSource?: (google.cloud.retail.v2beta.IProductInlineSource|null); + + /** ProductInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2beta.IGcsSource|null); + + /** ProductInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + } + + /** Represents a ProductInputConfig. */ + class ProductInputConfig implements IProductInputConfig { + + /** + * Constructs a new ProductInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IProductInputConfig); + + /** ProductInputConfig productInlineSource. */ + public productInlineSource?: (google.cloud.retail.v2beta.IProductInlineSource|null); + + /** ProductInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2beta.IGcsSource|null); + + /** ProductInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + + /** ProductInputConfig source. */ + public source?: ("productInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IProductInputConfig): google.cloud.retail.v2beta.ProductInputConfig; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductInputConfig.verify|verify} messages. + * @param message ProductInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IProductInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductInputConfig + * @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.cloud.retail.v2beta.ProductInputConfig; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductInputConfig + * @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.cloud.retail.v2beta.ProductInputConfig; + + /** + * Verifies a ProductInputConfig 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 ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ProductInputConfig; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @param message ProductInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ProductInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventInputConfig. */ + interface IUserEventInputConfig { + + /** UserEventInputConfig userEventInlineSource */ + userEventInlineSource?: (google.cloud.retail.v2beta.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource */ + gcsSource?: (google.cloud.retail.v2beta.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + } + + /** Represents a UserEventInputConfig. */ + class UserEventInputConfig implements IUserEventInputConfig { + + /** + * Constructs a new UserEventInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUserEventInputConfig); + + /** UserEventInputConfig userEventInlineSource. */ + public userEventInlineSource?: (google.cloud.retail.v2beta.IUserEventInlineSource|null); + + /** UserEventInputConfig gcsSource. */ + public gcsSource?: (google.cloud.retail.v2beta.IGcsSource|null); + + /** UserEventInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + + /** UserEventInputConfig source. */ + public source?: ("userEventInlineSource"|"gcsSource"|"bigQuerySource"); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUserEventInputConfig): google.cloud.retail.v2beta.UserEventInputConfig; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInputConfig.verify|verify} messages. + * @param message UserEventInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUserEventInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventInputConfig + * @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.cloud.retail.v2beta.UserEventInputConfig; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventInputConfig + * @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.cloud.retail.v2beta.UserEventInputConfig; + + /** + * Verifies a UserEventInputConfig 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 UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UserEventInputConfig; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @param message UserEventInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UserEventInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDataInputConfig. */ + interface ICompletionDataInputConfig { + + /** CompletionDataInputConfig bigQuerySource */ + bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + } + + /** Represents a CompletionDataInputConfig. */ + class CompletionDataInputConfig implements ICompletionDataInputConfig { + + /** + * Constructs a new CompletionDataInputConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICompletionDataInputConfig); + + /** CompletionDataInputConfig bigQuerySource. */ + public bigQuerySource?: (google.cloud.retail.v2beta.IBigQuerySource|null); + + /** CompletionDataInputConfig source. */ + public source?: "bigQuerySource"; + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDataInputConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICompletionDataInputConfig): google.cloud.retail.v2beta.CompletionDataInputConfig; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDataInputConfig.verify|verify} messages. + * @param message CompletionDataInputConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICompletionDataInputConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2beta.CompletionDataInputConfig; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDataInputConfig + * @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.cloud.retail.v2beta.CompletionDataInputConfig; + + /** + * Verifies a CompletionDataInputConfig 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 CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDataInputConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompletionDataInputConfig; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @param message CompletionDataInputConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompletionDataInputConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportMetadata. */ + interface IImportMetadata { + + /** ImportMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount */ + successCount?: (number|Long|string|null); + + /** ImportMetadata failureCount */ + failureCount?: (number|Long|string|null); + + /** ImportMetadata requestId */ + requestId?: (string|null); + + /** ImportMetadata notificationPubsubTopic */ + notificationPubsubTopic?: (string|null); + } + + /** Represents an ImportMetadata. */ + class ImportMetadata implements IImportMetadata { + + /** + * Constructs a new ImportMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportMetadata); + + /** ImportMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** ImportMetadata successCount. */ + public successCount: (number|Long|string); + + /** ImportMetadata failureCount. */ + public failureCount: (number|Long|string); + + /** ImportMetadata requestId. */ + public requestId: string; + + /** ImportMetadata notificationPubsubTopic. */ + public notificationPubsubTopic: string; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportMetadata): google.cloud.retail.v2beta.ImportMetadata; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportMetadata.verify|verify} messages. + * @param message ImportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportMetadata + * @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.cloud.retail.v2beta.ImportMetadata; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportMetadata + * @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.cloud.retail.v2beta.ImportMetadata; + + /** + * Verifies an ImportMetadata 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 ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportMetadata; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @param message ImportMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportProductsResponse. */ + interface IImportProductsResponse { + + /** ImportProductsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportProductsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + } + + /** Represents an ImportProductsResponse. */ + class ImportProductsResponse implements IImportProductsResponse { + + /** + * Constructs a new ImportProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportProductsResponse); + + /** ImportProductsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportProductsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportProductsResponse): google.cloud.retail.v2beta.ImportProductsResponse; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsResponse.verify|verify} messages. + * @param message ImportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportProductsResponse + * @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.cloud.retail.v2beta.ImportProductsResponse; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportProductsResponse + * @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.cloud.retail.v2beta.ImportProductsResponse; + + /** + * Verifies an ImportProductsResponse 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 ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportProductsResponse; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @param message ImportProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportUserEventsResponse. */ + interface IImportUserEventsResponse { + + /** ImportUserEventsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ImportUserEventsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary */ + importSummary?: (google.cloud.retail.v2beta.IUserEventImportSummary|null); + } + + /** Represents an ImportUserEventsResponse. */ + class ImportUserEventsResponse implements IImportUserEventsResponse { + + /** + * Constructs a new ImportUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportUserEventsResponse); + + /** ImportUserEventsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ImportUserEventsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IImportErrorsConfig|null); + + /** ImportUserEventsResponse importSummary. */ + public importSummary?: (google.cloud.retail.v2beta.IUserEventImportSummary|null); + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportUserEventsResponse): google.cloud.retail.v2beta.ImportUserEventsResponse; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsResponse.verify|verify} messages. + * @param message ImportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2beta.ImportUserEventsResponse; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportUserEventsResponse + * @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.cloud.retail.v2beta.ImportUserEventsResponse; + + /** + * Verifies an ImportUserEventsResponse 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 ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportUserEventsResponse; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @param message ImportUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEventImportSummary. */ + interface IUserEventImportSummary { + + /** UserEventImportSummary joinedEventsCount */ + joinedEventsCount?: (number|Long|string|null); + + /** UserEventImportSummary unjoinedEventsCount */ + unjoinedEventsCount?: (number|Long|string|null); + } + + /** Represents a UserEventImportSummary. */ + class UserEventImportSummary implements IUserEventImportSummary { + + /** + * Constructs a new UserEventImportSummary. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUserEventImportSummary); + + /** UserEventImportSummary joinedEventsCount. */ + public joinedEventsCount: (number|Long|string); + + /** UserEventImportSummary unjoinedEventsCount. */ + public unjoinedEventsCount: (number|Long|string); + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEventImportSummary instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUserEventImportSummary): google.cloud.retail.v2beta.UserEventImportSummary; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventImportSummary.verify|verify} messages. + * @param message UserEventImportSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUserEventImportSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEventImportSummary + * @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.cloud.retail.v2beta.UserEventImportSummary; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEventImportSummary + * @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.cloud.retail.v2beta.UserEventImportSummary; + + /** + * Verifies a UserEventImportSummary 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 UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEventImportSummary + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UserEventImportSummary; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @param message UserEventImportSummary + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UserEventImportSummary, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEventImportSummary to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEventImportSummary + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportCompletionDataResponse. */ + interface IImportCompletionDataResponse { + + /** ImportCompletionDataResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + } + + /** Represents an ImportCompletionDataResponse. */ + class ImportCompletionDataResponse implements IImportCompletionDataResponse { + + /** + * Constructs a new ImportCompletionDataResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IImportCompletionDataResponse); + + /** ImportCompletionDataResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportCompletionDataResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IImportCompletionDataResponse): google.cloud.retail.v2beta.ImportCompletionDataResponse; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataResponse.verify|verify} messages. + * @param message ImportCompletionDataResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IImportCompletionDataResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2beta.ImportCompletionDataResponse; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportCompletionDataResponse + * @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.cloud.retail.v2beta.ImportCompletionDataResponse; + + /** + * Verifies an ImportCompletionDataResponse 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 ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportCompletionDataResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ImportCompletionDataResponse; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @param message ImportCompletionDataResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ImportCompletionDataResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Product. */ + interface IProduct { + + /** Product expireTime */ + expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl */ + ttl?: (google.protobuf.IDuration|null); + + /** Product name */ + name?: (string|null); + + /** Product id */ + id?: (string|null); + + /** Product type */ + type?: (google.cloud.retail.v2beta.Product.Type|keyof typeof google.cloud.retail.v2beta.Product.Type|null); + + /** Product primaryProductId */ + primaryProductId?: (string|null); + + /** Product collectionMemberIds */ + collectionMemberIds?: (string[]|null); + + /** Product gtin */ + gtin?: (string|null); + + /** Product categories */ + categories?: (string[]|null); + + /** Product title */ + title?: (string|null); + + /** Product brands */ + brands?: (string[]|null); + + /** Product description */ + description?: (string|null); + + /** Product languageCode */ + languageCode?: (string|null); + + /** Product attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2beta.ICustomAttribute }|null); + + /** Product tags */ + tags?: (string[]|null); + + /** Product priceInfo */ + priceInfo?: (google.cloud.retail.v2beta.IPriceInfo|null); + + /** Product rating */ + rating?: (google.cloud.retail.v2beta.IRating|null); + + /** Product availableTime */ + availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability */ + availability?: (google.cloud.retail.v2beta.Product.Availability|keyof typeof google.cloud.retail.v2beta.Product.Availability|null); + + /** Product availableQuantity */ + availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo */ + fulfillmentInfo?: (google.cloud.retail.v2beta.IFulfillmentInfo[]|null); + + /** Product uri */ + uri?: (string|null); + + /** Product images */ + images?: (google.cloud.retail.v2beta.IImage[]|null); + + /** Product audience */ + audience?: (google.cloud.retail.v2beta.IAudience|null); + + /** Product colorInfo */ + colorInfo?: (google.cloud.retail.v2beta.IColorInfo|null); + + /** Product sizes */ + sizes?: (string[]|null); + + /** Product materials */ + materials?: (string[]|null); + + /** Product patterns */ + patterns?: (string[]|null); + + /** Product conditions */ + conditions?: (string[]|null); + + /** Product promotions */ + promotions?: (google.cloud.retail.v2beta.IPromotion[]|null); + + /** Product publishTime */ + publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields */ + retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants */ + variants?: (google.cloud.retail.v2beta.IProduct[]|null); + + /** Product localInventories */ + localInventories?: (google.cloud.retail.v2beta.ILocalInventory[]|null); + } + + /** Represents a Product. */ + class Product implements IProduct { + + /** + * Constructs a new Product. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IProduct); + + /** Product expireTime. */ + public expireTime?: (google.protobuf.ITimestamp|null); + + /** Product ttl. */ + public ttl?: (google.protobuf.IDuration|null); + + /** Product name. */ + public name: string; + + /** Product id. */ + public id: string; + + /** Product type. */ + public type: (google.cloud.retail.v2beta.Product.Type|keyof typeof google.cloud.retail.v2beta.Product.Type); + + /** Product primaryProductId. */ + public primaryProductId: string; + + /** Product collectionMemberIds. */ + public collectionMemberIds: string[]; + + /** Product gtin. */ + public gtin: string; + + /** Product categories. */ + public categories: string[]; + + /** Product title. */ + public title: string; + + /** Product brands. */ + public brands: string[]; + + /** Product description. */ + public description: string; + + /** Product languageCode. */ + public languageCode: string; + + /** Product attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2beta.ICustomAttribute }; + + /** Product tags. */ + public tags: string[]; + + /** Product priceInfo. */ + public priceInfo?: (google.cloud.retail.v2beta.IPriceInfo|null); + + /** Product rating. */ + public rating?: (google.cloud.retail.v2beta.IRating|null); + + /** Product availableTime. */ + public availableTime?: (google.protobuf.ITimestamp|null); + + /** Product availability. */ + public availability: (google.cloud.retail.v2beta.Product.Availability|keyof typeof google.cloud.retail.v2beta.Product.Availability); + + /** Product availableQuantity. */ + public availableQuantity?: (google.protobuf.IInt32Value|null); + + /** Product fulfillmentInfo. */ + public fulfillmentInfo: google.cloud.retail.v2beta.IFulfillmentInfo[]; + + /** Product uri. */ + public uri: string; + + /** Product images. */ + public images: google.cloud.retail.v2beta.IImage[]; + + /** Product audience. */ + public audience?: (google.cloud.retail.v2beta.IAudience|null); + + /** Product colorInfo. */ + public colorInfo?: (google.cloud.retail.v2beta.IColorInfo|null); + + /** Product sizes. */ + public sizes: string[]; + + /** Product materials. */ + public materials: string[]; + + /** Product patterns. */ + public patterns: string[]; + + /** Product conditions. */ + public conditions: string[]; + + /** Product promotions. */ + public promotions: google.cloud.retail.v2beta.IPromotion[]; + + /** Product publishTime. */ + public publishTime?: (google.protobuf.ITimestamp|null); + + /** Product retrievableFields. */ + public retrievableFields?: (google.protobuf.IFieldMask|null); + + /** Product variants. */ + public variants: google.cloud.retail.v2beta.IProduct[]; + + /** Product localInventories. */ + public localInventories: google.cloud.retail.v2beta.ILocalInventory[]; + + /** Product expiration. */ + public expiration?: ("expireTime"|"ttl"); + + /** + * Creates a new Product instance using the specified properties. + * @param [properties] Properties to set + * @returns Product instance + */ + public static create(properties?: google.cloud.retail.v2beta.IProduct): google.cloud.retail.v2beta.Product; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2beta.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Product.verify|verify} messages. + * @param message Product message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IProduct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Product message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Product + * @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.cloud.retail.v2beta.Product; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Product + * @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.cloud.retail.v2beta.Product; + + /** + * Verifies a Product 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 Product message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Product + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Product; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @param message Product + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Product, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Product to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Product + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Product { + + /** Type enum. */ + enum Type { + TYPE_UNSPECIFIED = 0, + PRIMARY = 1, + VARIANT = 2, + COLLECTION = 3 + } + + /** Availability enum. */ + enum Availability { + AVAILABILITY_UNSPECIFIED = 0, + IN_STOCK = 1, + OUT_OF_STOCK = 2, + PREORDER = 3, + BACKORDER = 4 + } + } + + /** Properties of a Promotion. */ + interface IPromotion { + + /** Promotion promotionId */ + promotionId?: (string|null); + } + + /** Represents a Promotion. */ + class Promotion implements IPromotion { + + /** + * Constructs a new Promotion. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPromotion); + + /** Promotion promotionId. */ + public promotionId: string; + + /** + * Creates a new Promotion instance using the specified properties. + * @param [properties] Properties to set + * @returns Promotion instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPromotion): google.cloud.retail.v2beta.Promotion; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2beta.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Promotion.verify|verify} messages. + * @param message Promotion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPromotion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Promotion + * @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.cloud.retail.v2beta.Promotion; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Promotion + * @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.cloud.retail.v2beta.Promotion; + + /** + * Verifies a Promotion 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 Promotion message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Promotion + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Promotion; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @param message Promotion + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Promotion, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Promotion to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Promotion + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UserEvent. */ + interface IUserEvent { + + /** UserEvent eventType */ + eventType?: (string|null); + + /** UserEvent visitorId */ + visitorId?: (string|null); + + /** UserEvent sessionId */ + sessionId?: (string|null); + + /** UserEvent eventTime */ + eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds */ + experimentIds?: (string[]|null); + + /** UserEvent attributionToken */ + attributionToken?: (string|null); + + /** UserEvent productDetails */ + productDetails?: (google.cloud.retail.v2beta.IProductDetail[]|null); + + /** UserEvent completionDetail */ + completionDetail?: (google.cloud.retail.v2beta.ICompletionDetail|null); + + /** UserEvent attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2beta.ICustomAttribute }|null); + + /** UserEvent cartId */ + cartId?: (string|null); + + /** UserEvent purchaseTransaction */ + purchaseTransaction?: (google.cloud.retail.v2beta.IPurchaseTransaction|null); + + /** UserEvent searchQuery */ + searchQuery?: (string|null); + + /** UserEvent filter */ + filter?: (string|null); + + /** UserEvent orderBy */ + orderBy?: (string|null); + + /** UserEvent offset */ + offset?: (number|null); + + /** UserEvent pageCategories */ + pageCategories?: (string[]|null); + + /** UserEvent userInfo */ + userInfo?: (google.cloud.retail.v2beta.IUserInfo|null); + + /** UserEvent uri */ + uri?: (string|null); + + /** UserEvent referrerUri */ + referrerUri?: (string|null); + + /** UserEvent pageViewId */ + pageViewId?: (string|null); + } + + /** Represents a UserEvent. */ + class UserEvent implements IUserEvent { + + /** + * Constructs a new UserEvent. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUserEvent); + + /** UserEvent eventType. */ + public eventType: string; + + /** UserEvent visitorId. */ + public visitorId: string; + + /** UserEvent sessionId. */ + public sessionId: string; + + /** UserEvent eventTime. */ + public eventTime?: (google.protobuf.ITimestamp|null); + + /** UserEvent experimentIds. */ + public experimentIds: string[]; + + /** UserEvent attributionToken. */ + public attributionToken: string; + + /** UserEvent productDetails. */ + public productDetails: google.cloud.retail.v2beta.IProductDetail[]; + + /** UserEvent completionDetail. */ + public completionDetail?: (google.cloud.retail.v2beta.ICompletionDetail|null); + + /** UserEvent attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2beta.ICustomAttribute }; + + /** UserEvent cartId. */ + public cartId: string; + + /** UserEvent purchaseTransaction. */ + public purchaseTransaction?: (google.cloud.retail.v2beta.IPurchaseTransaction|null); + + /** UserEvent searchQuery. */ + public searchQuery: string; + + /** UserEvent filter. */ + public filter: string; + + /** UserEvent orderBy. */ + public orderBy: string; + + /** UserEvent offset. */ + public offset: number; + + /** UserEvent pageCategories. */ + public pageCategories: string[]; + + /** UserEvent userInfo. */ + public userInfo?: (google.cloud.retail.v2beta.IUserInfo|null); + + /** UserEvent uri. */ + public uri: string; + + /** UserEvent referrerUri. */ + public referrerUri: string; + + /** UserEvent pageViewId. */ + public pageViewId: string; + + /** + * Creates a new UserEvent instance using the specified properties. + * @param [properties] Properties to set + * @returns UserEvent instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUserEvent): google.cloud.retail.v2beta.UserEvent; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2beta.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEvent.verify|verify} messages. + * @param message UserEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUserEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserEvent + * @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.cloud.retail.v2beta.UserEvent; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserEvent + * @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.cloud.retail.v2beta.UserEvent; + + /** + * Verifies a UserEvent 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 UserEvent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserEvent + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UserEvent; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @param message UserEvent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UserEvent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserEvent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UserEvent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ProductDetail. */ + interface IProductDetail { + + /** ProductDetail product */ + product?: (google.cloud.retail.v2beta.IProduct|null); + + /** ProductDetail quantity */ + quantity?: (google.protobuf.IInt32Value|null); + } + + /** Represents a ProductDetail. */ + class ProductDetail implements IProductDetail { + + /** + * Constructs a new ProductDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IProductDetail); + + /** ProductDetail product. */ + public product?: (google.cloud.retail.v2beta.IProduct|null); + + /** ProductDetail quantity. */ + public quantity?: (google.protobuf.IInt32Value|null); + + /** + * Creates a new ProductDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns ProductDetail instance + */ + public static create(properties?: google.cloud.retail.v2beta.IProductDetail): google.cloud.retail.v2beta.ProductDetail; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2beta.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductDetail.verify|verify} messages. + * @param message ProductDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IProductDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ProductDetail + * @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.cloud.retail.v2beta.ProductDetail; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ProductDetail + * @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.cloud.retail.v2beta.ProductDetail; + + /** + * Verifies a ProductDetail 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 ProductDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ProductDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ProductDetail; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @param message ProductDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ProductDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ProductDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ProductDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompletionDetail. */ + interface ICompletionDetail { + + /** CompletionDetail completionAttributionToken */ + completionAttributionToken?: (string|null); + + /** CompletionDetail selectedSuggestion */ + selectedSuggestion?: (string|null); + + /** CompletionDetail selectedPosition */ + selectedPosition?: (number|null); + } + + /** Represents a CompletionDetail. */ + class CompletionDetail implements ICompletionDetail { + + /** + * Constructs a new CompletionDetail. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICompletionDetail); + + /** CompletionDetail completionAttributionToken. */ + public completionAttributionToken: string; + + /** CompletionDetail selectedSuggestion. */ + public selectedSuggestion: string; + + /** CompletionDetail selectedPosition. */ + public selectedPosition: number; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionDetail instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICompletionDetail): google.cloud.retail.v2beta.CompletionDetail; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDetail.verify|verify} messages. + * @param message CompletionDetail message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICompletionDetail, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionDetail + * @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.cloud.retail.v2beta.CompletionDetail; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionDetail + * @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.cloud.retail.v2beta.CompletionDetail; + + /** + * Verifies a CompletionDetail 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 CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionDetail + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompletionDetail; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @param message CompletionDetail + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompletionDetail, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionDetail to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionDetail + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurchaseTransaction. */ + interface IPurchaseTransaction { + + /** PurchaseTransaction id */ + id?: (string|null); + + /** PurchaseTransaction revenue */ + revenue?: (number|null); + + /** PurchaseTransaction tax */ + tax?: (number|null); + + /** PurchaseTransaction cost */ + cost?: (number|null); + + /** PurchaseTransaction currencyCode */ + currencyCode?: (string|null); + } + + /** Represents a PurchaseTransaction. */ + class PurchaseTransaction implements IPurchaseTransaction { + + /** + * Constructs a new PurchaseTransaction. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPurchaseTransaction); + + /** PurchaseTransaction id. */ + public id: string; + + /** PurchaseTransaction revenue. */ + public revenue: number; + + /** PurchaseTransaction tax. */ + public tax: number; + + /** PurchaseTransaction cost. */ + public cost: number; + + /** PurchaseTransaction currencyCode. */ + public currencyCode: string; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @param [properties] Properties to set + * @returns PurchaseTransaction instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPurchaseTransaction): google.cloud.retail.v2beta.PurchaseTransaction; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2beta.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurchaseTransaction.verify|verify} messages. + * @param message PurchaseTransaction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPurchaseTransaction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurchaseTransaction + * @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.cloud.retail.v2beta.PurchaseTransaction; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurchaseTransaction + * @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.cloud.retail.v2beta.PurchaseTransaction; + + /** + * Verifies a PurchaseTransaction 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 PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurchaseTransaction + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PurchaseTransaction; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @param message PurchaseTransaction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PurchaseTransaction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurchaseTransaction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurchaseTransaction + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CatalogService */ + class CatalogService extends $protobuf.rpc.Service { + + /** + * Constructs a new CatalogService 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 CatalogService 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): CatalogService; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCatalogsResponse + */ + public listCatalogs(request: google.cloud.retail.v2beta.IListCatalogsRequest, callback: google.cloud.retail.v2beta.CatalogService.ListCatalogsCallback): void; + + /** + * Calls ListCatalogs. + * @param request ListCatalogsRequest message or plain object + * @returns Promise + */ + public listCatalogs(request: google.cloud.retail.v2beta.IListCatalogsRequest): Promise; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Catalog + */ + public updateCatalog(request: google.cloud.retail.v2beta.IUpdateCatalogRequest, callback: google.cloud.retail.v2beta.CatalogService.UpdateCatalogCallback): void; + + /** + * Calls UpdateCatalog. + * @param request UpdateCatalogRequest message or plain object + * @returns Promise + */ + public updateCatalog(request: google.cloud.retail.v2beta.IUpdateCatalogRequest): Promise; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public setDefaultBranch(request: google.cloud.retail.v2beta.ISetDefaultBranchRequest, callback: google.cloud.retail.v2beta.CatalogService.SetDefaultBranchCallback): void; + + /** + * Calls SetDefaultBranch. + * @param request SetDefaultBranchRequest message or plain object + * @returns Promise + */ + public setDefaultBranch(request: google.cloud.retail.v2beta.ISetDefaultBranchRequest): Promise; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + */ + public getDefaultBranch(request: google.cloud.retail.v2beta.IGetDefaultBranchRequest, callback: google.cloud.retail.v2beta.CatalogService.GetDefaultBranchCallback): void; + + /** + * Calls GetDefaultBranch. + * @param request GetDefaultBranchRequest message or plain object + * @returns Promise + */ + public getDefaultBranch(request: google.cloud.retail.v2beta.IGetDefaultBranchRequest): Promise; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public getCompletionConfig(request: google.cloud.retail.v2beta.IGetCompletionConfigRequest, callback: google.cloud.retail.v2beta.CatalogService.GetCompletionConfigCallback): void; + + /** + * Calls GetCompletionConfig. + * @param request GetCompletionConfigRequest message or plain object + * @returns Promise + */ + public getCompletionConfig(request: google.cloud.retail.v2beta.IGetCompletionConfigRequest): Promise; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompletionConfig + */ + public updateCompletionConfig(request: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, callback: google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfigCallback): void; + + /** + * Calls UpdateCompletionConfig. + * @param request UpdateCompletionConfigRequest message or plain object + * @returns Promise + */ + public updateCompletionConfig(request: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest): Promise; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public getAttributesConfig(request: google.cloud.retail.v2beta.IGetAttributesConfigRequest, callback: google.cloud.retail.v2beta.CatalogService.GetAttributesConfigCallback): void; + + /** + * Calls GetAttributesConfig. + * @param request GetAttributesConfigRequest message or plain object + * @returns Promise + */ + public getAttributesConfig(request: google.cloud.retail.v2beta.IGetAttributesConfigRequest): Promise; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public updateAttributesConfig(request: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, callback: google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfigCallback): void; + + /** + * Calls UpdateAttributesConfig. + * @param request UpdateAttributesConfigRequest message or plain object + * @returns Promise + */ + public updateAttributesConfig(request: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest): Promise; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public addCatalogAttribute(request: google.cloud.retail.v2beta.IAddCatalogAttributeRequest, callback: google.cloud.retail.v2beta.CatalogService.AddCatalogAttributeCallback): void; + + /** + * Calls AddCatalogAttribute. + * @param request AddCatalogAttributeRequest message or plain object + * @returns Promise + */ + public addCatalogAttribute(request: google.cloud.retail.v2beta.IAddCatalogAttributeRequest): Promise; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public removeCatalogAttribute(request: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, callback: google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttributeCallback): void; + + /** + * Calls RemoveCatalogAttribute. + * @param request RemoveCatalogAttributeRequest message or plain object + * @returns Promise + */ + public removeCatalogAttribute(request: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest): Promise; + + /** + * Calls BatchRemoveCatalogAttributes. + * @param request BatchRemoveCatalogAttributesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BatchRemoveCatalogAttributesResponse + */ + public batchRemoveCatalogAttributes(request: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, callback: google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributesCallback): void; + + /** + * Calls BatchRemoveCatalogAttributes. + * @param request BatchRemoveCatalogAttributesRequest message or plain object + * @returns Promise + */ + public batchRemoveCatalogAttributes(request: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest): Promise; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AttributesConfig + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, callback: google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttributeCallback): void; + + /** + * Calls ReplaceCatalogAttribute. + * @param request ReplaceCatalogAttributeRequest message or plain object + * @returns Promise + */ + public replaceCatalogAttribute(request: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest): Promise; + } + + namespace CatalogService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|listCatalogs}. + * @param error Error, if any + * @param [response] ListCatalogsResponse + */ + type ListCatalogsCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ListCatalogsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateCatalog}. + * @param error Error, if any + * @param [response] Catalog + */ + type UpdateCatalogCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Catalog) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|setDefaultBranch}. + * @param error Error, if any + * @param [response] Empty + */ + type SetDefaultBranchCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getDefaultBranch}. + * @param error Error, if any + * @param [response] GetDefaultBranchResponse + */ + type GetDefaultBranchCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.GetDefaultBranchResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type GetCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateCompletionConfig}. + * @param error Error, if any + * @param [response] CompletionConfig + */ + type UpdateCompletionConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.CompletionConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type GetAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateAttributesConfig}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type UpdateAttributesConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|addCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type AddCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|removeCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type RemoveCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.AttributesConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|batchRemoveCatalogAttributes}. + * @param error Error, if any + * @param [response] BatchRemoveCatalogAttributesResponse + */ + type BatchRemoveCatalogAttributesCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|replaceCatalogAttribute}. + * @param error Error, if any + * @param [response] AttributesConfig + */ + type ReplaceCatalogAttributeCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.AttributesConfig) => void; + } + + /** Properties of a ListCatalogsRequest. */ + interface IListCatalogsRequest { + + /** ListCatalogsRequest parent */ + parent?: (string|null); + + /** ListCatalogsRequest pageSize */ + pageSize?: (number|null); + + /** ListCatalogsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCatalogsRequest. */ + class ListCatalogsRequest implements IListCatalogsRequest { + + /** + * Constructs a new ListCatalogsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListCatalogsRequest); + + /** ListCatalogsRequest parent. */ + public parent: string; + + /** ListCatalogsRequest pageSize. */ + public pageSize: number; + + /** ListCatalogsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListCatalogsRequest): google.cloud.retail.v2beta.ListCatalogsRequest; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsRequest.verify|verify} messages. + * @param message ListCatalogsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListCatalogsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsRequest + * @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.cloud.retail.v2beta.ListCatalogsRequest; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsRequest + * @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.cloud.retail.v2beta.ListCatalogsRequest; + + /** + * Verifies a ListCatalogsRequest 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListCatalogsRequest; + + /** + * Creates a plain object from a ListCatalogsRequest message. Also converts values to other types if specified. + * @param message ListCatalogsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListCatalogsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListCatalogsResponse. */ + interface IListCatalogsResponse { + + /** ListCatalogsResponse catalogs */ + catalogs?: (google.cloud.retail.v2beta.ICatalog[]|null); + + /** ListCatalogsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCatalogsResponse. */ + class ListCatalogsResponse implements IListCatalogsResponse { + + /** + * Constructs a new ListCatalogsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListCatalogsResponse); + + /** ListCatalogsResponse catalogs. */ + public catalogs: google.cloud.retail.v2beta.ICatalog[]; + + /** ListCatalogsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCatalogsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListCatalogsResponse): google.cloud.retail.v2beta.ListCatalogsResponse; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsResponse.verify|verify} messages. + * @param message ListCatalogsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListCatalogsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCatalogsResponse + * @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.cloud.retail.v2beta.ListCatalogsResponse; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCatalogsResponse + * @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.cloud.retail.v2beta.ListCatalogsResponse; + + /** + * Verifies a ListCatalogsResponse 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 ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCatalogsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListCatalogsResponse; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @param message ListCatalogsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListCatalogsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListCatalogsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCatalogRequest. */ + interface IUpdateCatalogRequest { + + /** UpdateCatalogRequest catalog */ + catalog?: (google.cloud.retail.v2beta.ICatalog|null); + + /** UpdateCatalogRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCatalogRequest. */ + class UpdateCatalogRequest implements IUpdateCatalogRequest { + + /** + * Constructs a new UpdateCatalogRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateCatalogRequest); + + /** UpdateCatalogRequest catalog. */ + public catalog?: (google.cloud.retail.v2beta.ICatalog|null); + + /** UpdateCatalogRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCatalogRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateCatalogRequest): google.cloud.retail.v2beta.UpdateCatalogRequest; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCatalogRequest.verify|verify} messages. + * @param message UpdateCatalogRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateCatalogRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2beta.UpdateCatalogRequest; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCatalogRequest + * @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.cloud.retail.v2beta.UpdateCatalogRequest; + + /** + * Verifies an UpdateCatalogRequest 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 UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCatalogRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateCatalogRequest; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @param message UpdateCatalogRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateCatalogRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetDefaultBranchRequest. */ + interface ISetDefaultBranchRequest { + + /** SetDefaultBranchRequest catalog */ + catalog?: (string|null); + + /** SetDefaultBranchRequest branchId */ + branchId?: (string|null); + + /** SetDefaultBranchRequest note */ + note?: (string|null); + + /** SetDefaultBranchRequest force */ + force?: (boolean|null); + } + + /** Represents a SetDefaultBranchRequest. */ + class SetDefaultBranchRequest implements ISetDefaultBranchRequest { + + /** + * Constructs a new SetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISetDefaultBranchRequest); + + /** SetDefaultBranchRequest catalog. */ + public catalog: string; + + /** SetDefaultBranchRequest branchId. */ + public branchId: string; + + /** SetDefaultBranchRequest note. */ + public note: string; + + /** SetDefaultBranchRequest force. */ + public force: boolean; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISetDefaultBranchRequest): google.cloud.retail.v2beta.SetDefaultBranchRequest; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.verify|verify} messages. + * @param message SetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2beta.SetDefaultBranchRequest; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetDefaultBranchRequest + * @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.cloud.retail.v2beta.SetDefaultBranchRequest; + + /** + * Verifies a SetDefaultBranchRequest 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 SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SetDefaultBranchRequest; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message SetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchRequest. */ + interface IGetDefaultBranchRequest { + + /** GetDefaultBranchRequest catalog */ + catalog?: (string|null); + } + + /** Represents a GetDefaultBranchRequest. */ + class GetDefaultBranchRequest implements IGetDefaultBranchRequest { + + /** + * Constructs a new GetDefaultBranchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetDefaultBranchRequest); + + /** GetDefaultBranchRequest catalog. */ + public catalog: string; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetDefaultBranchRequest): google.cloud.retail.v2beta.GetDefaultBranchRequest; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchRequest.verify|verify} messages. + * @param message GetDefaultBranchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetDefaultBranchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2beta.GetDefaultBranchRequest; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchRequest + * @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.cloud.retail.v2beta.GetDefaultBranchRequest; + + /** + * Verifies a GetDefaultBranchRequest 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 GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetDefaultBranchRequest; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @param message GetDefaultBranchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetDefaultBranchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDefaultBranchResponse. */ + interface IGetDefaultBranchResponse { + + /** GetDefaultBranchResponse branch */ + branch?: (string|null); + + /** GetDefaultBranchResponse setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note */ + note?: (string|null); + } + + /** Represents a GetDefaultBranchResponse. */ + class GetDefaultBranchResponse implements IGetDefaultBranchResponse { + + /** + * Constructs a new GetDefaultBranchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetDefaultBranchResponse); + + /** GetDefaultBranchResponse branch. */ + public branch: string; + + /** GetDefaultBranchResponse setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** GetDefaultBranchResponse note. */ + public note: string; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDefaultBranchResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetDefaultBranchResponse): google.cloud.retail.v2beta.GetDefaultBranchResponse; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchResponse.verify|verify} messages. + * @param message GetDefaultBranchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetDefaultBranchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2beta.GetDefaultBranchResponse; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDefaultBranchResponse + * @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.cloud.retail.v2beta.GetDefaultBranchResponse; + + /** + * Verifies a GetDefaultBranchResponse 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 GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDefaultBranchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetDefaultBranchResponse; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @param message GetDefaultBranchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetDefaultBranchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetCompletionConfigRequest. */ + interface IGetCompletionConfigRequest { + + /** GetCompletionConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetCompletionConfigRequest. */ + class GetCompletionConfigRequest implements IGetCompletionConfigRequest { + + /** + * Constructs a new GetCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetCompletionConfigRequest); + + /** GetCompletionConfigRequest name. */ + public name: string; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetCompletionConfigRequest): google.cloud.retail.v2beta.GetCompletionConfigRequest; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetCompletionConfigRequest.verify|verify} messages. + * @param message GetCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2beta.GetCompletionConfigRequest; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCompletionConfigRequest + * @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.cloud.retail.v2beta.GetCompletionConfigRequest; + + /** + * Verifies a GetCompletionConfigRequest 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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetCompletionConfigRequest; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @param message GetCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateCompletionConfigRequest. */ + interface IUpdateCompletionConfigRequest { + + /** UpdateCompletionConfigRequest completionConfig */ + completionConfig?: (google.cloud.retail.v2beta.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCompletionConfigRequest. */ + class UpdateCompletionConfigRequest implements IUpdateCompletionConfigRequest { + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest); + + /** UpdateCompletionConfigRequest completionConfig. */ + public completionConfig?: (google.cloud.retail.v2beta.ICompletionConfig|null); + + /** UpdateCompletionConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCompletionConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest): google.cloud.retail.v2beta.UpdateCompletionConfigRequest; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCompletionConfigRequest.verify|verify} messages. + * @param message UpdateCompletionConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2beta.UpdateCompletionConfigRequest; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCompletionConfigRequest + * @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.cloud.retail.v2beta.UpdateCompletionConfigRequest; + + /** + * Verifies an UpdateCompletionConfigRequest 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 UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCompletionConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateCompletionConfigRequest; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @param message UpdateCompletionConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateCompletionConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetAttributesConfigRequest. */ + interface IGetAttributesConfigRequest { + + /** GetAttributesConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetAttributesConfigRequest. */ + class GetAttributesConfigRequest implements IGetAttributesConfigRequest { + + /** + * Constructs a new GetAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetAttributesConfigRequest); + + /** GetAttributesConfigRequest name. */ + public name: string; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetAttributesConfigRequest): google.cloud.retail.v2beta.GetAttributesConfigRequest; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetAttributesConfigRequest.verify|verify} messages. + * @param message GetAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2beta.GetAttributesConfigRequest; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetAttributesConfigRequest + * @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.cloud.retail.v2beta.GetAttributesConfigRequest; + + /** + * Verifies a GetAttributesConfigRequest 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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetAttributesConfigRequest; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @param message GetAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateAttributesConfigRequest. */ + interface IUpdateAttributesConfigRequest { + + /** UpdateAttributesConfigRequest attributesConfig */ + attributesConfig?: (google.cloud.retail.v2beta.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateAttributesConfigRequest. */ + class UpdateAttributesConfigRequest implements IUpdateAttributesConfigRequest { + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest); + + /** UpdateAttributesConfigRequest attributesConfig. */ + public attributesConfig?: (google.cloud.retail.v2beta.IAttributesConfig|null); + + /** UpdateAttributesConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateAttributesConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest): google.cloud.retail.v2beta.UpdateAttributesConfigRequest; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateAttributesConfigRequest.verify|verify} messages. + * @param message UpdateAttributesConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2beta.UpdateAttributesConfigRequest; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateAttributesConfigRequest + * @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.cloud.retail.v2beta.UpdateAttributesConfigRequest; + + /** + * Verifies an UpdateAttributesConfigRequest 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 UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateAttributesConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateAttributesConfigRequest; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @param message UpdateAttributesConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateAttributesConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddCatalogAttributeRequest. */ + interface IAddCatalogAttributeRequest { + + /** AddCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** AddCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2beta.ICatalogAttribute|null); + } + + /** Represents an AddCatalogAttributeRequest. */ + class AddCatalogAttributeRequest implements IAddCatalogAttributeRequest { + + /** + * Constructs a new AddCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddCatalogAttributeRequest); + + /** AddCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** AddCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2beta.ICatalogAttribute|null); + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddCatalogAttributeRequest): google.cloud.retail.v2beta.AddCatalogAttributeRequest; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddCatalogAttributeRequest.verify|verify} messages. + * @param message AddCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2beta.AddCatalogAttributeRequest; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddCatalogAttributeRequest + * @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.cloud.retail.v2beta.AddCatalogAttributeRequest; + + /** + * Verifies an AddCatalogAttributeRequest 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 AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddCatalogAttributeRequest; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message AddCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveCatalogAttributeRequest. */ + interface IRemoveCatalogAttributeRequest { + + /** RemoveCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** RemoveCatalogAttributeRequest key */ + key?: (string|null); + } + + /** Represents a RemoveCatalogAttributeRequest. */ + class RemoveCatalogAttributeRequest implements IRemoveCatalogAttributeRequest { + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest); + + /** RemoveCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** RemoveCatalogAttributeRequest key. */ + public key: string; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest): google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveCatalogAttributeRequest.verify|verify} messages. + * @param message RemoveCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveCatalogAttributeRequest + * @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.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + + /** + * Verifies a RemoveCatalogAttributeRequest 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 RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveCatalogAttributeRequest; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message RemoveCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRemoveCatalogAttributesRequest. */ + interface IBatchRemoveCatalogAttributesRequest { + + /** BatchRemoveCatalogAttributesRequest attributesConfig */ + attributesConfig?: (string|null); + + /** BatchRemoveCatalogAttributesRequest attributeKeys */ + attributeKeys?: (string[]|null); + } + + /** Represents a BatchRemoveCatalogAttributesRequest. */ + class BatchRemoveCatalogAttributesRequest implements IBatchRemoveCatalogAttributesRequest { + + /** + * Constructs a new BatchRemoveCatalogAttributesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest); + + /** BatchRemoveCatalogAttributesRequest attributesConfig. */ + public attributesConfig: string; + + /** BatchRemoveCatalogAttributesRequest attributeKeys. */ + public attributeKeys: string[]; + + /** + * Creates a new BatchRemoveCatalogAttributesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRemoveCatalogAttributesRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest): google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest; + + /** + * Encodes the specified BatchRemoveCatalogAttributesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest.verify|verify} messages. + * @param message BatchRemoveCatalogAttributesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRemoveCatalogAttributesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest.verify|verify} messages. + * @param message BatchRemoveCatalogAttributesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRemoveCatalogAttributesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRemoveCatalogAttributesRequest + * @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.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest; + + /** + * Decodes a BatchRemoveCatalogAttributesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRemoveCatalogAttributesRequest + * @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.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest; + + /** + * Verifies a BatchRemoveCatalogAttributesRequest 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 BatchRemoveCatalogAttributesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRemoveCatalogAttributesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest; + + /** + * Creates a plain object from a BatchRemoveCatalogAttributesRequest message. Also converts values to other types if specified. + * @param message BatchRemoveCatalogAttributesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRemoveCatalogAttributesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRemoveCatalogAttributesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BatchRemoveCatalogAttributesResponse. */ + interface IBatchRemoveCatalogAttributesResponse { + + /** BatchRemoveCatalogAttributesResponse deletedCatalogAttributes */ + deletedCatalogAttributes?: (string[]|null); + + /** BatchRemoveCatalogAttributesResponse resetCatalogAttributes */ + resetCatalogAttributes?: (string[]|null); + } + + /** Represents a BatchRemoveCatalogAttributesResponse. */ + class BatchRemoveCatalogAttributesResponse implements IBatchRemoveCatalogAttributesResponse { + + /** + * Constructs a new BatchRemoveCatalogAttributesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse); + + /** BatchRemoveCatalogAttributesResponse deletedCatalogAttributes. */ + public deletedCatalogAttributes: string[]; + + /** BatchRemoveCatalogAttributesResponse resetCatalogAttributes. */ + public resetCatalogAttributes: string[]; + + /** + * Creates a new BatchRemoveCatalogAttributesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchRemoveCatalogAttributesResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse): google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse; + + /** + * Encodes the specified BatchRemoveCatalogAttributesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.verify|verify} messages. + * @param message BatchRemoveCatalogAttributesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BatchRemoveCatalogAttributesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.verify|verify} messages. + * @param message BatchRemoveCatalogAttributesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchRemoveCatalogAttributesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BatchRemoveCatalogAttributesResponse + * @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.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse; + + /** + * Decodes a BatchRemoveCatalogAttributesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BatchRemoveCatalogAttributesResponse + * @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.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse; + + /** + * Verifies a BatchRemoveCatalogAttributesResponse 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 BatchRemoveCatalogAttributesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BatchRemoveCatalogAttributesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse; + + /** + * Creates a plain object from a BatchRemoveCatalogAttributesResponse message. Also converts values to other types if specified. + * @param message BatchRemoveCatalogAttributesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BatchRemoveCatalogAttributesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BatchRemoveCatalogAttributesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReplaceCatalogAttributeRequest. */ + interface IReplaceCatalogAttributeRequest { + + /** ReplaceCatalogAttributeRequest attributesConfig */ + attributesConfig?: (string|null); + + /** ReplaceCatalogAttributeRequest catalogAttribute */ + catalogAttribute?: (google.cloud.retail.v2beta.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a ReplaceCatalogAttributeRequest. */ + class ReplaceCatalogAttributeRequest implements IReplaceCatalogAttributeRequest { + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest); + + /** ReplaceCatalogAttributeRequest attributesConfig. */ + public attributesConfig: string; + + /** ReplaceCatalogAttributeRequest catalogAttribute. */ + public catalogAttribute?: (google.cloud.retail.v2beta.ICatalogAttribute|null); + + /** ReplaceCatalogAttributeRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ReplaceCatalogAttributeRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest): google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @param message ReplaceCatalogAttributeRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReplaceCatalogAttributeRequest + * @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.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; + + /** + * Verifies a ReplaceCatalogAttributeRequest 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 ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReplaceCatalogAttributeRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @param message ReplaceCatalogAttributeRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a CompletionService */ + class CompletionService extends $protobuf.rpc.Service { + + /** + * Constructs a new CompletionService 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 CompletionService 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): CompletionService; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CompleteQueryResponse + */ + public completeQuery(request: google.cloud.retail.v2beta.ICompleteQueryRequest, callback: google.cloud.retail.v2beta.CompletionService.CompleteQueryCallback): void; + + /** + * Calls CompleteQuery. + * @param request CompleteQueryRequest message or plain object + * @returns Promise + */ + public completeQuery(request: google.cloud.retail.v2beta.ICompleteQueryRequest): Promise; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importCompletionData(request: google.cloud.retail.v2beta.IImportCompletionDataRequest, callback: google.cloud.retail.v2beta.CompletionService.ImportCompletionDataCallback): void; + + /** + * Calls ImportCompletionData. + * @param request ImportCompletionDataRequest message or plain object + * @returns Promise + */ + public importCompletionData(request: google.cloud.retail.v2beta.IImportCompletionDataRequest): Promise; + } + + namespace CompletionService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CompletionService|completeQuery}. + * @param error Error, if any + * @param [response] CompleteQueryResponse + */ + type CompleteQueryCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.CompleteQueryResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CompletionService|importCompletionData}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportCompletionDataCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CompleteQueryRequest. */ + interface ICompleteQueryRequest { + + /** CompleteQueryRequest catalog */ + catalog?: (string|null); + + /** CompleteQueryRequest query */ + query?: (string|null); + + /** CompleteQueryRequest visitorId */ + visitorId?: (string|null); + + /** CompleteQueryRequest languageCodes */ + languageCodes?: (string[]|null); + + /** CompleteQueryRequest deviceType */ + deviceType?: (string|null); + + /** CompleteQueryRequest dataset */ + dataset?: (string|null); + + /** CompleteQueryRequest maxSuggestions */ + maxSuggestions?: (number|null); + } + + /** Represents a CompleteQueryRequest. */ + class CompleteQueryRequest implements ICompleteQueryRequest { + + /** + * Constructs a new CompleteQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICompleteQueryRequest); + + /** CompleteQueryRequest catalog. */ + public catalog: string; + + /** CompleteQueryRequest query. */ + public query: string; + + /** CompleteQueryRequest visitorId. */ + public visitorId: string; + + /** CompleteQueryRequest languageCodes. */ + public languageCodes: string[]; + + /** CompleteQueryRequest deviceType. */ + public deviceType: string; + + /** CompleteQueryRequest dataset. */ + public dataset: string; + + /** CompleteQueryRequest maxSuggestions. */ + public maxSuggestions: number; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICompleteQueryRequest): google.cloud.retail.v2beta.CompleteQueryRequest; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryRequest.verify|verify} messages. + * @param message CompleteQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICompleteQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryRequest + * @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.cloud.retail.v2beta.CompleteQueryRequest; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryRequest + * @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.cloud.retail.v2beta.CompleteQueryRequest; + + /** + * Verifies a CompleteQueryRequest 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 CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompleteQueryRequest; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @param message CompleteQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompleteQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompleteQueryResponse. */ + interface ICompleteQueryResponse { + + /** CompleteQueryResponse completionResults */ + completionResults?: (google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult[]|null); + + /** CompleteQueryResponse attributionToken */ + attributionToken?: (string|null); + + /** CompleteQueryResponse recentSearchResults */ + recentSearchResults?: (google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult[]|null); + } + + /** Represents a CompleteQueryResponse. */ + class CompleteQueryResponse implements ICompleteQueryResponse { + + /** + * Constructs a new CompleteQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICompleteQueryResponse); + + /** CompleteQueryResponse completionResults. */ + public completionResults: google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult[]; + + /** CompleteQueryResponse attributionToken. */ + public attributionToken: string; + + /** CompleteQueryResponse recentSearchResults. */ + public recentSearchResults: google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult[]; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns CompleteQueryResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICompleteQueryResponse): google.cloud.retail.v2beta.CompleteQueryResponse; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.verify|verify} messages. + * @param message CompleteQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICompleteQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompleteQueryResponse + * @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.cloud.retail.v2beta.CompleteQueryResponse; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompleteQueryResponse + * @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.cloud.retail.v2beta.CompleteQueryResponse; + + /** + * Verifies a CompleteQueryResponse 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 CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompleteQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompleteQueryResponse; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @param message CompleteQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompleteQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompleteQueryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CompleteQueryResponse { + + /** Properties of a CompletionResult. */ + interface ICompletionResult { + + /** CompletionResult suggestion */ + suggestion?: (string|null); + + /** CompletionResult attributes */ + attributes?: ({ [k: string]: google.cloud.retail.v2beta.ICustomAttribute }|null); + } + + /** Represents a CompletionResult. */ + class CompletionResult implements ICompletionResult { + + /** + * Constructs a new CompletionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult); + + /** CompletionResult suggestion. */ + public suggestion: string; + + /** CompletionResult attributes. */ + public attributes: { [k: string]: google.cloud.retail.v2beta.ICustomAttribute }; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns CompletionResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult): google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @param message CompletionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompletionResult + * @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.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompletionResult + * @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.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult; + + /** + * Verifies a CompletionResult 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 CompletionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompletionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @param message CompletionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompletionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompletionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RecentSearchResult. */ + interface IRecentSearchResult { + + /** RecentSearchResult recentSearch */ + recentSearch?: (string|null); + } + + /** Represents a RecentSearchResult. */ + class RecentSearchResult implements IRecentSearchResult { + + /** + * Constructs a new RecentSearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult); + + /** RecentSearchResult recentSearch. */ + public recentSearch: string; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentSearchResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult): google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @param message RecentSearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentSearchResult + * @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.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentSearchResult + * @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.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult; + + /** + * Verifies a RecentSearchResult 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 RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentSearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @param message RecentSearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentSearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RecentSearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a Control. */ + interface IControl { + + /** Control facetSpec */ + facetSpec?: (google.cloud.retail.v2beta.SearchRequest.IFacetSpec|null); + + /** Control rule */ + rule?: (google.cloud.retail.v2beta.IRule|null); + + /** Control name */ + name?: (string|null); + + /** Control displayName */ + displayName?: (string|null); + + /** Control associatedServingConfigIds */ + associatedServingConfigIds?: (string[]|null); + + /** Control solutionTypes */ + solutionTypes?: (google.cloud.retail.v2beta.SolutionType[]|null); + + /** Control searchSolutionUseCase */ + searchSolutionUseCase?: (google.cloud.retail.v2beta.SearchSolutionUseCase[]|null); + } + + /** Represents a Control. */ + class Control implements IControl { + + /** + * Constructs a new Control. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IControl); + + /** Control facetSpec. */ + public facetSpec?: (google.cloud.retail.v2beta.SearchRequest.IFacetSpec|null); + + /** Control rule. */ + public rule?: (google.cloud.retail.v2beta.IRule|null); + + /** Control name. */ + public name: string; + + /** Control displayName. */ + public displayName: string; + + /** Control associatedServingConfigIds. */ + public associatedServingConfigIds: string[]; + + /** Control solutionTypes. */ + public solutionTypes: google.cloud.retail.v2beta.SolutionType[]; + + /** Control searchSolutionUseCase. */ + public searchSolutionUseCase: google.cloud.retail.v2beta.SearchSolutionUseCase[]; + + /** Control control. */ + public control?: ("facetSpec"|"rule"); + + /** + * Creates a new Control instance using the specified properties. + * @param [properties] Properties to set + * @returns Control instance + */ + public static create(properties?: google.cloud.retail.v2beta.IControl): google.cloud.retail.v2beta.Control; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2beta.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Control.verify|verify} messages. + * @param message Control message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IControl, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Control message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Control + * @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.cloud.retail.v2beta.Control; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Control + * @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.cloud.retail.v2beta.Control; + + /** + * Verifies a Control 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 Control message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Control + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Control; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @param message Control + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Control, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Control to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Control + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a SearchService */ + class SearchService extends $protobuf.rpc.Service { + + /** + * Constructs a new SearchService 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 SearchService 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): SearchService; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SearchResponse + */ + public search(request: google.cloud.retail.v2beta.ISearchRequest, callback: google.cloud.retail.v2beta.SearchService.SearchCallback): void; + + /** + * Calls Search. + * @param request SearchRequest message or plain object + * @returns Promise + */ + public search(request: google.cloud.retail.v2beta.ISearchRequest): Promise; + } + + namespace SearchService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.SearchService|search}. + * @param error Error, if any + * @param [response] SearchResponse + */ + type SearchCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.SearchResponse) => void; + } + + /** Properties of a SearchRequest. */ + interface ISearchRequest { + + /** SearchRequest placement */ + placement?: (string|null); + + /** SearchRequest branch */ + branch?: (string|null); + + /** SearchRequest query */ + query?: (string|null); + + /** SearchRequest visitorId */ + visitorId?: (string|null); + + /** SearchRequest userInfo */ + userInfo?: (google.cloud.retail.v2beta.IUserInfo|null); + + /** SearchRequest pageSize */ + pageSize?: (number|null); + + /** SearchRequest pageToken */ + pageToken?: (string|null); + + /** SearchRequest offset */ + offset?: (number|null); + + /** SearchRequest filter */ + filter?: (string|null); + + /** SearchRequest canonicalFilter */ + canonicalFilter?: (string|null); + + /** SearchRequest orderBy */ + orderBy?: (string|null); + + /** SearchRequest facetSpecs */ + facetSpecs?: (google.cloud.retail.v2beta.SearchRequest.IFacetSpec[]|null); + + /** SearchRequest dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec */ + boostSpec?: (google.cloud.retail.v2beta.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec */ + queryExpansionSpec?: (google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest variantRollupKeys */ + variantRollupKeys?: (string[]|null); + + /** SearchRequest pageCategories */ + pageCategories?: (string[]|null); + + /** SearchRequest searchMode */ + searchMode?: (google.cloud.retail.v2beta.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2beta.SearchRequest.SearchMode|null); + + /** SearchRequest personalizationSpec */ + personalizationSpec?: (google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** SearchRequest spellCorrectionSpec */ + spellCorrectionSpec?: (google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec|null); + } + + /** Represents a SearchRequest. */ + class SearchRequest implements ISearchRequest { + + /** + * Constructs a new SearchRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISearchRequest); + + /** SearchRequest placement. */ + public placement: string; + + /** SearchRequest branch. */ + public branch: string; + + /** SearchRequest query. */ + public query: string; + + /** SearchRequest visitorId. */ + public visitorId: string; + + /** SearchRequest userInfo. */ + public userInfo?: (google.cloud.retail.v2beta.IUserInfo|null); + + /** SearchRequest pageSize. */ + public pageSize: number; + + /** SearchRequest pageToken. */ + public pageToken: string; + + /** SearchRequest offset. */ + public offset: number; + + /** SearchRequest filter. */ + public filter: string; + + /** SearchRequest canonicalFilter. */ + public canonicalFilter: string; + + /** SearchRequest orderBy. */ + public orderBy: string; + + /** SearchRequest facetSpecs. */ + public facetSpecs: google.cloud.retail.v2beta.SearchRequest.IFacetSpec[]; + + /** SearchRequest dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null); + + /** SearchRequest boostSpec. */ + public boostSpec?: (google.cloud.retail.v2beta.SearchRequest.IBoostSpec|null); + + /** SearchRequest queryExpansionSpec. */ + public queryExpansionSpec?: (google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec|null); + + /** SearchRequest variantRollupKeys. */ + public variantRollupKeys: string[]; + + /** SearchRequest pageCategories. */ + public pageCategories: string[]; + + /** SearchRequest searchMode. */ + public searchMode: (google.cloud.retail.v2beta.SearchRequest.SearchMode|keyof typeof google.cloud.retail.v2beta.SearchRequest.SearchMode); + + /** SearchRequest personalizationSpec. */ + public personalizationSpec?: (google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null); + + /** SearchRequest labels. */ + public labels: { [k: string]: string }; + + /** SearchRequest spellCorrectionSpec. */ + public spellCorrectionSpec?: (google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec|null); + + /** SearchRequest _spellCorrectionSpec. */ + public _spellCorrectionSpec?: "spellCorrectionSpec"; + + /** + * Creates a new SearchRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISearchRequest): google.cloud.retail.v2beta.SearchRequest; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.verify|verify} messages. + * @param message SearchRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISearchRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchRequest + * @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.cloud.retail.v2beta.SearchRequest; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchRequest + * @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.cloud.retail.v2beta.SearchRequest; + + /** + * Verifies a SearchRequest 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 SearchRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @param message SearchRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchRequest { + + /** Properties of a FacetSpec. */ + interface IFacetSpec { + + /** FacetSpec facetKey */ + facetKey?: (google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit */ + limit?: (number|null); + + /** FacetSpec excludedFilterKeys */ + excludedFilterKeys?: (string[]|null); + + /** FacetSpec enableDynamicPosition */ + enableDynamicPosition?: (boolean|null); + } + + /** Represents a FacetSpec. */ + class FacetSpec implements IFacetSpec { + + /** + * Constructs a new FacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.IFacetSpec); + + /** FacetSpec facetKey. */ + public facetKey?: (google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey|null); + + /** FacetSpec limit. */ + public limit: number; + + /** FacetSpec excludedFilterKeys. */ + public excludedFilterKeys: string[]; + + /** FacetSpec enableDynamicPosition. */ + public enableDynamicPosition: boolean; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.IFacetSpec): google.cloud.retail.v2beta.SearchRequest.FacetSpec; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify|verify} messages. + * @param message FacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.IFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetSpec + * @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.cloud.retail.v2beta.SearchRequest.FacetSpec; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetSpec + * @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.cloud.retail.v2beta.SearchRequest.FacetSpec; + + /** + * Verifies a FacetSpec 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 FacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.FacetSpec; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @param message FacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.FacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FacetSpec { + + /** Properties of a FacetKey. */ + interface IFacetKey { + + /** FacetKey key */ + key?: (string|null); + + /** FacetKey intervals */ + intervals?: (google.cloud.retail.v2beta.IInterval[]|null); + + /** FacetKey restrictedValues */ + restrictedValues?: (string[]|null); + + /** FacetKey prefixes */ + prefixes?: (string[]|null); + + /** FacetKey contains */ + contains?: (string[]|null); + + /** FacetKey caseInsensitive */ + caseInsensitive?: (boolean|null); + + /** FacetKey orderBy */ + orderBy?: (string|null); + + /** FacetKey query */ + query?: (string|null); + + /** FacetKey returnMinMax */ + returnMinMax?: (boolean|null); + } + + /** Represents a FacetKey. */ + class FacetKey implements IFacetKey { + + /** + * Constructs a new FacetKey. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey); + + /** FacetKey key. */ + public key: string; + + /** FacetKey intervals. */ + public intervals: google.cloud.retail.v2beta.IInterval[]; + + /** FacetKey restrictedValues. */ + public restrictedValues: string[]; + + /** FacetKey prefixes. */ + public prefixes: string[]; + + /** FacetKey contains. */ + public contains: string[]; + + /** FacetKey caseInsensitive. */ + public caseInsensitive: boolean; + + /** FacetKey orderBy. */ + public orderBy: string; + + /** FacetKey query. */ + public query: string; + + /** FacetKey returnMinMax. */ + public returnMinMax: boolean; + + /** + * Creates a new FacetKey instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetKey instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey): google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @param message FacetKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetKey + * @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.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetKey + * @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.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey; + + /** + * Verifies a FacetKey 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 FacetKey message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetKey + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @param message FacetKey + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetKey to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetKey + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a DynamicFacetSpec. */ + interface IDynamicFacetSpec { + + /** DynamicFacetSpec mode */ + mode?: (google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode|null); + } + + /** Represents a DynamicFacetSpec. */ + class DynamicFacetSpec implements IDynamicFacetSpec { + + /** + * Constructs a new DynamicFacetSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec); + + /** DynamicFacetSpec mode. */ + public mode: (google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode); + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns DynamicFacetSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec): google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @param message DynamicFacetSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DynamicFacetSpec + * @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.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DynamicFacetSpec + * @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.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec; + + /** + * Verifies a DynamicFacetSpec 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 DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DynamicFacetSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @param message DynamicFacetSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DynamicFacetSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DynamicFacetSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + DISABLED = 1, + ENABLED = 2 + } + } + + /** Properties of a BoostSpec. */ + interface IBoostSpec { + + /** BoostSpec conditionBoostSpecs */ + conditionBoostSpecs?: (google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + + /** BoostSpec skipBoostSpecValidation */ + skipBoostSpecValidation?: (boolean|null); + } + + /** Represents a BoostSpec. */ + class BoostSpec implements IBoostSpec { + + /** + * Constructs a new BoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.IBoostSpec); + + /** BoostSpec conditionBoostSpecs. */ + public conditionBoostSpecs: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** BoostSpec skipBoostSpecValidation. */ + public skipBoostSpecValidation?: (boolean|null); + + /** BoostSpec _skipBoostSpecValidation. */ + public _skipBoostSpecValidation?: "skipBoostSpecValidation"; + + /** + * Creates a new BoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns BoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.IBoostSpec): google.cloud.retail.v2beta.SearchRequest.BoostSpec; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.verify|verify} messages. + * @param message BoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.IBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoostSpec + * @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.cloud.retail.v2beta.SearchRequest.BoostSpec; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoostSpec + * @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.cloud.retail.v2beta.SearchRequest.BoostSpec; + + /** + * Verifies a BoostSpec 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 BoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.BoostSpec; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @param message BoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.BoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace BoostSpec { + + /** Properties of a ConditionBoostSpec. */ + interface IConditionBoostSpec { + + /** ConditionBoostSpec condition */ + condition?: (string|null); + + /** ConditionBoostSpec boost */ + boost?: (number|null); + } + + /** Represents a ConditionBoostSpec. */ + class ConditionBoostSpec implements IConditionBoostSpec { + + /** + * Constructs a new ConditionBoostSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec); + + /** ConditionBoostSpec condition. */ + public condition: string; + + /** ConditionBoostSpec boost. */ + public boost: number; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns ConditionBoostSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec): google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @param message ConditionBoostSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ConditionBoostSpec + * @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.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ConditionBoostSpec + * @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.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Verifies a ConditionBoostSpec 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 ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ConditionBoostSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @param message ConditionBoostSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ConditionBoostSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionSpec. */ + interface IQueryExpansionSpec { + + /** QueryExpansionSpec condition */ + condition?: (google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition|null); + + /** QueryExpansionSpec pinUnexpandedResults */ + pinUnexpandedResults?: (boolean|null); + } + + /** Represents a QueryExpansionSpec. */ + class QueryExpansionSpec implements IQueryExpansionSpec { + + /** + * Constructs a new QueryExpansionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec); + + /** QueryExpansionSpec condition. */ + public condition: (google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition|keyof typeof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition); + + /** QueryExpansionSpec pinUnexpandedResults. */ + public pinUnexpandedResults: boolean; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec): google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @param message QueryExpansionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionSpec + * @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.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionSpec + * @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.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec; + + /** + * Verifies a QueryExpansionSpec 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 QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @param message QueryExpansionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace QueryExpansionSpec { + + /** Condition enum. */ + enum Condition { + CONDITION_UNSPECIFIED = 0, + DISABLED = 1, + AUTO = 3 + } + } + + /** Properties of a PersonalizationSpec. */ + interface IPersonalizationSpec { + + /** PersonalizationSpec mode */ + mode?: (google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode|null); + } + + /** Represents a PersonalizationSpec. */ + class PersonalizationSpec implements IPersonalizationSpec { + + /** + * Constructs a new PersonalizationSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec); + + /** PersonalizationSpec mode. */ + public mode: (google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode); + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns PersonalizationSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec): google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @param message PersonalizationSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PersonalizationSpec + * @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.cloud.retail.v2beta.SearchRequest.PersonalizationSpec; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PersonalizationSpec + * @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.cloud.retail.v2beta.SearchRequest.PersonalizationSpec; + + /** + * Verifies a PersonalizationSpec 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 PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PersonalizationSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @param message PersonalizationSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PersonalizationSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PersonalizationSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PersonalizationSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + AUTO = 1, + DISABLED = 2 + } + } + + /** Properties of a SpellCorrectionSpec. */ + interface ISpellCorrectionSpec { + + /** SpellCorrectionSpec mode */ + mode?: (google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode|null); + } + + /** Represents a SpellCorrectionSpec. */ + class SpellCorrectionSpec implements ISpellCorrectionSpec { + + /** + * Constructs a new SpellCorrectionSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec); + + /** SpellCorrectionSpec mode. */ + public mode: (google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode|keyof typeof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode); + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns SpellCorrectionSpec instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec): google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @param message SpellCorrectionSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpellCorrectionSpec + * @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.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec; + + /** + * Verifies a SpellCorrectionSpec 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 SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpellCorrectionSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @param message SpellCorrectionSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SpellCorrectionSpec { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + SUGGESTION_ONLY = 1, + AUTO = 2 + } + } + + /** SearchMode enum. */ + enum SearchMode { + SEARCH_MODE_UNSPECIFIED = 0, + PRODUCT_SEARCH_ONLY = 1, + FACETED_SEARCH_ONLY = 2 + } + } + + /** Properties of a SearchResponse. */ + interface ISearchResponse { + + /** SearchResponse results */ + results?: (google.cloud.retail.v2beta.SearchResponse.ISearchResult[]|null); + + /** SearchResponse facets */ + facets?: (google.cloud.retail.v2beta.SearchResponse.IFacet[]|null); + + /** SearchResponse totalSize */ + totalSize?: (number|null); + + /** SearchResponse correctedQuery */ + correctedQuery?: (string|null); + + /** SearchResponse attributionToken */ + attributionToken?: (string|null); + + /** SearchResponse nextPageToken */ + nextPageToken?: (string|null); + + /** SearchResponse queryExpansionInfo */ + queryExpansionInfo?: (google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri */ + redirectUri?: (string|null); + + /** SearchResponse appliedControls */ + appliedControls?: (string[]|null); + + /** SearchResponse invalidConditionBoostSpecs */ + invalidConditionBoostSpecs?: (google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec[]|null); + } + + /** Represents a SearchResponse. */ + class SearchResponse implements ISearchResponse { + + /** + * Constructs a new SearchResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISearchResponse); + + /** SearchResponse results. */ + public results: google.cloud.retail.v2beta.SearchResponse.ISearchResult[]; + + /** SearchResponse facets. */ + public facets: google.cloud.retail.v2beta.SearchResponse.IFacet[]; + + /** SearchResponse totalSize. */ + public totalSize: number; + + /** SearchResponse correctedQuery. */ + public correctedQuery: string; + + /** SearchResponse attributionToken. */ + public attributionToken: string; + + /** SearchResponse nextPageToken. */ + public nextPageToken: string; + + /** SearchResponse queryExpansionInfo. */ + public queryExpansionInfo?: (google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo|null); + + /** SearchResponse redirectUri. */ + public redirectUri: string; + + /** SearchResponse appliedControls. */ + public appliedControls: string[]; + + /** SearchResponse invalidConditionBoostSpecs. */ + public invalidConditionBoostSpecs: google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec[]; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISearchResponse): google.cloud.retail.v2beta.SearchResponse; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.verify|verify} messages. + * @param message SearchResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISearchResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResponse + * @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.cloud.retail.v2beta.SearchResponse; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResponse + * @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.cloud.retail.v2beta.SearchResponse; + + /** + * Verifies a SearchResponse 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 SearchResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchResponse; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @param message SearchResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SearchResponse { + + /** Properties of a SearchResult. */ + interface ISearchResult { + + /** SearchResult id */ + id?: (string|null); + + /** SearchResult product */ + product?: (google.cloud.retail.v2beta.IProduct|null); + + /** SearchResult matchingVariantCount */ + matchingVariantCount?: (number|null); + + /** SearchResult matchingVariantFields */ + matchingVariantFields?: ({ [k: string]: google.protobuf.IFieldMask }|null); + + /** SearchResult variantRollupValues */ + variantRollupValues?: ({ [k: string]: google.protobuf.IValue }|null); + + /** SearchResult personalLabels */ + personalLabels?: (string[]|null); + } + + /** Represents a SearchResult. */ + class SearchResult implements ISearchResult { + + /** + * Constructs a new SearchResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchResponse.ISearchResult); + + /** SearchResult id. */ + public id: string; + + /** SearchResult product. */ + public product?: (google.cloud.retail.v2beta.IProduct|null); + + /** SearchResult matchingVariantCount. */ + public matchingVariantCount: number; + + /** SearchResult matchingVariantFields. */ + public matchingVariantFields: { [k: string]: google.protobuf.IFieldMask }; + + /** SearchResult variantRollupValues. */ + public variantRollupValues: { [k: string]: google.protobuf.IValue }; + + /** SearchResult personalLabels. */ + public personalLabels: string[]; + + /** + * Creates a new SearchResult instance using the specified properties. + * @param [properties] Properties to set + * @returns SearchResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchResponse.ISearchResult): google.cloud.retail.v2beta.SearchResponse.SearchResult; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.SearchResult.verify|verify} messages. + * @param message SearchResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchResponse.ISearchResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SearchResult + * @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.cloud.retail.v2beta.SearchResponse.SearchResult; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SearchResult + * @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.cloud.retail.v2beta.SearchResponse.SearchResult; + + /** + * Verifies a SearchResult 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 SearchResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SearchResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchResponse.SearchResult; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @param message SearchResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchResponse.SearchResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SearchResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SearchResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Facet. */ + interface IFacet { + + /** Facet key */ + key?: (string|null); + + /** Facet values */ + values?: (google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue[]|null); + + /** Facet dynamicFacet */ + dynamicFacet?: (boolean|null); + } + + /** Represents a Facet. */ + class Facet implements IFacet { + + /** + * Constructs a new Facet. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchResponse.IFacet); + + /** Facet key. */ + public key: string; + + /** Facet values. */ + public values: google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue[]; + + /** Facet dynamicFacet. */ + public dynamicFacet: boolean; + + /** + * Creates a new Facet instance using the specified properties. + * @param [properties] Properties to set + * @returns Facet instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchResponse.IFacet): google.cloud.retail.v2beta.SearchResponse.Facet; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.verify|verify} messages. + * @param message Facet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchResponse.IFacet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Facet + * @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.cloud.retail.v2beta.SearchResponse.Facet; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Facet + * @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.cloud.retail.v2beta.SearchResponse.Facet; + + /** + * Verifies a Facet 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 Facet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Facet + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchResponse.Facet; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @param message Facet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchResponse.Facet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Facet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Facet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Facet { + + /** Properties of a FacetValue. */ + interface IFacetValue { + + /** FacetValue value */ + value?: (string|null); + + /** FacetValue interval */ + interval?: (google.cloud.retail.v2beta.IInterval|null); + + /** FacetValue count */ + count?: (number|Long|string|null); + + /** FacetValue minValue */ + minValue?: (number|null); + + /** FacetValue maxValue */ + maxValue?: (number|null); + } + + /** Represents a FacetValue. */ + class FacetValue implements IFacetValue { + + /** + * Constructs a new FacetValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue); + + /** FacetValue value. */ + public value?: (string|null); + + /** FacetValue interval. */ + public interval?: (google.cloud.retail.v2beta.IInterval|null); + + /** FacetValue count. */ + public count: (number|Long|string); + + /** FacetValue minValue. */ + public minValue: number; + + /** FacetValue maxValue. */ + public maxValue: number; + + /** FacetValue facetValue. */ + public facetValue?: ("value"|"interval"); + + /** + * Creates a new FacetValue instance using the specified properties. + * @param [properties] Properties to set + * @returns FacetValue instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue): google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @param message FacetValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FacetValue + * @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.cloud.retail.v2beta.SearchResponse.Facet.FacetValue; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FacetValue + * @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.cloud.retail.v2beta.SearchResponse.Facet.FacetValue; + + /** + * Verifies a FacetValue 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 FacetValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FacetValue + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @param message FacetValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FacetValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FacetValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a QueryExpansionInfo. */ + interface IQueryExpansionInfo { + + /** QueryExpansionInfo expandedQuery */ + expandedQuery?: (boolean|null); + + /** QueryExpansionInfo pinnedResultCount */ + pinnedResultCount?: (number|Long|string|null); + } + + /** Represents a QueryExpansionInfo. */ + class QueryExpansionInfo implements IQueryExpansionInfo { + + /** + * Constructs a new QueryExpansionInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo); + + /** QueryExpansionInfo expandedQuery. */ + public expandedQuery: boolean; + + /** QueryExpansionInfo pinnedResultCount. */ + public pinnedResultCount: (number|Long|string); + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryExpansionInfo instance + */ + public static create(properties?: google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo): google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @param message QueryExpansionInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryExpansionInfo + * @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.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryExpansionInfo + * @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.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo; + + /** + * Verifies a QueryExpansionInfo 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 QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryExpansionInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @param message QueryExpansionInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryExpansionInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Represents a ControlService */ + class ControlService extends $protobuf.rpc.Service { + + /** + * Constructs a new ControlService 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 ControlService 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): ControlService; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public createControl(request: google.cloud.retail.v2beta.ICreateControlRequest, callback: google.cloud.retail.v2beta.ControlService.CreateControlCallback): void; + + /** + * Calls CreateControl. + * @param request CreateControlRequest message or plain object + * @returns Promise + */ + public createControl(request: google.cloud.retail.v2beta.ICreateControlRequest): Promise; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteControl(request: google.cloud.retail.v2beta.IDeleteControlRequest, callback: google.cloud.retail.v2beta.ControlService.DeleteControlCallback): void; + + /** + * Calls DeleteControl. + * @param request DeleteControlRequest message or plain object + * @returns Promise + */ + public deleteControl(request: google.cloud.retail.v2beta.IDeleteControlRequest): Promise; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public updateControl(request: google.cloud.retail.v2beta.IUpdateControlRequest, callback: google.cloud.retail.v2beta.ControlService.UpdateControlCallback): void; + + /** + * Calls UpdateControl. + * @param request UpdateControlRequest message or plain object + * @returns Promise + */ + public updateControl(request: google.cloud.retail.v2beta.IUpdateControlRequest): Promise; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Control + */ + public getControl(request: google.cloud.retail.v2beta.IGetControlRequest, callback: google.cloud.retail.v2beta.ControlService.GetControlCallback): void; + + /** + * Calls GetControl. + * @param request GetControlRequest message or plain object + * @returns Promise + */ + public getControl(request: google.cloud.retail.v2beta.IGetControlRequest): Promise; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListControlsResponse + */ + public listControls(request: google.cloud.retail.v2beta.IListControlsRequest, callback: google.cloud.retail.v2beta.ControlService.ListControlsCallback): void; + + /** + * Calls ListControls. + * @param request ListControlsRequest message or plain object + * @returns Promise + */ + public listControls(request: google.cloud.retail.v2beta.IListControlsRequest): Promise; + } + + namespace ControlService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|createControl}. + * @param error Error, if any + * @param [response] Control + */ + type CreateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|deleteControl}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteControlCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|updateControl}. + * @param error Error, if any + * @param [response] Control + */ + type UpdateControlCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|getControl}. + * @param error Error, if any + * @param [response] Control + */ + type GetControlCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Control) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|listControls}. + * @param error Error, if any + * @param [response] ListControlsResponse + */ + type ListControlsCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ListControlsResponse) => void; + } + + /** Properties of a CreateControlRequest. */ + interface ICreateControlRequest { + + /** CreateControlRequest parent */ + parent?: (string|null); + + /** CreateControlRequest control */ + control?: (google.cloud.retail.v2beta.IControl|null); + + /** CreateControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a CreateControlRequest. */ + class CreateControlRequest implements ICreateControlRequest { + + /** + * Constructs a new CreateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICreateControlRequest); + + /** CreateControlRequest parent. */ + public parent: string; + + /** CreateControlRequest control. */ + public control?: (google.cloud.retail.v2beta.IControl|null); + + /** CreateControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICreateControlRequest): google.cloud.retail.v2beta.CreateControlRequest; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateControlRequest.verify|verify} messages. + * @param message CreateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICreateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateControlRequest + * @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.cloud.retail.v2beta.CreateControlRequest; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateControlRequest + * @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.cloud.retail.v2beta.CreateControlRequest; + + /** + * Verifies a CreateControlRequest 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 CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CreateControlRequest; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @param message CreateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CreateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateControlRequest. */ + interface IUpdateControlRequest { + + /** UpdateControlRequest control */ + control?: (google.cloud.retail.v2beta.IControl|null); + + /** UpdateControlRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateControlRequest. */ + class UpdateControlRequest implements IUpdateControlRequest { + + /** + * Constructs a new UpdateControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateControlRequest); + + /** UpdateControlRequest control. */ + public control?: (google.cloud.retail.v2beta.IControl|null); + + /** UpdateControlRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateControlRequest): google.cloud.retail.v2beta.UpdateControlRequest; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateControlRequest.verify|verify} messages. + * @param message UpdateControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateControlRequest + * @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.cloud.retail.v2beta.UpdateControlRequest; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateControlRequest + * @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.cloud.retail.v2beta.UpdateControlRequest; + + /** + * Verifies an UpdateControlRequest 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 UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateControlRequest; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @param message UpdateControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteControlRequest. */ + interface IDeleteControlRequest { + + /** DeleteControlRequest name */ + name?: (string|null); + } + + /** Represents a DeleteControlRequest. */ + class DeleteControlRequest implements IDeleteControlRequest { + + /** + * Constructs a new DeleteControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IDeleteControlRequest); + + /** DeleteControlRequest name. */ + public name: string; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IDeleteControlRequest): google.cloud.retail.v2beta.DeleteControlRequest; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteControlRequest.verify|verify} messages. + * @param message DeleteControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IDeleteControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteControlRequest + * @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.cloud.retail.v2beta.DeleteControlRequest; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteControlRequest + * @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.cloud.retail.v2beta.DeleteControlRequest; + + /** + * Verifies a DeleteControlRequest 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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.DeleteControlRequest; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @param message DeleteControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.DeleteControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetControlRequest. */ + interface IGetControlRequest { + + /** GetControlRequest name */ + name?: (string|null); + } + + /** Represents a GetControlRequest. */ + class GetControlRequest implements IGetControlRequest { + + /** + * Constructs a new GetControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetControlRequest); + + /** GetControlRequest name. */ + public name: string; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetControlRequest): google.cloud.retail.v2beta.GetControlRequest; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetControlRequest.verify|verify} messages. + * @param message GetControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetControlRequest + * @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.cloud.retail.v2beta.GetControlRequest; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetControlRequest + * @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.cloud.retail.v2beta.GetControlRequest; + + /** + * Verifies a GetControlRequest 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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetControlRequest; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @param message GetControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsRequest. */ + interface IListControlsRequest { + + /** ListControlsRequest parent */ + parent?: (string|null); + + /** ListControlsRequest pageSize */ + pageSize?: (number|null); + + /** ListControlsRequest pageToken */ + pageToken?: (string|null); + + /** ListControlsRequest filter */ + filter?: (string|null); + } + + /** Represents a ListControlsRequest. */ + class ListControlsRequest implements IListControlsRequest { + + /** + * Constructs a new ListControlsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListControlsRequest); + + /** ListControlsRequest parent. */ + public parent: string; + + /** ListControlsRequest pageSize. */ + public pageSize: number; + + /** ListControlsRequest pageToken. */ + public pageToken: string; + + /** ListControlsRequest filter. */ + public filter: string; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListControlsRequest): google.cloud.retail.v2beta.ListControlsRequest; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsRequest.verify|verify} messages. + * @param message ListControlsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListControlsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsRequest + * @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.cloud.retail.v2beta.ListControlsRequest; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsRequest + * @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.cloud.retail.v2beta.ListControlsRequest; + + /** + * Verifies a ListControlsRequest 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 ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListControlsRequest; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @param message ListControlsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListControlsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListControlsResponse. */ + interface IListControlsResponse { + + /** ListControlsResponse controls */ + controls?: (google.cloud.retail.v2beta.IControl[]|null); + + /** ListControlsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListControlsResponse. */ + class ListControlsResponse implements IListControlsResponse { + + /** + * Constructs a new ListControlsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListControlsResponse); + + /** ListControlsResponse controls. */ + public controls: google.cloud.retail.v2beta.IControl[]; + + /** ListControlsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListControlsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListControlsResponse): google.cloud.retail.v2beta.ListControlsResponse; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsResponse.verify|verify} messages. + * @param message ListControlsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListControlsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListControlsResponse + * @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.cloud.retail.v2beta.ListControlsResponse; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListControlsResponse + * @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.cloud.retail.v2beta.ListControlsResponse; + + /** + * Verifies a ListControlsResponse 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 ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListControlsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListControlsResponse; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @param message ListControlsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListControlsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListControlsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListControlsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportErrorsConfig. */ + interface IExportErrorsConfig { + + /** ExportErrorsConfig gcsPrefix */ + gcsPrefix?: (string|null); + } + + /** Represents an ExportErrorsConfig. */ + class ExportErrorsConfig implements IExportErrorsConfig { + + /** + * Constructs a new ExportErrorsConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IExportErrorsConfig); + + /** ExportErrorsConfig gcsPrefix. */ + public gcsPrefix?: (string|null); + + /** ExportErrorsConfig destination. */ + public destination?: "gcsPrefix"; + + /** + * Creates a new ExportErrorsConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportErrorsConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IExportErrorsConfig): google.cloud.retail.v2beta.ExportErrorsConfig; + + /** + * Encodes the specified ExportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ExportErrorsConfig.verify|verify} messages. + * @param message ExportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IExportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportErrorsConfig.verify|verify} messages. + * @param message ExportErrorsConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IExportErrorsConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportErrorsConfig + * @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.cloud.retail.v2beta.ExportErrorsConfig; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportErrorsConfig + * @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.cloud.retail.v2beta.ExportErrorsConfig; + + /** + * Verifies an ExportErrorsConfig 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 ExportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportErrorsConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ExportErrorsConfig; + + /** + * Creates a plain object from an ExportErrorsConfig message. Also converts values to other types if specified. + * @param message ExportErrorsConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ExportErrorsConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportErrorsConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportErrorsConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportMetadata. */ + interface IExportMetadata { + + /** ExportMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ExportMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents an ExportMetadata. */ + class ExportMetadata implements IExportMetadata { + + /** + * Constructs a new ExportMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IExportMetadata); + + /** ExportMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ExportMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new ExportMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IExportMetadata): google.cloud.retail.v2beta.ExportMetadata; + + /** + * Encodes the specified ExportMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.ExportMetadata.verify|verify} messages. + * @param message ExportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IExportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportMetadata.verify|verify} messages. + * @param message ExportMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IExportMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportMetadata + * @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.cloud.retail.v2beta.ExportMetadata; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportMetadata + * @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.cloud.retail.v2beta.ExportMetadata; + + /** + * Verifies an ExportMetadata 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 ExportMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ExportMetadata; + + /** + * Creates a plain object from an ExportMetadata message. Also converts values to other types if specified. + * @param message ExportMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ExportMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportProductsResponse. */ + interface IExportProductsResponse { + + /** ExportProductsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ExportProductsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IExportErrorsConfig|null); + + /** ExportProductsResponse outputResult */ + outputResult?: (google.cloud.retail.v2beta.IOutputResult|null); + } + + /** Represents an ExportProductsResponse. */ + class ExportProductsResponse implements IExportProductsResponse { + + /** + * Constructs a new ExportProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IExportProductsResponse); + + /** ExportProductsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ExportProductsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IExportErrorsConfig|null); + + /** ExportProductsResponse outputResult. */ + public outputResult?: (google.cloud.retail.v2beta.IOutputResult|null); + + /** + * Creates a new ExportProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IExportProductsResponse): google.cloud.retail.v2beta.ExportProductsResponse; + + /** + * Encodes the specified ExportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ExportProductsResponse.verify|verify} messages. + * @param message ExportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IExportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportProductsResponse.verify|verify} messages. + * @param message ExportProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IExportProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportProductsResponse + * @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.cloud.retail.v2beta.ExportProductsResponse; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportProductsResponse + * @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.cloud.retail.v2beta.ExportProductsResponse; + + /** + * Verifies an ExportProductsResponse 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 ExportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ExportProductsResponse; + + /** + * Creates a plain object from an ExportProductsResponse message. Also converts values to other types if specified. + * @param message ExportProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ExportProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportUserEventsResponse. */ + interface IExportUserEventsResponse { + + /** ExportUserEventsResponse errorSamples */ + errorSamples?: (google.rpc.IStatus[]|null); + + /** ExportUserEventsResponse errorsConfig */ + errorsConfig?: (google.cloud.retail.v2beta.IExportErrorsConfig|null); + + /** ExportUserEventsResponse outputResult */ + outputResult?: (google.cloud.retail.v2beta.IOutputResult|null); + } + + /** Represents an ExportUserEventsResponse. */ + class ExportUserEventsResponse implements IExportUserEventsResponse { + + /** + * Constructs a new ExportUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IExportUserEventsResponse); + + /** ExportUserEventsResponse errorSamples. */ + public errorSamples: google.rpc.IStatus[]; + + /** ExportUserEventsResponse errorsConfig. */ + public errorsConfig?: (google.cloud.retail.v2beta.IExportErrorsConfig|null); + + /** ExportUserEventsResponse outputResult. */ + public outputResult?: (google.cloud.retail.v2beta.IOutputResult|null); + + /** + * Creates a new ExportUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IExportUserEventsResponse): google.cloud.retail.v2beta.ExportUserEventsResponse; + + /** + * Encodes the specified ExportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ExportUserEventsResponse.verify|verify} messages. + * @param message ExportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IExportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportUserEventsResponse.verify|verify} messages. + * @param message ExportUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IExportUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportUserEventsResponse + * @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.cloud.retail.v2beta.ExportUserEventsResponse; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportUserEventsResponse + * @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.cloud.retail.v2beta.ExportUserEventsResponse; + + /** + * Verifies an ExportUserEventsResponse 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 ExportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ExportUserEventsResponse; + + /** + * Creates a plain object from an ExportUserEventsResponse message. Also converts values to other types if specified. + * @param message ExportUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ExportUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OutputResult. */ + interface IOutputResult { + + /** OutputResult bigqueryResult */ + bigqueryResult?: (google.cloud.retail.v2beta.IBigQueryOutputResult[]|null); + } + + /** Represents an OutputResult. */ + class OutputResult implements IOutputResult { + + /** + * Constructs a new OutputResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IOutputResult); + + /** OutputResult bigqueryResult. */ + public bigqueryResult: google.cloud.retail.v2beta.IBigQueryOutputResult[]; + + /** + * Creates a new OutputResult instance using the specified properties. + * @param [properties] Properties to set + * @returns OutputResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.IOutputResult): google.cloud.retail.v2beta.OutputResult; + + /** + * Encodes the specified OutputResult message. Does not implicitly {@link google.cloud.retail.v2beta.OutputResult.verify|verify} messages. + * @param message OutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.OutputResult.verify|verify} messages. + * @param message OutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OutputResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OutputResult + * @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.cloud.retail.v2beta.OutputResult; + + /** + * Decodes an OutputResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OutputResult + * @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.cloud.retail.v2beta.OutputResult; + + /** + * Verifies an OutputResult 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 OutputResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OutputResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.OutputResult; + + /** + * Creates a plain object from an OutputResult message. Also converts values to other types if specified. + * @param message OutputResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.OutputResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OutputResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OutputResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BigQueryOutputResult. */ + interface IBigQueryOutputResult { + + /** BigQueryOutputResult datasetId */ + datasetId?: (string|null); + + /** BigQueryOutputResult tableId */ + tableId?: (string|null); + } + + /** Represents a BigQueryOutputResult. */ + class BigQueryOutputResult implements IBigQueryOutputResult { + + /** + * Constructs a new BigQueryOutputResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IBigQueryOutputResult); + + /** BigQueryOutputResult datasetId. */ + public datasetId: string; + + /** BigQueryOutputResult tableId. */ + public tableId: string; + + /** + * Creates a new BigQueryOutputResult instance using the specified properties. + * @param [properties] Properties to set + * @returns BigQueryOutputResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.IBigQueryOutputResult): google.cloud.retail.v2beta.BigQueryOutputResult; + + /** + * Encodes the specified BigQueryOutputResult message. Does not implicitly {@link google.cloud.retail.v2beta.BigQueryOutputResult.verify|verify} messages. + * @param message BigQueryOutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IBigQueryOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BigQueryOutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BigQueryOutputResult.verify|verify} messages. + * @param message BigQueryOutputResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IBigQueryOutputResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BigQueryOutputResult + * @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.cloud.retail.v2beta.BigQueryOutputResult; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BigQueryOutputResult + * @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.cloud.retail.v2beta.BigQueryOutputResult; + + /** + * Verifies a BigQueryOutputResult 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 BigQueryOutputResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BigQueryOutputResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.BigQueryOutputResult; + + /** + * Creates a plain object from a BigQueryOutputResult message. Also converts values to other types if specified. + * @param message BigQueryOutputResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.BigQueryOutputResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BigQueryOutputResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BigQueryOutputResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Model. */ + interface IModel { + + /** Model name */ + name?: (string|null); + + /** Model displayName */ + displayName?: (string|null); + + /** Model trainingState */ + trainingState?: (google.cloud.retail.v2beta.Model.TrainingState|keyof typeof google.cloud.retail.v2beta.Model.TrainingState|null); + + /** Model servingState */ + servingState?: (google.cloud.retail.v2beta.Model.ServingState|keyof typeof google.cloud.retail.v2beta.Model.ServingState|null); + + /** Model createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** Model updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** Model type */ + type?: (string|null); + + /** Model optimizationObjective */ + optimizationObjective?: (string|null); + + /** Model periodicTuningState */ + periodicTuningState?: (google.cloud.retail.v2beta.Model.PeriodicTuningState|keyof typeof google.cloud.retail.v2beta.Model.PeriodicTuningState|null); + + /** Model lastTuneTime */ + lastTuneTime?: (google.protobuf.ITimestamp|null); + + /** Model tuningOperation */ + tuningOperation?: (string|null); + + /** Model dataState */ + dataState?: (google.cloud.retail.v2beta.Model.DataState|keyof typeof google.cloud.retail.v2beta.Model.DataState|null); + + /** Model filteringOption */ + filteringOption?: (google.cloud.retail.v2beta.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2beta.RecommendationsFilteringOption|null); + + /** Model servingConfigLists */ + servingConfigLists?: (google.cloud.retail.v2beta.Model.IServingConfigList[]|null); + } + + /** Represents a Model. */ + class Model implements IModel { + + /** + * Constructs a new Model. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IModel); + + /** Model name. */ + public name: string; + + /** Model displayName. */ + public displayName: string; + + /** Model trainingState. */ + public trainingState: (google.cloud.retail.v2beta.Model.TrainingState|keyof typeof google.cloud.retail.v2beta.Model.TrainingState); + + /** Model servingState. */ + public servingState: (google.cloud.retail.v2beta.Model.ServingState|keyof typeof google.cloud.retail.v2beta.Model.ServingState); + + /** Model createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** Model updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Model type. */ + public type: string; + + /** Model optimizationObjective. */ + public optimizationObjective: string; + + /** Model periodicTuningState. */ + public periodicTuningState: (google.cloud.retail.v2beta.Model.PeriodicTuningState|keyof typeof google.cloud.retail.v2beta.Model.PeriodicTuningState); + + /** Model lastTuneTime. */ + public lastTuneTime?: (google.protobuf.ITimestamp|null); + + /** Model tuningOperation. */ + public tuningOperation: string; + + /** Model dataState. */ + public dataState: (google.cloud.retail.v2beta.Model.DataState|keyof typeof google.cloud.retail.v2beta.Model.DataState); + + /** Model filteringOption. */ + public filteringOption: (google.cloud.retail.v2beta.RecommendationsFilteringOption|keyof typeof google.cloud.retail.v2beta.RecommendationsFilteringOption); + + /** Model servingConfigLists. */ + public servingConfigLists: google.cloud.retail.v2beta.Model.IServingConfigList[]; + + /** + * Creates a new Model instance using the specified properties. + * @param [properties] Properties to set + * @returns Model instance + */ + public static create(properties?: google.cloud.retail.v2beta.IModel): google.cloud.retail.v2beta.Model; + + /** + * Encodes the specified Model message. Does not implicitly {@link google.cloud.retail.v2beta.Model.verify|verify} messages. + * @param message Model message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IModel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Model message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Model.verify|verify} messages. + * @param message Model message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IModel, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Model message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Model + * @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.cloud.retail.v2beta.Model; + + /** + * Decodes a Model message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Model + * @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.cloud.retail.v2beta.Model; + + /** + * Verifies a Model 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 Model message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Model + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Model; + + /** + * Creates a plain object from a Model message. Also converts values to other types if specified. + * @param message Model + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Model, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Model to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Model + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Model { + + /** Properties of a ServingConfigList. */ + interface IServingConfigList { + + /** ServingConfigList servingConfigIds */ + servingConfigIds?: (string[]|null); + } + + /** Represents a ServingConfigList. */ + class ServingConfigList implements IServingConfigList { + + /** + * Constructs a new ServingConfigList. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.Model.IServingConfigList); + + /** ServingConfigList servingConfigIds. */ + public servingConfigIds: string[]; + + /** + * Creates a new ServingConfigList instance using the specified properties. + * @param [properties] Properties to set + * @returns ServingConfigList instance + */ + public static create(properties?: google.cloud.retail.v2beta.Model.IServingConfigList): google.cloud.retail.v2beta.Model.ServingConfigList; + + /** + * Encodes the specified ServingConfigList message. Does not implicitly {@link google.cloud.retail.v2beta.Model.ServingConfigList.verify|verify} messages. + * @param message ServingConfigList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.Model.IServingConfigList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServingConfigList message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Model.ServingConfigList.verify|verify} messages. + * @param message ServingConfigList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.Model.IServingConfigList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServingConfigList + * @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.cloud.retail.v2beta.Model.ServingConfigList; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServingConfigList + * @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.cloud.retail.v2beta.Model.ServingConfigList; + + /** + * Verifies a ServingConfigList 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 ServingConfigList message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServingConfigList + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.Model.ServingConfigList; + + /** + * Creates a plain object from a ServingConfigList message. Also converts values to other types if specified. + * @param message ServingConfigList + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.Model.ServingConfigList, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServingConfigList to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServingConfigList + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** ServingState enum. */ + enum ServingState { + SERVING_STATE_UNSPECIFIED = 0, + INACTIVE = 1, + ACTIVE = 2, + TUNED = 3 + } + + /** TrainingState enum. */ + enum TrainingState { + TRAINING_STATE_UNSPECIFIED = 0, + PAUSED = 1, + TRAINING = 2 + } + + /** PeriodicTuningState enum. */ + enum PeriodicTuningState { + PERIODIC_TUNING_STATE_UNSPECIFIED = 0, + PERIODIC_TUNING_DISABLED = 1, + ALL_TUNING_DISABLED = 3, + PERIODIC_TUNING_ENABLED = 2 + } + + /** DataState enum. */ + enum DataState { + DATA_STATE_UNSPECIFIED = 0, + DATA_OK = 1, + DATA_ERROR = 2 + } + } + + /** Represents a ModelService */ + class ModelService extends $protobuf.rpc.Service { + + /** + * Constructs a new ModelService 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 ModelService 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): ModelService; + + /** + * Calls CreateModel. + * @param request CreateModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createModel(request: google.cloud.retail.v2beta.ICreateModelRequest, callback: google.cloud.retail.v2beta.ModelService.CreateModelCallback): void; + + /** + * Calls CreateModel. + * @param request CreateModelRequest message or plain object + * @returns Promise + */ + public createModel(request: google.cloud.retail.v2beta.ICreateModelRequest): Promise; + + /** + * Calls PauseModel. + * @param request PauseModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public pauseModel(request: google.cloud.retail.v2beta.IPauseModelRequest, callback: google.cloud.retail.v2beta.ModelService.PauseModelCallback): void; + + /** + * Calls PauseModel. + * @param request PauseModelRequest message or plain object + * @returns Promise + */ + public pauseModel(request: google.cloud.retail.v2beta.IPauseModelRequest): Promise; + + /** + * Calls ResumeModel. + * @param request ResumeModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public resumeModel(request: google.cloud.retail.v2beta.IResumeModelRequest, callback: google.cloud.retail.v2beta.ModelService.ResumeModelCallback): void; + + /** + * Calls ResumeModel. + * @param request ResumeModelRequest message or plain object + * @returns Promise + */ + public resumeModel(request: google.cloud.retail.v2beta.IResumeModelRequest): Promise; + + /** + * Calls DeleteModel. + * @param request DeleteModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteModel(request: google.cloud.retail.v2beta.IDeleteModelRequest, callback: google.cloud.retail.v2beta.ModelService.DeleteModelCallback): void; + + /** + * Calls DeleteModel. + * @param request DeleteModelRequest message or plain object + * @returns Promise + */ + public deleteModel(request: google.cloud.retail.v2beta.IDeleteModelRequest): Promise; + + /** + * Calls ListModels. + * @param request ListModelsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListModelsResponse + */ + public listModels(request: google.cloud.retail.v2beta.IListModelsRequest, callback: google.cloud.retail.v2beta.ModelService.ListModelsCallback): void; + + /** + * Calls ListModels. + * @param request ListModelsRequest message or plain object + * @returns Promise + */ + public listModels(request: google.cloud.retail.v2beta.IListModelsRequest): Promise; + + /** + * Calls UpdateModel. + * @param request UpdateModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Model + */ + public updateModel(request: google.cloud.retail.v2beta.IUpdateModelRequest, callback: google.cloud.retail.v2beta.ModelService.UpdateModelCallback): void; + + /** + * Calls UpdateModel. + * @param request UpdateModelRequest message or plain object + * @returns Promise + */ + public updateModel(request: google.cloud.retail.v2beta.IUpdateModelRequest): Promise; + + /** + * Calls TuneModel. + * @param request TuneModelRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public tuneModel(request: google.cloud.retail.v2beta.ITuneModelRequest, callback: google.cloud.retail.v2beta.ModelService.TuneModelCallback): void; + + /** + * Calls TuneModel. + * @param request TuneModelRequest message or plain object + * @returns Promise + */ + public tuneModel(request: google.cloud.retail.v2beta.ITuneModelRequest): Promise; + } + + namespace ModelService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|createModel}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateModelCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|pauseModel}. + * @param error Error, if any + * @param [response] Model + */ + type PauseModelCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|resumeModel}. + * @param error Error, if any + * @param [response] Model + */ + type ResumeModelCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|deleteModel}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteModelCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|listModels}. + * @param error Error, if any + * @param [response] ListModelsResponse + */ + type ListModelsCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ListModelsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|updateModel}. + * @param error Error, if any + * @param [response] Model + */ + type UpdateModelCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Model) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|tuneModel}. + * @param error Error, if any + * @param [response] Operation + */ + type TuneModelCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateModelRequest. */ + interface ICreateModelRequest { + + /** CreateModelRequest parent */ + parent?: (string|null); + + /** CreateModelRequest model */ + model?: (google.cloud.retail.v2beta.IModel|null); + + /** CreateModelRequest dryRun */ + dryRun?: (boolean|null); + } + + /** Represents a CreateModelRequest. */ + class CreateModelRequest implements ICreateModelRequest { + + /** + * Constructs a new CreateModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICreateModelRequest); + + /** CreateModelRequest parent. */ + public parent: string; + + /** CreateModelRequest model. */ + public model?: (google.cloud.retail.v2beta.IModel|null); + + /** CreateModelRequest dryRun. */ + public dryRun: boolean; + + /** + * Creates a new CreateModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICreateModelRequest): google.cloud.retail.v2beta.CreateModelRequest; + + /** + * Encodes the specified CreateModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelRequest.verify|verify} messages. + * @param message CreateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICreateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelRequest.verify|verify} messages. + * @param message CreateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICreateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateModelRequest + * @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.cloud.retail.v2beta.CreateModelRequest; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateModelRequest + * @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.cloud.retail.v2beta.CreateModelRequest; + + /** + * Verifies a CreateModelRequest 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 CreateModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CreateModelRequest; + + /** + * Creates a plain object from a CreateModelRequest message. Also converts values to other types if specified. + * @param message CreateModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CreateModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateModelRequest. */ + interface IUpdateModelRequest { + + /** UpdateModelRequest model */ + model?: (google.cloud.retail.v2beta.IModel|null); + + /** UpdateModelRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateModelRequest. */ + class UpdateModelRequest implements IUpdateModelRequest { + + /** + * Constructs a new UpdateModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateModelRequest); + + /** UpdateModelRequest model. */ + public model?: (google.cloud.retail.v2beta.IModel|null); + + /** UpdateModelRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateModelRequest): google.cloud.retail.v2beta.UpdateModelRequest; + + /** + * Encodes the specified UpdateModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateModelRequest.verify|verify} messages. + * @param message UpdateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateModelRequest.verify|verify} messages. + * @param message UpdateModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateModelRequest + * @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.cloud.retail.v2beta.UpdateModelRequest; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateModelRequest + * @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.cloud.retail.v2beta.UpdateModelRequest; + + /** + * Verifies an UpdateModelRequest 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 UpdateModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateModelRequest; + + /** + * Creates a plain object from an UpdateModelRequest message. Also converts values to other types if specified. + * @param message UpdateModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PauseModelRequest. */ + interface IPauseModelRequest { + + /** PauseModelRequest name */ + name?: (string|null); + } + + /** Represents a PauseModelRequest. */ + class PauseModelRequest implements IPauseModelRequest { + + /** + * Constructs a new PauseModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPauseModelRequest); + + /** PauseModelRequest name. */ + public name: string; + + /** + * Creates a new PauseModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PauseModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPauseModelRequest): google.cloud.retail.v2beta.PauseModelRequest; + + /** + * Encodes the specified PauseModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PauseModelRequest.verify|verify} messages. + * @param message PauseModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPauseModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PauseModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PauseModelRequest.verify|verify} messages. + * @param message PauseModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPauseModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PauseModelRequest + * @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.cloud.retail.v2beta.PauseModelRequest; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PauseModelRequest + * @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.cloud.retail.v2beta.PauseModelRequest; + + /** + * Verifies a PauseModelRequest 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 PauseModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PauseModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PauseModelRequest; + + /** + * Creates a plain object from a PauseModelRequest message. Also converts values to other types if specified. + * @param message PauseModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PauseModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PauseModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PauseModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ResumeModelRequest. */ + interface IResumeModelRequest { + + /** ResumeModelRequest name */ + name?: (string|null); + } + + /** Represents a ResumeModelRequest. */ + class ResumeModelRequest implements IResumeModelRequest { + + /** + * Constructs a new ResumeModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IResumeModelRequest); + + /** ResumeModelRequest name. */ + public name: string; + + /** + * Creates a new ResumeModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ResumeModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IResumeModelRequest): google.cloud.retail.v2beta.ResumeModelRequest; + + /** + * Encodes the specified ResumeModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ResumeModelRequest.verify|verify} messages. + * @param message ResumeModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IResumeModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ResumeModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ResumeModelRequest.verify|verify} messages. + * @param message ResumeModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IResumeModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ResumeModelRequest + * @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.cloud.retail.v2beta.ResumeModelRequest; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ResumeModelRequest + * @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.cloud.retail.v2beta.ResumeModelRequest; + + /** + * Verifies a ResumeModelRequest 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 ResumeModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResumeModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ResumeModelRequest; + + /** + * Creates a plain object from a ResumeModelRequest message. Also converts values to other types if specified. + * @param message ResumeModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ResumeModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResumeModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResumeModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListModelsRequest. */ + interface IListModelsRequest { + + /** ListModelsRequest parent */ + parent?: (string|null); + + /** ListModelsRequest pageSize */ + pageSize?: (number|null); + + /** ListModelsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListModelsRequest. */ + class ListModelsRequest implements IListModelsRequest { + + /** + * Constructs a new ListModelsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListModelsRequest); + + /** ListModelsRequest parent. */ + public parent: string; + + /** ListModelsRequest pageSize. */ + public pageSize: number; + + /** ListModelsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListModelsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListModelsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListModelsRequest): google.cloud.retail.v2beta.ListModelsRequest; + + /** + * Encodes the specified ListModelsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsRequest.verify|verify} messages. + * @param message ListModelsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListModelsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListModelsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsRequest.verify|verify} messages. + * @param message ListModelsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListModelsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListModelsRequest + * @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.cloud.retail.v2beta.ListModelsRequest; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListModelsRequest + * @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.cloud.retail.v2beta.ListModelsRequest; + + /** + * Verifies a ListModelsRequest 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 ListModelsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListModelsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListModelsRequest; + + /** + * Creates a plain object from a ListModelsRequest message. Also converts values to other types if specified. + * @param message ListModelsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListModelsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListModelsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListModelsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteModelRequest. */ + interface IDeleteModelRequest { + + /** DeleteModelRequest name */ + name?: (string|null); + } + + /** Represents a DeleteModelRequest. */ + class DeleteModelRequest implements IDeleteModelRequest { + + /** + * Constructs a new DeleteModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IDeleteModelRequest); + + /** DeleteModelRequest name. */ + public name: string; + + /** + * Creates a new DeleteModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IDeleteModelRequest): google.cloud.retail.v2beta.DeleteModelRequest; + + /** + * Encodes the specified DeleteModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteModelRequest.verify|verify} messages. + * @param message DeleteModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IDeleteModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteModelRequest.verify|verify} messages. + * @param message DeleteModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IDeleteModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteModelRequest + * @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.cloud.retail.v2beta.DeleteModelRequest; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteModelRequest + * @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.cloud.retail.v2beta.DeleteModelRequest; + + /** + * Verifies a DeleteModelRequest 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 DeleteModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.DeleteModelRequest; + + /** + * Creates a plain object from a DeleteModelRequest message. Also converts values to other types if specified. + * @param message DeleteModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.DeleteModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListModelsResponse. */ + interface IListModelsResponse { + + /** ListModelsResponse models */ + models?: (google.cloud.retail.v2beta.IModel[]|null); + + /** ListModelsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListModelsResponse. */ + class ListModelsResponse implements IListModelsResponse { + + /** + * Constructs a new ListModelsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListModelsResponse); + + /** ListModelsResponse models. */ + public models: google.cloud.retail.v2beta.IModel[]; + + /** ListModelsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListModelsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListModelsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListModelsResponse): google.cloud.retail.v2beta.ListModelsResponse; + + /** + * Encodes the specified ListModelsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsResponse.verify|verify} messages. + * @param message ListModelsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListModelsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListModelsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsResponse.verify|verify} messages. + * @param message ListModelsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListModelsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListModelsResponse + * @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.cloud.retail.v2beta.ListModelsResponse; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListModelsResponse + * @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.cloud.retail.v2beta.ListModelsResponse; + + /** + * Verifies a ListModelsResponse 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 ListModelsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListModelsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListModelsResponse; + + /** + * Creates a plain object from a ListModelsResponse message. Also converts values to other types if specified. + * @param message ListModelsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListModelsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListModelsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListModelsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelRequest. */ + interface ITuneModelRequest { + + /** TuneModelRequest name */ + name?: (string|null); + } + + /** Represents a TuneModelRequest. */ + class TuneModelRequest implements ITuneModelRequest { + + /** + * Constructs a new TuneModelRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ITuneModelRequest); + + /** TuneModelRequest name. */ + public name: string; + + /** + * Creates a new TuneModelRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ITuneModelRequest): google.cloud.retail.v2beta.TuneModelRequest; + + /** + * Encodes the specified TuneModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelRequest.verify|verify} messages. + * @param message TuneModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ITuneModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelRequest.verify|verify} messages. + * @param message TuneModelRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ITuneModelRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelRequest + * @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.cloud.retail.v2beta.TuneModelRequest; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelRequest + * @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.cloud.retail.v2beta.TuneModelRequest; + + /** + * Verifies a TuneModelRequest 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 TuneModelRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.TuneModelRequest; + + /** + * Creates a plain object from a TuneModelRequest message. Also converts values to other types if specified. + * @param message TuneModelRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.TuneModelRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreateModelMetadata. */ + interface ICreateModelMetadata { + + /** CreateModelMetadata model */ + model?: (string|null); + } + + /** Represents a CreateModelMetadata. */ + class CreateModelMetadata implements ICreateModelMetadata { + + /** + * Constructs a new CreateModelMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICreateModelMetadata); + + /** CreateModelMetadata model. */ + public model: string; + + /** + * Creates a new CreateModelMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateModelMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICreateModelMetadata): google.cloud.retail.v2beta.CreateModelMetadata; + + /** + * Encodes the specified CreateModelMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelMetadata.verify|verify} messages. + * @param message CreateModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICreateModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelMetadata.verify|verify} messages. + * @param message CreateModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICreateModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateModelMetadata + * @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.cloud.retail.v2beta.CreateModelMetadata; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateModelMetadata + * @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.cloud.retail.v2beta.CreateModelMetadata; + + /** + * Verifies a CreateModelMetadata 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 CreateModelMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateModelMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CreateModelMetadata; + + /** + * Creates a plain object from a CreateModelMetadata message. Also converts values to other types if specified. + * @param message CreateModelMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CreateModelMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateModelMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateModelMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelMetadata. */ + interface ITuneModelMetadata { + + /** TuneModelMetadata model */ + model?: (string|null); + } + + /** Represents a TuneModelMetadata. */ + class TuneModelMetadata implements ITuneModelMetadata { + + /** + * Constructs a new TuneModelMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ITuneModelMetadata); + + /** TuneModelMetadata model. */ + public model: string; + + /** + * Creates a new TuneModelMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.ITuneModelMetadata): google.cloud.retail.v2beta.TuneModelMetadata; + + /** + * Encodes the specified TuneModelMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelMetadata.verify|verify} messages. + * @param message TuneModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ITuneModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelMetadata.verify|verify} messages. + * @param message TuneModelMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ITuneModelMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelMetadata + * @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.cloud.retail.v2beta.TuneModelMetadata; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelMetadata + * @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.cloud.retail.v2beta.TuneModelMetadata; + + /** + * Verifies a TuneModelMetadata 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 TuneModelMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.TuneModelMetadata; + + /** + * Creates a plain object from a TuneModelMetadata message. Also converts values to other types if specified. + * @param message TuneModelMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.TuneModelMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a TuneModelResponse. */ + interface ITuneModelResponse { + } + + /** Represents a TuneModelResponse. */ + class TuneModelResponse implements ITuneModelResponse { + + /** + * Constructs a new TuneModelResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ITuneModelResponse); + + /** + * Creates a new TuneModelResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns TuneModelResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.ITuneModelResponse): google.cloud.retail.v2beta.TuneModelResponse; + + /** + * Encodes the specified TuneModelResponse message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelResponse.verify|verify} messages. + * @param message TuneModelResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ITuneModelResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TuneModelResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelResponse.verify|verify} messages. + * @param message TuneModelResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ITuneModelResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TuneModelResponse + * @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.cloud.retail.v2beta.TuneModelResponse; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TuneModelResponse + * @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.cloud.retail.v2beta.TuneModelResponse; + + /** + * Verifies a TuneModelResponse 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 TuneModelResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TuneModelResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.TuneModelResponse; + + /** + * Creates a plain object from a TuneModelResponse message. Also converts values to other types if specified. + * @param message TuneModelResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.TuneModelResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TuneModelResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TuneModelResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a PredictionService */ + class PredictionService extends $protobuf.rpc.Service { + + /** + * Constructs a new PredictionService 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 PredictionService 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): PredictionService; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PredictResponse + */ + public predict(request: google.cloud.retail.v2beta.IPredictRequest, callback: google.cloud.retail.v2beta.PredictionService.PredictCallback): void; + + /** + * Calls Predict. + * @param request PredictRequest message or plain object + * @returns Promise + */ + public predict(request: google.cloud.retail.v2beta.IPredictRequest): Promise; + } + + namespace PredictionService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.PredictionService|predict}. + * @param error Error, if any + * @param [response] PredictResponse + */ + type PredictCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.PredictResponse) => void; + } + + /** Properties of a PredictRequest. */ + interface IPredictRequest { + + /** PredictRequest placement */ + placement?: (string|null); + + /** PredictRequest userEvent */ + userEvent?: (google.cloud.retail.v2beta.IUserEvent|null); + + /** PredictRequest pageSize */ + pageSize?: (number|null); + + /** PredictRequest pageToken */ + pageToken?: (string|null); + + /** PredictRequest filter */ + filter?: (string|null); + + /** PredictRequest validateOnly */ + validateOnly?: (boolean|null); + + /** PredictRequest params */ + params?: ({ [k: string]: google.protobuf.IValue }|null); + + /** PredictRequest labels */ + labels?: ({ [k: string]: string }|null); + } + + /** Represents a PredictRequest. */ + class PredictRequest implements IPredictRequest { + + /** + * Constructs a new PredictRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPredictRequest); + + /** PredictRequest placement. */ + public placement: string; + + /** PredictRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2beta.IUserEvent|null); + + /** PredictRequest pageSize. */ + public pageSize: number; + + /** PredictRequest pageToken. */ + public pageToken: string; + + /** PredictRequest filter. */ + public filter: string; + + /** PredictRequest validateOnly. */ + public validateOnly: boolean; + + /** PredictRequest params. */ + public params: { [k: string]: google.protobuf.IValue }; + + /** PredictRequest labels. */ + public labels: { [k: string]: string }; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPredictRequest): google.cloud.retail.v2beta.PredictRequest; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictRequest.verify|verify} messages. + * @param message PredictRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPredictRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictRequest + * @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.cloud.retail.v2beta.PredictRequest; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictRequest + * @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.cloud.retail.v2beta.PredictRequest; + + /** + * Verifies a PredictRequest 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 PredictRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PredictRequest; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @param message PredictRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PredictRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PredictResponse. */ + interface IPredictResponse { + + /** PredictResponse results */ + results?: (google.cloud.retail.v2beta.PredictResponse.IPredictionResult[]|null); + + /** PredictResponse attributionToken */ + attributionToken?: (string|null); + + /** PredictResponse missingIds */ + missingIds?: (string[]|null); + + /** PredictResponse validateOnly */ + validateOnly?: (boolean|null); + } + + /** Represents a PredictResponse. */ + class PredictResponse implements IPredictResponse { + + /** + * Constructs a new PredictResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPredictResponse); + + /** PredictResponse results. */ + public results: google.cloud.retail.v2beta.PredictResponse.IPredictionResult[]; + + /** PredictResponse attributionToken. */ + public attributionToken: string; + + /** PredictResponse missingIds. */ + public missingIds: string[]; + + /** PredictResponse validateOnly. */ + public validateOnly: boolean; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPredictResponse): google.cloud.retail.v2beta.PredictResponse; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.verify|verify} messages. + * @param message PredictResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPredictResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictResponse + * @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.cloud.retail.v2beta.PredictResponse; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictResponse + * @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.cloud.retail.v2beta.PredictResponse; + + /** + * Verifies a PredictResponse 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 PredictResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PredictResponse; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @param message PredictResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PredictResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PredictResponse { + + /** Properties of a PredictionResult. */ + interface IPredictionResult { + + /** PredictionResult id */ + id?: (string|null); + + /** PredictionResult metadata */ + metadata?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a PredictionResult. */ + class PredictionResult implements IPredictionResult { + + /** + * Constructs a new PredictionResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.PredictResponse.IPredictionResult); + + /** PredictionResult id. */ + public id: string; + + /** PredictionResult metadata. */ + public metadata: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @param [properties] Properties to set + * @returns PredictionResult instance + */ + public static create(properties?: google.cloud.retail.v2beta.PredictResponse.IPredictionResult): google.cloud.retail.v2beta.PredictResponse.PredictionResult; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.PredictionResult.verify|verify} messages. + * @param message PredictionResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.PredictResponse.IPredictionResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PredictionResult + * @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.cloud.retail.v2beta.PredictResponse.PredictionResult; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PredictionResult + * @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.cloud.retail.v2beta.PredictResponse.PredictionResult; + + /** + * Verifies a PredictionResult 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 PredictionResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PredictionResult + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PredictResponse.PredictionResult; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @param message PredictionResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PredictResponse.PredictionResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PredictionResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PredictionResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Represents a ProductService */ + class ProductService extends $protobuf.rpc.Service { + + /** + * Constructs a new ProductService 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 ProductService 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): ProductService; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public createProduct(request: google.cloud.retail.v2beta.ICreateProductRequest, callback: google.cloud.retail.v2beta.ProductService.CreateProductCallback): void; + + /** + * Calls CreateProduct. + * @param request CreateProductRequest message or plain object + * @returns Promise + */ + public createProduct(request: google.cloud.retail.v2beta.ICreateProductRequest): Promise; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public getProduct(request: google.cloud.retail.v2beta.IGetProductRequest, callback: google.cloud.retail.v2beta.ProductService.GetProductCallback): void; + + /** + * Calls GetProduct. + * @param request GetProductRequest message or plain object + * @returns Promise + */ + public getProduct(request: google.cloud.retail.v2beta.IGetProductRequest): Promise; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListProductsResponse + */ + public listProducts(request: google.cloud.retail.v2beta.IListProductsRequest, callback: google.cloud.retail.v2beta.ProductService.ListProductsCallback): void; + + /** + * Calls ListProducts. + * @param request ListProductsRequest message or plain object + * @returns Promise + */ + public listProducts(request: google.cloud.retail.v2beta.IListProductsRequest): Promise; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Product + */ + public updateProduct(request: google.cloud.retail.v2beta.IUpdateProductRequest, callback: google.cloud.retail.v2beta.ProductService.UpdateProductCallback): void; + + /** + * Calls UpdateProduct. + * @param request UpdateProductRequest message or plain object + * @returns Promise + */ + public updateProduct(request: google.cloud.retail.v2beta.IUpdateProductRequest): Promise; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteProduct(request: google.cloud.retail.v2beta.IDeleteProductRequest, callback: google.cloud.retail.v2beta.ProductService.DeleteProductCallback): void; + + /** + * Calls DeleteProduct. + * @param request DeleteProductRequest message or plain object + * @returns Promise + */ + public deleteProduct(request: google.cloud.retail.v2beta.IDeleteProductRequest): Promise; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importProducts(request: google.cloud.retail.v2beta.IImportProductsRequest, callback: google.cloud.retail.v2beta.ProductService.ImportProductsCallback): void; + + /** + * Calls ImportProducts. + * @param request ImportProductsRequest message or plain object + * @returns Promise + */ + public importProducts(request: google.cloud.retail.v2beta.IImportProductsRequest): Promise; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public setInventory(request: google.cloud.retail.v2beta.ISetInventoryRequest, callback: google.cloud.retail.v2beta.ProductService.SetInventoryCallback): void; + + /** + * Calls SetInventory. + * @param request SetInventoryRequest message or plain object + * @returns Promise + */ + public setInventory(request: google.cloud.retail.v2beta.ISetInventoryRequest): Promise; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, callback: google.cloud.retail.v2beta.ProductService.AddFulfillmentPlacesCallback): void; + + /** + * Calls AddFulfillmentPlaces. + * @param request AddFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public addFulfillmentPlaces(request: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest): Promise; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, callback: google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlacesCallback): void; + + /** + * Calls RemoveFulfillmentPlaces. + * @param request RemoveFulfillmentPlacesRequest message or plain object + * @returns Promise + */ + public removeFulfillmentPlaces(request: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest): Promise; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public addLocalInventories(request: google.cloud.retail.v2beta.IAddLocalInventoriesRequest, callback: google.cloud.retail.v2beta.ProductService.AddLocalInventoriesCallback): void; + + /** + * Calls AddLocalInventories. + * @param request AddLocalInventoriesRequest message or plain object + * @returns Promise + */ + public addLocalInventories(request: google.cloud.retail.v2beta.IAddLocalInventoriesRequest): Promise; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public removeLocalInventories(request: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, callback: google.cloud.retail.v2beta.ProductService.RemoveLocalInventoriesCallback): void; + + /** + * Calls RemoveLocalInventories. + * @param request RemoveLocalInventoriesRequest message or plain object + * @returns Promise + */ + public removeLocalInventories(request: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest): Promise; + } + + namespace ProductService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|createProduct}. + * @param error Error, if any + * @param [response] Product + */ + type CreateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|getProduct}. + * @param error Error, if any + * @param [response] Product + */ + type GetProductCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|listProducts}. + * @param error Error, if any + * @param [response] ListProductsResponse + */ + type ListProductsCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ListProductsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|updateProduct}. + * @param error Error, if any + * @param [response] Product + */ + type UpdateProductCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.Product) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|deleteProduct}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteProductCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|importProducts}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportProductsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|setInventory}. + * @param error Error, if any + * @param [response] Operation + */ + type SetInventoryCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|addFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type AddFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|removeFulfillmentPlaces}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveFulfillmentPlacesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|addLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type AddLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|removeLocalInventories}. + * @param error Error, if any + * @param [response] Operation + */ + type RemoveLocalInventoriesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a CreateProductRequest. */ + interface ICreateProductRequest { + + /** CreateProductRequest parent */ + parent?: (string|null); + + /** CreateProductRequest product */ + product?: (google.cloud.retail.v2beta.IProduct|null); + + /** CreateProductRequest productId */ + productId?: (string|null); + } + + /** Represents a CreateProductRequest. */ + class CreateProductRequest implements ICreateProductRequest { + + /** + * Constructs a new CreateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICreateProductRequest); + + /** CreateProductRequest parent. */ + public parent: string; + + /** CreateProductRequest product. */ + public product?: (google.cloud.retail.v2beta.IProduct|null); + + /** CreateProductRequest productId. */ + public productId: string; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICreateProductRequest): google.cloud.retail.v2beta.CreateProductRequest; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateProductRequest.verify|verify} messages. + * @param message CreateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICreateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateProductRequest + * @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.cloud.retail.v2beta.CreateProductRequest; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateProductRequest + * @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.cloud.retail.v2beta.CreateProductRequest; + + /** + * Verifies a CreateProductRequest 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 CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CreateProductRequest; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @param message CreateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CreateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetProductRequest. */ + interface IGetProductRequest { + + /** GetProductRequest name */ + name?: (string|null); + } + + /** Represents a GetProductRequest. */ + class GetProductRequest implements IGetProductRequest { + + /** + * Constructs a new GetProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetProductRequest); + + /** GetProductRequest name. */ + public name: string; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetProductRequest): google.cloud.retail.v2beta.GetProductRequest; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetProductRequest.verify|verify} messages. + * @param message GetProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetProductRequest + * @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.cloud.retail.v2beta.GetProductRequest; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetProductRequest + * @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.cloud.retail.v2beta.GetProductRequest; + + /** + * Verifies a GetProductRequest 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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetProductRequest; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @param message GetProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateProductRequest. */ + interface IUpdateProductRequest { + + /** UpdateProductRequest product */ + product?: (google.cloud.retail.v2beta.IProduct|null); + + /** UpdateProductRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an UpdateProductRequest. */ + class UpdateProductRequest implements IUpdateProductRequest { + + /** + * Constructs a new UpdateProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateProductRequest); + + /** UpdateProductRequest product. */ + public product?: (google.cloud.retail.v2beta.IProduct|null); + + /** UpdateProductRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** UpdateProductRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateProductRequest): google.cloud.retail.v2beta.UpdateProductRequest; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateProductRequest.verify|verify} messages. + * @param message UpdateProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateProductRequest + * @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.cloud.retail.v2beta.UpdateProductRequest; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateProductRequest + * @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.cloud.retail.v2beta.UpdateProductRequest; + + /** + * Verifies an UpdateProductRequest 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 UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateProductRequest; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @param message UpdateProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteProductRequest. */ + interface IDeleteProductRequest { + + /** DeleteProductRequest name */ + name?: (string|null); + } + + /** Represents a DeleteProductRequest. */ + class DeleteProductRequest implements IDeleteProductRequest { + + /** + * Constructs a new DeleteProductRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IDeleteProductRequest); + + /** DeleteProductRequest name. */ + public name: string; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteProductRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IDeleteProductRequest): google.cloud.retail.v2beta.DeleteProductRequest; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteProductRequest.verify|verify} messages. + * @param message DeleteProductRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IDeleteProductRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteProductRequest + * @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.cloud.retail.v2beta.DeleteProductRequest; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteProductRequest + * @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.cloud.retail.v2beta.DeleteProductRequest; + + /** + * Verifies a DeleteProductRequest 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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteProductRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.DeleteProductRequest; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @param message DeleteProductRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.DeleteProductRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteProductRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteProductRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsRequest. */ + interface IListProductsRequest { + + /** ListProductsRequest parent */ + parent?: (string|null); + + /** ListProductsRequest pageSize */ + pageSize?: (number|null); + + /** ListProductsRequest pageToken */ + pageToken?: (string|null); + + /** ListProductsRequest filter */ + filter?: (string|null); + + /** ListProductsRequest readMask */ + readMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents a ListProductsRequest. */ + class ListProductsRequest implements IListProductsRequest { + + /** + * Constructs a new ListProductsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListProductsRequest); + + /** ListProductsRequest parent. */ + public parent: string; + + /** ListProductsRequest pageSize. */ + public pageSize: number; + + /** ListProductsRequest pageToken. */ + public pageToken: string; + + /** ListProductsRequest filter. */ + public filter: string; + + /** ListProductsRequest readMask. */ + public readMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListProductsRequest): google.cloud.retail.v2beta.ListProductsRequest; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsRequest.verify|verify} messages. + * @param message ListProductsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListProductsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsRequest + * @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.cloud.retail.v2beta.ListProductsRequest; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsRequest + * @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.cloud.retail.v2beta.ListProductsRequest; + + /** + * Verifies a ListProductsRequest 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 ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListProductsRequest; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @param message ListProductsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListProductsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListProductsResponse. */ + interface IListProductsResponse { + + /** ListProductsResponse products */ + products?: (google.cloud.retail.v2beta.IProduct[]|null); + + /** ListProductsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListProductsResponse. */ + class ListProductsResponse implements IListProductsResponse { + + /** + * Constructs a new ListProductsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListProductsResponse); + + /** ListProductsResponse products. */ + public products: google.cloud.retail.v2beta.IProduct[]; + + /** ListProductsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListProductsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListProductsResponse): google.cloud.retail.v2beta.ListProductsResponse; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsResponse.verify|verify} messages. + * @param message ListProductsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListProductsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListProductsResponse + * @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.cloud.retail.v2beta.ListProductsResponse; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListProductsResponse + * @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.cloud.retail.v2beta.ListProductsResponse; + + /** + * Verifies a ListProductsResponse 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 ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListProductsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListProductsResponse; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @param message ListProductsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListProductsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListProductsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListProductsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryRequest. */ + interface ISetInventoryRequest { + + /** SetInventoryRequest inventory */ + inventory?: (google.cloud.retail.v2beta.IProduct|null); + + /** SetInventoryRequest setMask */ + setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime */ + setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a SetInventoryRequest. */ + class SetInventoryRequest implements ISetInventoryRequest { + + /** + * Constructs a new SetInventoryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISetInventoryRequest); + + /** SetInventoryRequest inventory. */ + public inventory?: (google.cloud.retail.v2beta.IProduct|null); + + /** SetInventoryRequest setMask. */ + public setMask?: (google.protobuf.IFieldMask|null); + + /** SetInventoryRequest setTime. */ + public setTime?: (google.protobuf.ITimestamp|null); + + /** SetInventoryRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISetInventoryRequest): google.cloud.retail.v2beta.SetInventoryRequest; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryRequest.verify|verify} messages. + * @param message SetInventoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISetInventoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryRequest + * @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.cloud.retail.v2beta.SetInventoryRequest; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryRequest + * @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.cloud.retail.v2beta.SetInventoryRequest; + + /** + * Verifies a SetInventoryRequest 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 SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SetInventoryRequest; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @param message SetInventoryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SetInventoryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryMetadata. */ + interface ISetInventoryMetadata { + } + + /** Represents a SetInventoryMetadata. */ + class SetInventoryMetadata implements ISetInventoryMetadata { + + /** + * Constructs a new SetInventoryMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISetInventoryMetadata); + + /** + * Creates a new SetInventoryMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISetInventoryMetadata): google.cloud.retail.v2beta.SetInventoryMetadata; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryMetadata.verify|verify} messages. + * @param message SetInventoryMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISetInventoryMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryMetadata + * @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.cloud.retail.v2beta.SetInventoryMetadata; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryMetadata + * @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.cloud.retail.v2beta.SetInventoryMetadata; + + /** + * Verifies a SetInventoryMetadata 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 SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SetInventoryMetadata; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @param message SetInventoryMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SetInventoryMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a SetInventoryResponse. */ + interface ISetInventoryResponse { + } + + /** Represents a SetInventoryResponse. */ + class SetInventoryResponse implements ISetInventoryResponse { + + /** + * Constructs a new SetInventoryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ISetInventoryResponse); + + /** + * Creates a new SetInventoryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns SetInventoryResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.ISetInventoryResponse): google.cloud.retail.v2beta.SetInventoryResponse; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryResponse.verify|verify} messages. + * @param message SetInventoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ISetInventoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SetInventoryResponse + * @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.cloud.retail.v2beta.SetInventoryResponse; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SetInventoryResponse + * @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.cloud.retail.v2beta.SetInventoryResponse; + + /** + * Verifies a SetInventoryResponse 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 SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SetInventoryResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.SetInventoryResponse; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @param message SetInventoryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.SetInventoryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SetInventoryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SetInventoryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesRequest. */ + interface IAddFulfillmentPlacesRequest { + + /** AddFulfillmentPlacesRequest product */ + product?: (string|null); + + /** AddFulfillmentPlacesRequest type */ + type?: (string|null); + + /** AddFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** AddFulfillmentPlacesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddFulfillmentPlacesRequest. */ + class AddFulfillmentPlacesRequest implements IAddFulfillmentPlacesRequest { + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest); + + /** AddFulfillmentPlacesRequest product. */ + public product: string; + + /** AddFulfillmentPlacesRequest type. */ + public type: string; + + /** AddFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** AddFulfillmentPlacesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest): google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.verify|verify} messages. + * @param message AddFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2beta.AddFulfillmentPlacesRequest; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesRequest + * @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.cloud.retail.v2beta.AddFulfillmentPlacesRequest; + + /** + * Verifies an AddFulfillmentPlacesRequest 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 AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddFulfillmentPlacesRequest; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesMetadata. */ + interface IAddFulfillmentPlacesMetadata { + } + + /** Represents an AddFulfillmentPlacesMetadata. */ + class AddFulfillmentPlacesMetadata implements IAddFulfillmentPlacesMetadata { + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata); + + /** + * Creates a new AddFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata): google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @param message AddFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesMetadata + * @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.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; + + /** + * Verifies an AddFulfillmentPlacesMetadata 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 AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddFulfillmentPlacesResponse. */ + interface IAddFulfillmentPlacesResponse { + } + + /** Represents an AddFulfillmentPlacesResponse. */ + class AddFulfillmentPlacesResponse implements IAddFulfillmentPlacesResponse { + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse); + + /** + * Creates a new AddFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse): google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesResponse.verify|verify} messages. + * @param message AddFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2beta.AddFulfillmentPlacesResponse; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddFulfillmentPlacesResponse + * @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.cloud.retail.v2beta.AddFulfillmentPlacesResponse; + + /** + * Verifies an AddFulfillmentPlacesResponse 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 AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddFulfillmentPlacesResponse; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message AddFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesRequest. */ + interface IAddLocalInventoriesRequest { + + /** AddLocalInventoriesRequest product */ + product?: (string|null); + + /** AddLocalInventoriesRequest localInventories */ + localInventories?: (google.cloud.retail.v2beta.ILocalInventory[]|null); + + /** AddLocalInventoriesRequest addMask */ + addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime */ + addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents an AddLocalInventoriesRequest. */ + class AddLocalInventoriesRequest implements IAddLocalInventoriesRequest { + + /** + * Constructs a new AddLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesRequest); + + /** AddLocalInventoriesRequest product. */ + public product: string; + + /** AddLocalInventoriesRequest localInventories. */ + public localInventories: google.cloud.retail.v2beta.ILocalInventory[]; + + /** AddLocalInventoriesRequest addMask. */ + public addMask?: (google.protobuf.IFieldMask|null); + + /** AddLocalInventoriesRequest addTime. */ + public addTime?: (google.protobuf.ITimestamp|null); + + /** AddLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesRequest): google.cloud.retail.v2beta.AddLocalInventoriesRequest; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesRequest.verify|verify} messages. + * @param message AddLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2beta.AddLocalInventoriesRequest; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesRequest + * @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.cloud.retail.v2beta.AddLocalInventoriesRequest; + + /** + * Verifies an AddLocalInventoriesRequest 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 AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddLocalInventoriesRequest; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message AddLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesMetadata. */ + interface IAddLocalInventoriesMetadata { + } + + /** Represents an AddLocalInventoriesMetadata. */ + class AddLocalInventoriesMetadata implements IAddLocalInventoriesMetadata { + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesMetadata); + + /** + * Creates a new AddLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesMetadata): google.cloud.retail.v2beta.AddLocalInventoriesMetadata; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesMetadata.verify|verify} messages. + * @param message AddLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2beta.AddLocalInventoriesMetadata; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesMetadata + * @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.cloud.retail.v2beta.AddLocalInventoriesMetadata; + + /** + * Verifies an AddLocalInventoriesMetadata 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 AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddLocalInventoriesMetadata; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message AddLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddLocalInventoriesResponse. */ + interface IAddLocalInventoriesResponse { + } + + /** Represents an AddLocalInventoriesResponse. */ + class AddLocalInventoriesResponse implements IAddLocalInventoriesResponse { + + /** + * Constructs a new AddLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesResponse); + + /** + * Creates a new AddLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AddLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddLocalInventoriesResponse): google.cloud.retail.v2beta.AddLocalInventoriesResponse; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesResponse.verify|verify} messages. + * @param message AddLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2beta.AddLocalInventoriesResponse; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddLocalInventoriesResponse + * @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.cloud.retail.v2beta.AddLocalInventoriesResponse; + + /** + * Verifies an AddLocalInventoriesResponse 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 AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddLocalInventoriesResponse; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message AddLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesRequest. */ + interface IRemoveLocalInventoriesRequest { + + /** RemoveLocalInventoriesRequest product */ + product?: (string|null); + + /** RemoveLocalInventoriesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveLocalInventoriesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveLocalInventoriesRequest. */ + class RemoveLocalInventoriesRequest implements IRemoveLocalInventoriesRequest { + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest); + + /** RemoveLocalInventoriesRequest product. */ + public product: string; + + /** RemoveLocalInventoriesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveLocalInventoriesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveLocalInventoriesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest): google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.verify|verify} messages. + * @param message RemoveLocalInventoriesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2beta.RemoveLocalInventoriesRequest; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesRequest + * @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.cloud.retail.v2beta.RemoveLocalInventoriesRequest; + + /** + * Verifies a RemoveLocalInventoriesRequest 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 RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveLocalInventoriesRequest; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveLocalInventoriesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesMetadata. */ + interface IRemoveLocalInventoriesMetadata { + } + + /** Represents a RemoveLocalInventoriesMetadata. */ + class RemoveLocalInventoriesMetadata implements IRemoveLocalInventoriesMetadata { + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata); + + /** + * Creates a new RemoveLocalInventoriesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata): google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @param message RemoveLocalInventoriesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesMetadata + * @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.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; + + /** + * Verifies a RemoveLocalInventoriesMetadata 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 RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveLocalInventoriesResponse. */ + interface IRemoveLocalInventoriesResponse { + } + + /** Represents a RemoveLocalInventoriesResponse. */ + class RemoveLocalInventoriesResponse implements IRemoveLocalInventoriesResponse { + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse); + + /** + * Creates a new RemoveLocalInventoriesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveLocalInventoriesResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse): google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesResponse.verify|verify} messages. + * @param message RemoveLocalInventoriesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveLocalInventoriesResponse + * @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.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + + /** + * Verifies a RemoveLocalInventoriesResponse 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 RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveLocalInventoriesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveLocalInventoriesResponse; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @param message RemoveLocalInventoriesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveLocalInventoriesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesRequest. */ + interface IRemoveFulfillmentPlacesRequest { + + /** RemoveFulfillmentPlacesRequest product */ + product?: (string|null); + + /** RemoveFulfillmentPlacesRequest type */ + type?: (string|null); + + /** RemoveFulfillmentPlacesRequest placeIds */ + placeIds?: (string[]|null); + + /** RemoveFulfillmentPlacesRequest removeTime */ + removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing */ + allowMissing?: (boolean|null); + } + + /** Represents a RemoveFulfillmentPlacesRequest. */ + class RemoveFulfillmentPlacesRequest implements IRemoveFulfillmentPlacesRequest { + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest); + + /** RemoveFulfillmentPlacesRequest product. */ + public product: string; + + /** RemoveFulfillmentPlacesRequest type. */ + public type: string; + + /** RemoveFulfillmentPlacesRequest placeIds. */ + public placeIds: string[]; + + /** RemoveFulfillmentPlacesRequest removeTime. */ + public removeTime?: (google.protobuf.ITimestamp|null); + + /** RemoveFulfillmentPlacesRequest allowMissing. */ + public allowMissing: boolean; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest): google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @param message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesRequest + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; + + /** + * Verifies a RemoveFulfillmentPlacesRequest 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 RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesMetadata. */ + interface IRemoveFulfillmentPlacesMetadata { + } + + /** Represents a RemoveFulfillmentPlacesMetadata. */ + class RemoveFulfillmentPlacesMetadata implements IRemoveFulfillmentPlacesMetadata { + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata); + + /** + * Creates a new RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata): google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @param message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesMetadata + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata 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 RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveFulfillmentPlacesResponse. */ + interface IRemoveFulfillmentPlacesResponse { + } + + /** Represents a RemoveFulfillmentPlacesResponse. */ + class RemoveFulfillmentPlacesResponse implements IRemoveFulfillmentPlacesResponse { + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse); + + /** + * Creates a new RemoveFulfillmentPlacesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveFulfillmentPlacesResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse): google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @param message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveFulfillmentPlacesResponse + * @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.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + + /** + * Verifies a RemoveFulfillmentPlacesResponse 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 RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveFulfillmentPlacesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @param message RemoveFulfillmentPlacesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeMetadata. */ + interface IPurgeMetadata { + } + + /** Represents a PurgeMetadata. */ + class PurgeMetadata implements IPurgeMetadata { + + /** + * Constructs a new PurgeMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPurgeMetadata); + + /** + * Creates a new PurgeMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPurgeMetadata): google.cloud.retail.v2beta.PurgeMetadata; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeMetadata.verify|verify} messages. + * @param message PurgeMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPurgeMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeMetadata + * @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.cloud.retail.v2beta.PurgeMetadata; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeMetadata + * @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.cloud.retail.v2beta.PurgeMetadata; + + /** + * Verifies a PurgeMetadata 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 PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PurgeMetadata; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @param message PurgeMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PurgeMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsRequest. */ + interface IPurgeUserEventsRequest { + + /** PurgeUserEventsRequest parent */ + parent?: (string|null); + + /** PurgeUserEventsRequest filter */ + filter?: (string|null); + + /** PurgeUserEventsRequest force */ + force?: (boolean|null); + } + + /** Represents a PurgeUserEventsRequest. */ + class PurgeUserEventsRequest implements IPurgeUserEventsRequest { + + /** + * Constructs a new PurgeUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPurgeUserEventsRequest); + + /** PurgeUserEventsRequest parent. */ + public parent: string; + + /** PurgeUserEventsRequest filter. */ + public filter: string; + + /** PurgeUserEventsRequest force. */ + public force: boolean; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPurgeUserEventsRequest): google.cloud.retail.v2beta.PurgeUserEventsRequest; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsRequest.verify|verify} messages. + * @param message PurgeUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPurgeUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2beta.PurgeUserEventsRequest; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsRequest + * @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.cloud.retail.v2beta.PurgeUserEventsRequest; + + /** + * Verifies a PurgeUserEventsRequest 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 PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PurgeUserEventsRequest; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @param message PurgeUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PurgeUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PurgeUserEventsResponse. */ + interface IPurgeUserEventsResponse { + + /** PurgeUserEventsResponse purgedEventsCount */ + purgedEventsCount?: (number|Long|string|null); + } + + /** Represents a PurgeUserEventsResponse. */ + class PurgeUserEventsResponse implements IPurgeUserEventsResponse { + + /** + * Constructs a new PurgeUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IPurgeUserEventsResponse); + + /** PurgeUserEventsResponse purgedEventsCount. */ + public purgedEventsCount: (number|Long|string); + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns PurgeUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IPurgeUserEventsResponse): google.cloud.retail.v2beta.PurgeUserEventsResponse; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsResponse.verify|verify} messages. + * @param message PurgeUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IPurgeUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2beta.PurgeUserEventsResponse; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PurgeUserEventsResponse + * @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.cloud.retail.v2beta.PurgeUserEventsResponse; + + /** + * Verifies a PurgeUserEventsResponse 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 PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PurgeUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.PurgeUserEventsResponse; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @param message PurgeUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.PurgeUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ServingConfig. */ + interface IServingConfig { + + /** ServingConfig name */ + name?: (string|null); + + /** ServingConfig displayName */ + displayName?: (string|null); + + /** ServingConfig modelId */ + modelId?: (string|null); + + /** ServingConfig priceRerankingLevel */ + priceRerankingLevel?: (string|null); + + /** ServingConfig facetControlIds */ + facetControlIds?: (string[]|null); + + /** ServingConfig dynamicFacetSpec */ + dynamicFacetSpec?: (google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds */ + boostControlIds?: (string[]|null); + + /** ServingConfig filterControlIds */ + filterControlIds?: (string[]|null); + + /** ServingConfig redirectControlIds */ + redirectControlIds?: (string[]|null); + + /** ServingConfig twowaySynonymsControlIds */ + twowaySynonymsControlIds?: (string[]|null); + + /** ServingConfig onewaySynonymsControlIds */ + onewaySynonymsControlIds?: (string[]|null); + + /** ServingConfig doNotAssociateControlIds */ + doNotAssociateControlIds?: (string[]|null); + + /** ServingConfig replacementControlIds */ + replacementControlIds?: (string[]|null); + + /** ServingConfig ignoreControlIds */ + ignoreControlIds?: (string[]|null); + + /** ServingConfig diversityLevel */ + diversityLevel?: (string|null); + + /** ServingConfig diversityType */ + diversityType?: (google.cloud.retail.v2beta.ServingConfig.DiversityType|keyof typeof google.cloud.retail.v2beta.ServingConfig.DiversityType|null); + + /** ServingConfig enableCategoryFilterLevel */ + enableCategoryFilterLevel?: (string|null); + + /** ServingConfig personalizationSpec */ + personalizationSpec?: (google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null); + + /** ServingConfig solutionTypes */ + solutionTypes?: (google.cloud.retail.v2beta.SolutionType[]|null); + } + + /** Represents a ServingConfig. */ + class ServingConfig implements IServingConfig { + + /** + * Constructs a new ServingConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IServingConfig); + + /** ServingConfig name. */ + public name: string; + + /** ServingConfig displayName. */ + public displayName: string; + + /** ServingConfig modelId. */ + public modelId: string; + + /** ServingConfig priceRerankingLevel. */ + public priceRerankingLevel: string; + + /** ServingConfig facetControlIds. */ + public facetControlIds: string[]; + + /** ServingConfig dynamicFacetSpec. */ + public dynamicFacetSpec?: (google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null); + + /** ServingConfig boostControlIds. */ + public boostControlIds: string[]; + + /** ServingConfig filterControlIds. */ + public filterControlIds: string[]; + + /** ServingConfig redirectControlIds. */ + public redirectControlIds: string[]; + + /** ServingConfig twowaySynonymsControlIds. */ + public twowaySynonymsControlIds: string[]; + + /** ServingConfig onewaySynonymsControlIds. */ + public onewaySynonymsControlIds: string[]; + + /** ServingConfig doNotAssociateControlIds. */ + public doNotAssociateControlIds: string[]; + + /** ServingConfig replacementControlIds. */ + public replacementControlIds: string[]; + + /** ServingConfig ignoreControlIds. */ + public ignoreControlIds: string[]; + + /** ServingConfig diversityLevel. */ + public diversityLevel: string; + + /** ServingConfig diversityType. */ + public diversityType: (google.cloud.retail.v2beta.ServingConfig.DiversityType|keyof typeof google.cloud.retail.v2beta.ServingConfig.DiversityType); + + /** ServingConfig enableCategoryFilterLevel. */ + public enableCategoryFilterLevel: string; + + /** ServingConfig personalizationSpec. */ + public personalizationSpec?: (google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null); + + /** ServingConfig solutionTypes. */ + public solutionTypes: google.cloud.retail.v2beta.SolutionType[]; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ServingConfig instance + */ + public static create(properties?: google.cloud.retail.v2beta.IServingConfig): google.cloud.retail.v2beta.ServingConfig; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ServingConfig.verify|verify} messages. + * @param message ServingConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IServingConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServingConfig + * @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.cloud.retail.v2beta.ServingConfig; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServingConfig + * @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.cloud.retail.v2beta.ServingConfig; + + /** + * Verifies a ServingConfig 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 ServingConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServingConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ServingConfig; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @param message ServingConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ServingConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServingConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServingConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ServingConfig { + + /** DiversityType enum. */ + enum DiversityType { + DIVERSITY_TYPE_UNSPECIFIED = 0, + RULE_BASED_DIVERSITY = 2, + DATA_DRIVEN_DIVERSITY = 3 + } + } + + /** Represents a ServingConfigService */ + class ServingConfigService extends $protobuf.rpc.Service { + + /** + * Constructs a new ServingConfigService 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 ServingConfigService 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): ServingConfigService; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public createServingConfig(request: google.cloud.retail.v2beta.ICreateServingConfigRequest, callback: google.cloud.retail.v2beta.ServingConfigService.CreateServingConfigCallback): void; + + /** + * Calls CreateServingConfig. + * @param request CreateServingConfigRequest message or plain object + * @returns Promise + */ + public createServingConfig(request: google.cloud.retail.v2beta.ICreateServingConfigRequest): Promise; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteServingConfig(request: google.cloud.retail.v2beta.IDeleteServingConfigRequest, callback: google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfigCallback): void; + + /** + * Calls DeleteServingConfig. + * @param request DeleteServingConfigRequest message or plain object + * @returns Promise + */ + public deleteServingConfig(request: google.cloud.retail.v2beta.IDeleteServingConfigRequest): Promise; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public updateServingConfig(request: google.cloud.retail.v2beta.IUpdateServingConfigRequest, callback: google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfigCallback): void; + + /** + * Calls UpdateServingConfig. + * @param request UpdateServingConfigRequest message or plain object + * @returns Promise + */ + public updateServingConfig(request: google.cloud.retail.v2beta.IUpdateServingConfigRequest): Promise; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public getServingConfig(request: google.cloud.retail.v2beta.IGetServingConfigRequest, callback: google.cloud.retail.v2beta.ServingConfigService.GetServingConfigCallback): void; + + /** + * Calls GetServingConfig. + * @param request GetServingConfigRequest message or plain object + * @returns Promise + */ + public getServingConfig(request: google.cloud.retail.v2beta.IGetServingConfigRequest): Promise; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListServingConfigsResponse + */ + public listServingConfigs(request: google.cloud.retail.v2beta.IListServingConfigsRequest, callback: google.cloud.retail.v2beta.ServingConfigService.ListServingConfigsCallback): void; + + /** + * Calls ListServingConfigs. + * @param request ListServingConfigsRequest message or plain object + * @returns Promise + */ + public listServingConfigs(request: google.cloud.retail.v2beta.IListServingConfigsRequest): Promise; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public addControl(request: google.cloud.retail.v2beta.IAddControlRequest, callback: google.cloud.retail.v2beta.ServingConfigService.AddControlCallback): void; + + /** + * Calls AddControl. + * @param request AddControlRequest message or plain object + * @returns Promise + */ + public addControl(request: google.cloud.retail.v2beta.IAddControlRequest): Promise; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ServingConfig + */ + public removeControl(request: google.cloud.retail.v2beta.IRemoveControlRequest, callback: google.cloud.retail.v2beta.ServingConfigService.RemoveControlCallback): void; + + /** + * Calls RemoveControl. + * @param request RemoveControlRequest message or plain object + * @returns Promise + */ + public removeControl(request: google.cloud.retail.v2beta.IRemoveControlRequest): Promise; + } + + namespace ServingConfigService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|createServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type CreateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|deleteServingConfig}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteServingConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|updateServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type UpdateServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|getServingConfig}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type GetServingConfigCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|listServingConfigs}. + * @param error Error, if any + * @param [response] ListServingConfigsResponse + */ + type ListServingConfigsCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ListServingConfigsResponse) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|addControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type AddControlCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ServingConfig) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|removeControl}. + * @param error Error, if any + * @param [response] ServingConfig + */ + type RemoveControlCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.ServingConfig) => void; + } + + /** Properties of a CreateServingConfigRequest. */ + interface ICreateServingConfigRequest { + + /** CreateServingConfigRequest parent */ + parent?: (string|null); + + /** CreateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2beta.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId */ + servingConfigId?: (string|null); + } + + /** Represents a CreateServingConfigRequest. */ + class CreateServingConfigRequest implements ICreateServingConfigRequest { + + /** + * Constructs a new CreateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICreateServingConfigRequest); + + /** CreateServingConfigRequest parent. */ + public parent: string; + + /** CreateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2beta.IServingConfig|null); + + /** CreateServingConfigRequest servingConfigId. */ + public servingConfigId: string; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICreateServingConfigRequest): google.cloud.retail.v2beta.CreateServingConfigRequest; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateServingConfigRequest.verify|verify} messages. + * @param message CreateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICreateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2beta.CreateServingConfigRequest; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateServingConfigRequest + * @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.cloud.retail.v2beta.CreateServingConfigRequest; + + /** + * Verifies a CreateServingConfigRequest 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 CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CreateServingConfigRequest; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @param message CreateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CreateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateServingConfigRequest. */ + interface IUpdateServingConfigRequest { + + /** UpdateServingConfigRequest servingConfig */ + servingConfig?: (google.cloud.retail.v2beta.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateServingConfigRequest. */ + class UpdateServingConfigRequest implements IUpdateServingConfigRequest { + + /** + * Constructs a new UpdateServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IUpdateServingConfigRequest); + + /** UpdateServingConfigRequest servingConfig. */ + public servingConfig?: (google.cloud.retail.v2beta.IServingConfig|null); + + /** UpdateServingConfigRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IUpdateServingConfigRequest): google.cloud.retail.v2beta.UpdateServingConfigRequest; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateServingConfigRequest.verify|verify} messages. + * @param message UpdateServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IUpdateServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2beta.UpdateServingConfigRequest; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateServingConfigRequest + * @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.cloud.retail.v2beta.UpdateServingConfigRequest; + + /** + * Verifies an UpdateServingConfigRequest 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 UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.UpdateServingConfigRequest; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @param message UpdateServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.UpdateServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteServingConfigRequest. */ + interface IDeleteServingConfigRequest { + + /** DeleteServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a DeleteServingConfigRequest. */ + class DeleteServingConfigRequest implements IDeleteServingConfigRequest { + + /** + * Constructs a new DeleteServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IDeleteServingConfigRequest); + + /** DeleteServingConfigRequest name. */ + public name: string; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IDeleteServingConfigRequest): google.cloud.retail.v2beta.DeleteServingConfigRequest; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteServingConfigRequest.verify|verify} messages. + * @param message DeleteServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IDeleteServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2beta.DeleteServingConfigRequest; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteServingConfigRequest + * @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.cloud.retail.v2beta.DeleteServingConfigRequest; + + /** + * Verifies a DeleteServingConfigRequest 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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.DeleteServingConfigRequest; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @param message DeleteServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.DeleteServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetServingConfigRequest. */ + interface IGetServingConfigRequest { + + /** GetServingConfigRequest name */ + name?: (string|null); + } + + /** Represents a GetServingConfigRequest. */ + class GetServingConfigRequest implements IGetServingConfigRequest { + + /** + * Constructs a new GetServingConfigRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IGetServingConfigRequest); + + /** GetServingConfigRequest name. */ + public name: string; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetServingConfigRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IGetServingConfigRequest): google.cloud.retail.v2beta.GetServingConfigRequest; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetServingConfigRequest.verify|verify} messages. + * @param message GetServingConfigRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IGetServingConfigRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetServingConfigRequest + * @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.cloud.retail.v2beta.GetServingConfigRequest; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetServingConfigRequest + * @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.cloud.retail.v2beta.GetServingConfigRequest; + + /** + * Verifies a GetServingConfigRequest 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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetServingConfigRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.GetServingConfigRequest; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @param message GetServingConfigRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.GetServingConfigRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetServingConfigRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetServingConfigRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsRequest. */ + interface IListServingConfigsRequest { + + /** ListServingConfigsRequest parent */ + parent?: (string|null); + + /** ListServingConfigsRequest pageSize */ + pageSize?: (number|null); + + /** ListServingConfigsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListServingConfigsRequest. */ + class ListServingConfigsRequest implements IListServingConfigsRequest { + + /** + * Constructs a new ListServingConfigsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListServingConfigsRequest); + + /** ListServingConfigsRequest parent. */ + public parent: string; + + /** ListServingConfigsRequest pageSize. */ + public pageSize: number; + + /** ListServingConfigsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListServingConfigsRequest): google.cloud.retail.v2beta.ListServingConfigsRequest; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsRequest.verify|verify} messages. + * @param message ListServingConfigsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListServingConfigsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2beta.ListServingConfigsRequest; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsRequest + * @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.cloud.retail.v2beta.ListServingConfigsRequest; + + /** + * Verifies a ListServingConfigsRequest 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListServingConfigsRequest; + + /** + * Creates a plain object from a ListServingConfigsRequest message. Also converts values to other types if specified. + * @param message ListServingConfigsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListServingConfigsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListServingConfigsResponse. */ + interface IListServingConfigsResponse { + + /** ListServingConfigsResponse servingConfigs */ + servingConfigs?: (google.cloud.retail.v2beta.IServingConfig[]|null); + + /** ListServingConfigsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListServingConfigsResponse. */ + class ListServingConfigsResponse implements IListServingConfigsResponse { + + /** + * Constructs a new ListServingConfigsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IListServingConfigsResponse); + + /** ListServingConfigsResponse servingConfigs. */ + public servingConfigs: google.cloud.retail.v2beta.IServingConfig[]; + + /** ListServingConfigsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListServingConfigsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IListServingConfigsResponse): google.cloud.retail.v2beta.ListServingConfigsResponse; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsResponse.verify|verify} messages. + * @param message ListServingConfigsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IListServingConfigsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2beta.ListServingConfigsResponse; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListServingConfigsResponse + * @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.cloud.retail.v2beta.ListServingConfigsResponse; + + /** + * Verifies a ListServingConfigsResponse 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 ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListServingConfigsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.ListServingConfigsResponse; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @param message ListServingConfigsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.ListServingConfigsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AddControlRequest. */ + interface IAddControlRequest { + + /** AddControlRequest servingConfig */ + servingConfig?: (string|null); + + /** AddControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents an AddControlRequest. */ + class AddControlRequest implements IAddControlRequest { + + /** + * Constructs a new AddControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IAddControlRequest); + + /** AddControlRequest servingConfig. */ + public servingConfig: string; + + /** AddControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AddControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IAddControlRequest): google.cloud.retail.v2beta.AddControlRequest; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddControlRequest.verify|verify} messages. + * @param message AddControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IAddControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AddControlRequest + * @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.cloud.retail.v2beta.AddControlRequest; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AddControlRequest + * @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.cloud.retail.v2beta.AddControlRequest; + + /** + * Verifies an AddControlRequest 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 AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AddControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.AddControlRequest; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @param message AddControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.AddControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AddControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AddControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RemoveControlRequest. */ + interface IRemoveControlRequest { + + /** RemoveControlRequest servingConfig */ + servingConfig?: (string|null); + + /** RemoveControlRequest controlId */ + controlId?: (string|null); + } + + /** Represents a RemoveControlRequest. */ + class RemoveControlRequest implements IRemoveControlRequest { + + /** + * Constructs a new RemoveControlRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRemoveControlRequest); + + /** RemoveControlRequest servingConfig. */ + public servingConfig: string; + + /** RemoveControlRequest controlId. */ + public controlId: string; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RemoveControlRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRemoveControlRequest): google.cloud.retail.v2beta.RemoveControlRequest; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveControlRequest.verify|verify} messages. + * @param message RemoveControlRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRemoveControlRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RemoveControlRequest + * @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.cloud.retail.v2beta.RemoveControlRequest; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RemoveControlRequest + * @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.cloud.retail.v2beta.RemoveControlRequest; + + /** + * Verifies a RemoveControlRequest 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 RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RemoveControlRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RemoveControlRequest; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @param message RemoveControlRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RemoveControlRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RemoveControlRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RemoveControlRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Represents a UserEventService */ + class UserEventService extends $protobuf.rpc.Service { + + /** + * Constructs a new UserEventService 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 UserEventService 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): UserEventService; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and UserEvent + */ + public writeUserEvent(request: google.cloud.retail.v2beta.IWriteUserEventRequest, callback: google.cloud.retail.v2beta.UserEventService.WriteUserEventCallback): void; + + /** + * Calls WriteUserEvent. + * @param request WriteUserEventRequest message or plain object + * @returns Promise + */ + public writeUserEvent(request: google.cloud.retail.v2beta.IWriteUserEventRequest): Promise; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @param callback Node-style callback called with the error, if any, and HttpBody + */ + public collectUserEvent(request: google.cloud.retail.v2beta.ICollectUserEventRequest, callback: google.cloud.retail.v2beta.UserEventService.CollectUserEventCallback): void; + + /** + * Calls CollectUserEvent. + * @param request CollectUserEventRequest message or plain object + * @returns Promise + */ + public collectUserEvent(request: google.cloud.retail.v2beta.ICollectUserEventRequest): Promise; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public purgeUserEvents(request: google.cloud.retail.v2beta.IPurgeUserEventsRequest, callback: google.cloud.retail.v2beta.UserEventService.PurgeUserEventsCallback): void; + + /** + * Calls PurgeUserEvents. + * @param request PurgeUserEventsRequest message or plain object + * @returns Promise + */ + public purgeUserEvents(request: google.cloud.retail.v2beta.IPurgeUserEventsRequest): Promise; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importUserEvents(request: google.cloud.retail.v2beta.IImportUserEventsRequest, callback: google.cloud.retail.v2beta.UserEventService.ImportUserEventsCallback): void; + + /** + * Calls ImportUserEvents. + * @param request ImportUserEventsRequest message or plain object + * @returns Promise + */ + public importUserEvents(request: google.cloud.retail.v2beta.IImportUserEventsRequest): Promise; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public rejoinUserEvents(request: google.cloud.retail.v2beta.IRejoinUserEventsRequest, callback: google.cloud.retail.v2beta.UserEventService.RejoinUserEventsCallback): void; + + /** + * Calls RejoinUserEvents. + * @param request RejoinUserEventsRequest message or plain object + * @returns Promise + */ + public rejoinUserEvents(request: google.cloud.retail.v2beta.IRejoinUserEventsRequest): Promise; + } + + namespace UserEventService { + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|writeUserEvent}. + * @param error Error, if any + * @param [response] UserEvent + */ + type WriteUserEventCallback = (error: (Error|null), response?: google.cloud.retail.v2beta.UserEvent) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|collectUserEvent}. + * @param error Error, if any + * @param [response] HttpBody + */ + type CollectUserEventCallback = (error: (Error|null), response?: google.api.HttpBody) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|purgeUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type PurgeUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|importUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|rejoinUserEvents}. + * @param error Error, if any + * @param [response] Operation + */ + type RejoinUserEventsCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of a WriteUserEventRequest. */ + interface IWriteUserEventRequest { + + /** WriteUserEventRequest parent */ + parent?: (string|null); + + /** WriteUserEventRequest userEvent */ + userEvent?: (google.cloud.retail.v2beta.IUserEvent|null); + } + + /** Represents a WriteUserEventRequest. */ + class WriteUserEventRequest implements IWriteUserEventRequest { + + /** + * Constructs a new WriteUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IWriteUserEventRequest); + + /** WriteUserEventRequest parent. */ + public parent: string; + + /** WriteUserEventRequest userEvent. */ + public userEvent?: (google.cloud.retail.v2beta.IUserEvent|null); + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns WriteUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IWriteUserEventRequest): google.cloud.retail.v2beta.WriteUserEventRequest; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2beta.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.WriteUserEventRequest.verify|verify} messages. + * @param message WriteUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IWriteUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WriteUserEventRequest + * @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.cloud.retail.v2beta.WriteUserEventRequest; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WriteUserEventRequest + * @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.cloud.retail.v2beta.WriteUserEventRequest; + + /** + * Verifies a WriteUserEventRequest 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 WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WriteUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.WriteUserEventRequest; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @param message WriteUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.WriteUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WriteUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CollectUserEventRequest. */ + interface ICollectUserEventRequest { + + /** CollectUserEventRequest parent */ + parent?: (string|null); + + /** CollectUserEventRequest userEvent */ + userEvent?: (string|null); + + /** CollectUserEventRequest uri */ + uri?: (string|null); + + /** CollectUserEventRequest ets */ + ets?: (number|Long|string|null); + } + + /** Represents a CollectUserEventRequest. */ + class CollectUserEventRequest implements ICollectUserEventRequest { + + /** + * Constructs a new CollectUserEventRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.ICollectUserEventRequest); + + /** CollectUserEventRequest parent. */ + public parent: string; + + /** CollectUserEventRequest userEvent. */ + public userEvent: string; + + /** CollectUserEventRequest uri. */ + public uri: string; + + /** CollectUserEventRequest ets. */ + public ets: (number|Long|string); + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CollectUserEventRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.ICollectUserEventRequest): google.cloud.retail.v2beta.CollectUserEventRequest; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CollectUserEventRequest.verify|verify} messages. + * @param message CollectUserEventRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.ICollectUserEventRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CollectUserEventRequest + * @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.cloud.retail.v2beta.CollectUserEventRequest; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CollectUserEventRequest + * @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.cloud.retail.v2beta.CollectUserEventRequest; + + /** + * Verifies a CollectUserEventRequest 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 CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CollectUserEventRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.CollectUserEventRequest; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @param message CollectUserEventRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.CollectUserEventRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CollectUserEventRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsRequest. */ + interface IRejoinUserEventsRequest { + + /** RejoinUserEventsRequest parent */ + parent?: (string|null); + + /** RejoinUserEventsRequest userEventRejoinScope */ + userEventRejoinScope?: (google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope|null); + } + + /** Represents a RejoinUserEventsRequest. */ + class RejoinUserEventsRequest implements IRejoinUserEventsRequest { + + /** + * Constructs a new RejoinUserEventsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRejoinUserEventsRequest); + + /** RejoinUserEventsRequest parent. */ + public parent: string; + + /** RejoinUserEventsRequest userEventRejoinScope. */ + public userEventRejoinScope: (google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope|keyof typeof google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope); + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsRequest instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRejoinUserEventsRequest): google.cloud.retail.v2beta.RejoinUserEventsRequest; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsRequest.verify|verify} messages. + * @param message RejoinUserEventsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRejoinUserEventsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2beta.RejoinUserEventsRequest; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsRequest + * @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.cloud.retail.v2beta.RejoinUserEventsRequest; + + /** + * Verifies a RejoinUserEventsRequest 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 RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RejoinUserEventsRequest; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @param message RejoinUserEventsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RejoinUserEventsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace RejoinUserEventsRequest { + + /** UserEventRejoinScope enum. */ + enum UserEventRejoinScope { + USER_EVENT_REJOIN_SCOPE_UNSPECIFIED = 0, + JOINED_EVENTS = 1, + UNJOINED_EVENTS = 2 + } + } + + /** Properties of a RejoinUserEventsResponse. */ + interface IRejoinUserEventsResponse { + + /** RejoinUserEventsResponse rejoinedUserEventsCount */ + rejoinedUserEventsCount?: (number|Long|string|null); + } + + /** Represents a RejoinUserEventsResponse. */ + class RejoinUserEventsResponse implements IRejoinUserEventsResponse { + + /** + * Constructs a new RejoinUserEventsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRejoinUserEventsResponse); + + /** RejoinUserEventsResponse rejoinedUserEventsCount. */ + public rejoinedUserEventsCount: (number|Long|string); + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsResponse instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRejoinUserEventsResponse): google.cloud.retail.v2beta.RejoinUserEventsResponse; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsResponse.verify|verify} messages. + * @param message RejoinUserEventsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRejoinUserEventsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2beta.RejoinUserEventsResponse; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsResponse + * @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.cloud.retail.v2beta.RejoinUserEventsResponse; + + /** + * Verifies a RejoinUserEventsResponse 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 RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RejoinUserEventsResponse; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @param message RejoinUserEventsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RejoinUserEventsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RejoinUserEventsMetadata. */ + interface IRejoinUserEventsMetadata { + } + + /** Represents a RejoinUserEventsMetadata. */ + class RejoinUserEventsMetadata implements IRejoinUserEventsMetadata { + + /** + * Constructs a new RejoinUserEventsMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.retail.v2beta.IRejoinUserEventsMetadata); + + /** + * Creates a new RejoinUserEventsMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RejoinUserEventsMetadata instance + */ + public static create(properties?: google.cloud.retail.v2beta.IRejoinUserEventsMetadata): google.cloud.retail.v2beta.RejoinUserEventsMetadata; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.retail.v2beta.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsMetadata.verify|verify} messages. + * @param message RejoinUserEventsMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.retail.v2beta.IRejoinUserEventsMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2beta.RejoinUserEventsMetadata; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RejoinUserEventsMetadata + * @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.cloud.retail.v2beta.RejoinUserEventsMetadata; + + /** + * Verifies a RejoinUserEventsMetadata 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 RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RejoinUserEventsMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.retail.v2beta.RejoinUserEventsMetadata; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @param message RejoinUserEventsMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.retail.v2beta.RejoinUserEventsMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + } + } + + /** Namespace api. */ + namespace api { + + /** 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 + } + + /** Properties of a ResourceDescriptor. */ + interface IResourceDescriptor { + + /** ResourceDescriptor type */ + type?: (string|null); + + /** ResourceDescriptor pattern */ + pattern?: (string[]|null); + + /** ResourceDescriptor nameField */ + nameField?: (string|null); + + /** ResourceDescriptor history */ + history?: (google.api.ResourceDescriptor.History|keyof typeof google.api.ResourceDescriptor.History|null); + + /** ResourceDescriptor plural */ + plural?: (string|null); + + /** ResourceDescriptor singular */ + singular?: (string|null); + + /** ResourceDescriptor style */ + style?: (google.api.ResourceDescriptor.Style[]|null); + } + + /** Represents a ResourceDescriptor. */ + class ResourceDescriptor implements IResourceDescriptor { + + /** + * Constructs a new ResourceDescriptor. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceDescriptor); + + /** ResourceDescriptor type. */ + public type: string; + + /** ResourceDescriptor pattern. */ + public pattern: string[]; + + /** ResourceDescriptor nameField. */ + public nameField: string; + + /** ResourceDescriptor history. */ + public history: (google.api.ResourceDescriptor.History|keyof typeof google.api.ResourceDescriptor.History); + + /** ResourceDescriptor plural. */ + public plural: string; + + /** ResourceDescriptor singular. */ + public singular: string; + + /** ResourceDescriptor style. */ + public style: google.api.ResourceDescriptor.Style[]; + + /** + * Creates a new ResourceDescriptor instance using the specified properties. + * @param [properties] Properties to set + * @returns ResourceDescriptor instance + */ + public static create(properties?: google.api.IResourceDescriptor): google.api.ResourceDescriptor; + + /** + * Encodes the specified ResourceDescriptor message. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @param message ResourceDescriptor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IResourceDescriptor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ResourceDescriptor message, length delimited. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @param message ResourceDescriptor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IResourceDescriptor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ResourceDescriptor + * @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.ResourceDescriptor; + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ResourceDescriptor + * @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.ResourceDescriptor; + + /** + * Verifies a ResourceDescriptor 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 ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceDescriptor + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceDescriptor; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @param message ResourceDescriptor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceDescriptor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceDescriptor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResourceDescriptor + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ResourceDescriptor { + + /** History enum. */ + enum History { + HISTORY_UNSPECIFIED = 0, + ORIGINALLY_SINGLE_PATTERN = 1, + FUTURE_MULTI_PATTERN = 2 + } + + /** Style enum. */ + enum Style { + STYLE_UNSPECIFIED = 0, + DECLARATIVE_FRIENDLY = 1 + } + } + + /** Properties of a ResourceReference. */ + interface IResourceReference { + + /** ResourceReference type */ + type?: (string|null); + + /** ResourceReference childType */ + childType?: (string|null); + } + + /** Represents a ResourceReference. */ + class ResourceReference implements IResourceReference { + + /** + * Constructs a new ResourceReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IResourceReference); + + /** ResourceReference type. */ + public type: string; + + /** ResourceReference childType. */ + public childType: string; + + /** + * Creates a new ResourceReference instance using the specified properties. + * @param [properties] Properties to set + * @returns ResourceReference instance + */ + public static create(properties?: google.api.IResourceReference): google.api.ResourceReference; + + /** + * Encodes the specified ResourceReference message. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @param message ResourceReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IResourceReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ResourceReference message, length delimited. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @param message ResourceReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IResourceReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ResourceReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ResourceReference + * @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.ResourceReference; + + /** + * Decodes a ResourceReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ResourceReference + * @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.ResourceReference; + + /** + * Verifies a ResourceReference 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 ResourceReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ResourceReference + */ + public static fromObject(object: { [k: string]: any }): google.api.ResourceReference; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @param message ResourceReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ResourceReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ResourceReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ResourceReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** 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 HttpBody. */ + interface IHttpBody { + + /** HttpBody contentType */ + contentType?: (string|null); + + /** HttpBody data */ + data?: (Uint8Array|string|null); + + /** HttpBody extensions */ + extensions?: (google.protobuf.IAny[]|null); + } + + /** Represents a HttpBody. */ + class HttpBody implements IHttpBody { + + /** + * Constructs a new HttpBody. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpBody); + + /** HttpBody contentType. */ + public contentType: string; + + /** HttpBody data. */ + public data: (Uint8Array|string); + + /** HttpBody extensions. */ + public extensions: google.protobuf.IAny[]; + + /** + * Creates a new HttpBody instance using the specified properties. + * @param [properties] Properties to set + * @returns HttpBody instance + */ + public static create(properties?: google.api.IHttpBody): google.api.HttpBody; + + /** + * Encodes the specified HttpBody message. Does not implicitly {@link google.api.HttpBody.verify|verify} messages. + * @param message HttpBody message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IHttpBody, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HttpBody message, length delimited. Does not implicitly {@link google.api.HttpBody.verify|verify} messages. + * @param message HttpBody message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IHttpBody, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HttpBody message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HttpBody + * @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.HttpBody; + + /** + * Decodes a HttpBody message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HttpBody + * @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.HttpBody; + + /** + * Verifies a HttpBody 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 HttpBody message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpBody + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpBody; + + /** + * Creates a plain object from a HttpBody message. Also converts values to other types if specified. + * @param message HttpBody + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpBody, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpBody to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for HttpBody + * @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; + } + + /** 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 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?: (string|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 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: string; + + /** + * 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); + } + + /** 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[]; + + /** + * 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); + } + + /** 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[]; + + /** + * 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; + } + + /** 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_REQUIRED = 2, + LABEL_REPEATED = 3 + } + } + + /** 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); + } + + /** 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[]; + + /** + * 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 phpGenericServices */ + phpGenericServices?: (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 uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FileOptions .google.api.resourceDefinition */ + ".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|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 phpGenericServices. */ + public phpGenericServices: 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 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 uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MessageOptions .google.api.resource */ + ".google.api.resource"?: (google.api.IResourceDescriptor|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 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 uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + + /** FieldOptions .google.api.resourceReference */ + ".google.api.resourceReference"?: (google.api.IResourceReference|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 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 + } + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** 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 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 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 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 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 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 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); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** 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 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); + } + + /** 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 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|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|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 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 + } + } + } + + /** 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 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 a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + + /** + * Creates a new FieldMask instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldMask instance + */ + public static create(properties?: google.protobuf.IFieldMask): google.protobuf.FieldMask; + + /** + * Encodes the specified FieldMask message. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @param message FieldMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldMask message, length delimited. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @param message FieldMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldMask message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldMask + * @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.FieldMask; + + /** + * Decodes a FieldMask message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldMask + * @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.FieldMask; + + /** + * Verifies a FieldMask 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 FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FieldMask + * @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|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|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; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|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|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 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; + } + } + + /** 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 Date. */ + interface IDate { + + /** Date year */ + year?: (number|null); + + /** Date month */ + month?: (number|null); + + /** Date day */ + day?: (number|null); + } + + /** Represents a Date. */ + class Date implements IDate { + + /** + * Constructs a new Date. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.IDate); + + /** Date year. */ + public year: number; + + /** Date month. */ + public month: number; + + /** Date day. */ + public day: number; + + /** + * Creates a new Date instance using the specified properties. + * @param [properties] Properties to set + * @returns Date instance + */ + public static create(properties?: google.type.IDate): google.type.Date; + + /** + * Encodes the specified Date message. Does not implicitly {@link google.type.Date.verify|verify} messages. + * @param message Date message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.type.IDate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Date message, length delimited. Does not implicitly {@link google.type.Date.verify|verify} messages. + * @param message Date message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.type.IDate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Date message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Date + * @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.Date; + + /** + * Decodes a Date message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Date + * @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.Date; + + /** + * Verifies a Date 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 Date message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Date + */ + public static fromObject(object: { [k: string]: any }): google.type.Date; + + /** + * Creates a plain object from a Date message. Also converts values to other types if specified. + * @param message Date + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.Date, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Date to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Date + * @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; + } + } +} diff --git a/packages/google-cloud-retail/protos/protos.js b/packages/google-cloud-retail/protos/protos.js new file mode 100644 index 00000000000..b8840714673 --- /dev/null +++ b/packages/google-cloud-retail/protos/protos.js @@ -0,0 +1,147500 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*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_retail_protos || ($protobuf.roots._google_cloud_retail_protos = {}); + + $root.google = (function() { + + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {}; + + google.cloud = (function() { + + /** + * Namespace cloud. + * @memberof google + * @namespace + */ + var cloud = {}; + + cloud.retail = (function() { + + /** + * Namespace retail. + * @memberof google.cloud + * @namespace + */ + var retail = {}; + + retail.v2 = (function() { + + /** + * Namespace v2. + * @memberof google.cloud.retail + * @namespace + */ + var v2 = {}; + + v2.ProductLevelConfig = (function() { + + /** + * Properties of a ProductLevelConfig. + * @memberof google.cloud.retail.v2 + * @interface IProductLevelConfig + * @property {string|null} [ingestionProductType] ProductLevelConfig ingestionProductType + * @property {string|null} [merchantCenterProductIdField] ProductLevelConfig merchantCenterProductIdField + */ + + /** + * Constructs a new ProductLevelConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ProductLevelConfig. + * @implements IProductLevelConfig + * @constructor + * @param {google.cloud.retail.v2.IProductLevelConfig=} [properties] Properties to set + */ + function ProductLevelConfig(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]]; + } + + /** + * ProductLevelConfig ingestionProductType. + * @member {string} ingestionProductType + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.ingestionProductType = ""; + + /** + * ProductLevelConfig merchantCenterProductIdField. + * @member {string} merchantCenterProductIdField + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.merchantCenterProductIdField = ""; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2.IProductLevelConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ProductLevelConfig} ProductLevelConfig instance + */ + ProductLevelConfig.create = function create(properties) { + return new ProductLevelConfig(properties); + }; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2.ProductLevelConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ingestionProductType != null && Object.hasOwnProperty.call(message, "ingestionProductType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ingestionProductType); + if (message.merchantCenterProductIdField != null && Object.hasOwnProperty.call(message, "merchantCenterProductIdField")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.merchantCenterProductIdField); + return writer; + }; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductLevelConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.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.cloud.retail.v2.ProductLevelConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ingestionProductType = reader.string(); + break; + } + case 2: { + message.merchantCenterProductIdField = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductLevelConfig message. + * @function verify + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductLevelConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + if (!$util.isString(message.ingestionProductType)) + return "ingestionProductType: string expected"; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + if (!$util.isString(message.merchantCenterProductIdField)) + return "merchantCenterProductIdField: string expected"; + return null; + }; + + /** + * Creates a ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ProductLevelConfig} ProductLevelConfig + */ + ProductLevelConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ProductLevelConfig) + return object; + var message = new $root.google.cloud.retail.v2.ProductLevelConfig(); + if (object.ingestionProductType != null) + message.ingestionProductType = String(object.ingestionProductType); + if (object.merchantCenterProductIdField != null) + message.merchantCenterProductIdField = String(object.merchantCenterProductIdField); + return message; + }; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2.ProductLevelConfig} message ProductLevelConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductLevelConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ingestionProductType = ""; + object.merchantCenterProductIdField = ""; + } + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + object.ingestionProductType = message.ingestionProductType; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + object.merchantCenterProductIdField = message.merchantCenterProductIdField; + return object; + }; + + /** + * Converts this ProductLevelConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @instance + * @returns {Object.} JSON object + */ + ProductLevelConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductLevelConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ProductLevelConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductLevelConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ProductLevelConfig"; + }; + + return ProductLevelConfig; + })(); + + v2.CatalogAttribute = (function() { + + /** + * Properties of a CatalogAttribute. + * @memberof google.cloud.retail.v2 + * @interface ICatalogAttribute + * @property {string|null} [key] CatalogAttribute key + * @property {boolean|null} [inUse] CatalogAttribute inUse + * @property {google.cloud.retail.v2.CatalogAttribute.AttributeType|null} [type] CatalogAttribute type + * @property {google.cloud.retail.v2.CatalogAttribute.IndexableOption|null} [indexableOption] CatalogAttribute indexableOption + * @property {google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption|null} [dynamicFacetableOption] CatalogAttribute dynamicFacetableOption + * @property {google.cloud.retail.v2.CatalogAttribute.SearchableOption|null} [searchableOption] CatalogAttribute searchableOption + */ + + /** + * Constructs a new CatalogAttribute. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CatalogAttribute. + * @implements ICatalogAttribute + * @constructor + * @param {google.cloud.retail.v2.ICatalogAttribute=} [properties] Properties to set + */ + function CatalogAttribute(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]]; + } + + /** + * CatalogAttribute key. + * @member {string} key + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.key = ""; + + /** + * CatalogAttribute inUse. + * @member {boolean} inUse + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.inUse = false; + + /** + * CatalogAttribute type. + * @member {google.cloud.retail.v2.CatalogAttribute.AttributeType} type + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.type = 0; + + /** + * CatalogAttribute indexableOption. + * @member {google.cloud.retail.v2.CatalogAttribute.IndexableOption} indexableOption + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.indexableOption = 0; + + /** + * CatalogAttribute dynamicFacetableOption. + * @member {google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption} dynamicFacetableOption + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.dynamicFacetableOption = 0; + + /** + * CatalogAttribute searchableOption. + * @member {google.cloud.retail.v2.CatalogAttribute.SearchableOption} searchableOption + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.searchableOption = 0; + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {google.cloud.retail.v2.ICatalogAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CatalogAttribute} CatalogAttribute instance + */ + CatalogAttribute.create = function create(properties) { + return new CatalogAttribute(properties); + }; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2.CatalogAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {google.cloud.retail.v2.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.indexableOption != null && Object.hasOwnProperty.call(message, "indexableOption")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.indexableOption); + if (message.dynamicFacetableOption != null && Object.hasOwnProperty.call(message, "dynamicFacetableOption")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.dynamicFacetableOption); + if (message.searchableOption != null && Object.hasOwnProperty.call(message, "searchableOption")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.searchableOption); + if (message.inUse != null && Object.hasOwnProperty.call(message, "inUse")) + writer.uint32(/* id 9, wireType 0 =*/72).bool(message.inUse); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.type); + return writer; + }; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CatalogAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {google.cloud.retail.v2.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.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.cloud.retail.v2.CatalogAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 9: { + message.inUse = reader.bool(); + break; + } + case 10: { + message.type = reader.int32(); + break; + } + case 5: { + message.indexableOption = reader.int32(); + break; + } + case 6: { + message.dynamicFacetableOption = reader.int32(); + break; + } + case 7: { + message.searchableOption = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CatalogAttribute message. + * @function verify + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CatalogAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.inUse != null && message.hasOwnProperty("inUse")) + if (typeof message.inUse !== "boolean") + return "inUse: boolean expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + switch (message.indexableOption) { + default: + return "indexableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + switch (message.dynamicFacetableOption) { + default: + return "dynamicFacetableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + switch (message.searchableOption) { + default: + return "searchableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CatalogAttribute} CatalogAttribute + */ + CatalogAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CatalogAttribute) + return object; + var message = new $root.google.cloud.retail.v2.CatalogAttribute(); + if (object.key != null) + message.key = String(object.key); + if (object.inUse != null) + message.inUse = Boolean(object.inUse); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "UNKNOWN": + case 0: + message.type = 0; + break; + case "TEXTUAL": + case 1: + message.type = 1; + break; + case "NUMERICAL": + case 2: + message.type = 2; + break; + } + switch (object.indexableOption) { + default: + if (typeof object.indexableOption === "number") { + message.indexableOption = object.indexableOption; + break; + } + break; + case "INDEXABLE_OPTION_UNSPECIFIED": + case 0: + message.indexableOption = 0; + break; + case "INDEXABLE_ENABLED": + case 1: + message.indexableOption = 1; + break; + case "INDEXABLE_DISABLED": + case 2: + message.indexableOption = 2; + break; + } + switch (object.dynamicFacetableOption) { + default: + if (typeof object.dynamicFacetableOption === "number") { + message.dynamicFacetableOption = object.dynamicFacetableOption; + break; + } + break; + case "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": + case 0: + message.dynamicFacetableOption = 0; + break; + case "DYNAMIC_FACETABLE_ENABLED": + case 1: + message.dynamicFacetableOption = 1; + break; + case "DYNAMIC_FACETABLE_DISABLED": + case 2: + message.dynamicFacetableOption = 2; + break; + } + switch (object.searchableOption) { + default: + if (typeof object.searchableOption === "number") { + message.searchableOption = object.searchableOption; + break; + } + break; + case "SEARCHABLE_OPTION_UNSPECIFIED": + case 0: + message.searchableOption = 0; + break; + case "SEARCHABLE_ENABLED": + case 1: + message.searchableOption = 1; + break; + case "SEARCHABLE_DISABLED": + case 2: + message.searchableOption = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {google.cloud.retail.v2.CatalogAttribute} message CatalogAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CatalogAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.key = ""; + object.indexableOption = options.enums === String ? "INDEXABLE_OPTION_UNSPECIFIED" : 0; + object.dynamicFacetableOption = options.enums === String ? "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED" : 0; + object.searchableOption = options.enums === String ? "SEARCHABLE_OPTION_UNSPECIFIED" : 0; + object.inUse = false; + object.type = options.enums === String ? "UNKNOWN" : 0; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + object.indexableOption = options.enums === String ? $root.google.cloud.retail.v2.CatalogAttribute.IndexableOption[message.indexableOption] === undefined ? message.indexableOption : $root.google.cloud.retail.v2.CatalogAttribute.IndexableOption[message.indexableOption] : message.indexableOption; + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + object.dynamicFacetableOption = options.enums === String ? $root.google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] === undefined ? message.dynamicFacetableOption : $root.google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] : message.dynamicFacetableOption; + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + object.searchableOption = options.enums === String ? $root.google.cloud.retail.v2.CatalogAttribute.SearchableOption[message.searchableOption] === undefined ? message.searchableOption : $root.google.cloud.retail.v2.CatalogAttribute.SearchableOption[message.searchableOption] : message.searchableOption; + if (message.inUse != null && message.hasOwnProperty("inUse")) + object.inUse = message.inUse; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2.CatalogAttribute.AttributeType[message.type] === undefined ? message.type : $root.google.cloud.retail.v2.CatalogAttribute.AttributeType[message.type] : message.type; + return object; + }; + + /** + * Converts this CatalogAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CatalogAttribute + * @instance + * @returns {Object.} JSON object + */ + CatalogAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CatalogAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CatalogAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CatalogAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CatalogAttribute"; + }; + + /** + * AttributeType enum. + * @name google.cloud.retail.v2.CatalogAttribute.AttributeType + * @enum {number} + * @property {number} UNKNOWN=0 UNKNOWN value + * @property {number} TEXTUAL=1 TEXTUAL value + * @property {number} NUMERICAL=2 NUMERICAL value + */ + CatalogAttribute.AttributeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN"] = 0; + values[valuesById[1] = "TEXTUAL"] = 1; + values[valuesById[2] = "NUMERICAL"] = 2; + return values; + })(); + + /** + * IndexableOption enum. + * @name google.cloud.retail.v2.CatalogAttribute.IndexableOption + * @enum {number} + * @property {number} INDEXABLE_OPTION_UNSPECIFIED=0 INDEXABLE_OPTION_UNSPECIFIED value + * @property {number} INDEXABLE_ENABLED=1 INDEXABLE_ENABLED value + * @property {number} INDEXABLE_DISABLED=2 INDEXABLE_DISABLED value + */ + CatalogAttribute.IndexableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "INDEXABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "INDEXABLE_ENABLED"] = 1; + values[valuesById[2] = "INDEXABLE_DISABLED"] = 2; + return values; + })(); + + /** + * DynamicFacetableOption enum. + * @name google.cloud.retail.v2.CatalogAttribute.DynamicFacetableOption + * @enum {number} + * @property {number} DYNAMIC_FACETABLE_OPTION_UNSPECIFIED=0 DYNAMIC_FACETABLE_OPTION_UNSPECIFIED value + * @property {number} DYNAMIC_FACETABLE_ENABLED=1 DYNAMIC_FACETABLE_ENABLED value + * @property {number} DYNAMIC_FACETABLE_DISABLED=2 DYNAMIC_FACETABLE_DISABLED value + */ + CatalogAttribute.DynamicFacetableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DYNAMIC_FACETABLE_ENABLED"] = 1; + values[valuesById[2] = "DYNAMIC_FACETABLE_DISABLED"] = 2; + return values; + })(); + + /** + * SearchableOption enum. + * @name google.cloud.retail.v2.CatalogAttribute.SearchableOption + * @enum {number} + * @property {number} SEARCHABLE_OPTION_UNSPECIFIED=0 SEARCHABLE_OPTION_UNSPECIFIED value + * @property {number} SEARCHABLE_ENABLED=1 SEARCHABLE_ENABLED value + * @property {number} SEARCHABLE_DISABLED=2 SEARCHABLE_DISABLED value + */ + CatalogAttribute.SearchableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCHABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCHABLE_ENABLED"] = 1; + values[valuesById[2] = "SEARCHABLE_DISABLED"] = 2; + return values; + })(); + + return CatalogAttribute; + })(); + + v2.AttributesConfig = (function() { + + /** + * Properties of an AttributesConfig. + * @memberof google.cloud.retail.v2 + * @interface IAttributesConfig + * @property {string|null} [name] AttributesConfig name + * @property {Object.|null} [catalogAttributes] AttributesConfig catalogAttributes + * @property {google.cloud.retail.v2.AttributeConfigLevel|null} [attributeConfigLevel] AttributesConfig attributeConfigLevel + */ + + /** + * Constructs a new AttributesConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AttributesConfig. + * @implements IAttributesConfig + * @constructor + * @param {google.cloud.retail.v2.IAttributesConfig=} [properties] Properties to set + */ + function AttributesConfig(properties) { + this.catalogAttributes = {}; + 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]]; + } + + /** + * AttributesConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2.AttributesConfig + * @instance + */ + AttributesConfig.prototype.name = ""; + + /** + * AttributesConfig catalogAttributes. + * @member {Object.} catalogAttributes + * @memberof google.cloud.retail.v2.AttributesConfig + * @instance + */ + AttributesConfig.prototype.catalogAttributes = $util.emptyObject; + + /** + * AttributesConfig attributeConfigLevel. + * @member {google.cloud.retail.v2.AttributeConfigLevel} attributeConfigLevel + * @memberof google.cloud.retail.v2.AttributesConfig + * @instance + */ + AttributesConfig.prototype.attributeConfigLevel = 0; + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {google.cloud.retail.v2.IAttributesConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AttributesConfig} AttributesConfig instance + */ + AttributesConfig.create = function create(properties) { + return new AttributesConfig(properties); + }; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2.AttributesConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {google.cloud.retail.v2.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.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.catalogAttributes != null && Object.hasOwnProperty.call(message, "catalogAttributes")) + for (var keys = Object.keys(message.catalogAttributes), 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.cloud.retail.v2.CatalogAttribute.encode(message.catalogAttributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.attributeConfigLevel != null && Object.hasOwnProperty.call(message, "attributeConfigLevel")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.attributeConfigLevel); + return writer; + }; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AttributesConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {google.cloud.retail.v2.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.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.cloud.retail.v2.AttributesConfig(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (message.catalogAttributes === $util.emptyObject) + message.catalogAttributes = {}; + 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.cloud.retail.v2.CatalogAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.catalogAttributes[key] = value; + break; + } + case 3: { + message.attributeConfigLevel = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AttributesConfig message. + * @function verify + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AttributesConfig.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.catalogAttributes != null && message.hasOwnProperty("catalogAttributes")) { + if (!$util.isObject(message.catalogAttributes)) + return "catalogAttributes: object expected"; + var key = Object.keys(message.catalogAttributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2.CatalogAttribute.verify(message.catalogAttributes[key[i]]); + if (error) + return "catalogAttributes." + error; + } + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + switch (message.attributeConfigLevel) { + default: + return "attributeConfigLevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AttributesConfig} AttributesConfig + */ + AttributesConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AttributesConfig) + return object; + var message = new $root.google.cloud.retail.v2.AttributesConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.catalogAttributes) { + if (typeof object.catalogAttributes !== "object") + throw TypeError(".google.cloud.retail.v2.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes = {}; + for (var keys = Object.keys(object.catalogAttributes), i = 0; i < keys.length; ++i) { + if (typeof object.catalogAttributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes[keys[i]] = $root.google.cloud.retail.v2.CatalogAttribute.fromObject(object.catalogAttributes[keys[i]]); + } + } + switch (object.attributeConfigLevel) { + default: + if (typeof object.attributeConfigLevel === "number") { + message.attributeConfigLevel = object.attributeConfigLevel; + break; + } + break; + case "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": + case 0: + message.attributeConfigLevel = 0; + break; + case "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": + case 1: + message.attributeConfigLevel = 1; + break; + case "CATALOG_LEVEL_ATTRIBUTE_CONFIG": + case 2: + message.attributeConfigLevel = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {google.cloud.retail.v2.AttributesConfig} message AttributesConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AttributesConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.catalogAttributes = {}; + if (options.defaults) { + object.name = ""; + object.attributeConfigLevel = options.enums === String ? "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + var keys2; + if (message.catalogAttributes && (keys2 = Object.keys(message.catalogAttributes)).length) { + object.catalogAttributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.catalogAttributes[keys2[j]] = $root.google.cloud.retail.v2.CatalogAttribute.toObject(message.catalogAttributes[keys2[j]], options); + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + object.attributeConfigLevel = options.enums === String ? $root.google.cloud.retail.v2.AttributeConfigLevel[message.attributeConfigLevel] === undefined ? message.attributeConfigLevel : $root.google.cloud.retail.v2.AttributeConfigLevel[message.attributeConfigLevel] : message.attributeConfigLevel; + return object; + }; + + /** + * Converts this AttributesConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AttributesConfig + * @instance + * @returns {Object.} JSON object + */ + AttributesConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AttributesConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AttributesConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AttributesConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AttributesConfig"; + }; + + return AttributesConfig; + })(); + + v2.CompletionConfig = (function() { + + /** + * Properties of a CompletionConfig. + * @memberof google.cloud.retail.v2 + * @interface ICompletionConfig + * @property {string|null} [name] CompletionConfig name + * @property {string|null} [matchingOrder] CompletionConfig matchingOrder + * @property {number|null} [maxSuggestions] CompletionConfig maxSuggestions + * @property {number|null} [minPrefixLength] CompletionConfig minPrefixLength + * @property {boolean|null} [autoLearning] CompletionConfig autoLearning + * @property {google.cloud.retail.v2.ICompletionDataInputConfig|null} [suggestionsInputConfig] CompletionConfig suggestionsInputConfig + * @property {string|null} [lastSuggestionsImportOperation] CompletionConfig lastSuggestionsImportOperation + * @property {google.cloud.retail.v2.ICompletionDataInputConfig|null} [denylistInputConfig] CompletionConfig denylistInputConfig + * @property {string|null} [lastDenylistImportOperation] CompletionConfig lastDenylistImportOperation + * @property {google.cloud.retail.v2.ICompletionDataInputConfig|null} [allowlistInputConfig] CompletionConfig allowlistInputConfig + * @property {string|null} [lastAllowlistImportOperation] CompletionConfig lastAllowlistImportOperation + */ + + /** + * Constructs a new CompletionConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompletionConfig. + * @implements ICompletionConfig + * @constructor + * @param {google.cloud.retail.v2.ICompletionConfig=} [properties] Properties to set + */ + function CompletionConfig(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]]; + } + + /** + * CompletionConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.name = ""; + + /** + * CompletionConfig matchingOrder. + * @member {string} matchingOrder + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.matchingOrder = ""; + + /** + * CompletionConfig maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.maxSuggestions = 0; + + /** + * CompletionConfig minPrefixLength. + * @member {number} minPrefixLength + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.minPrefixLength = 0; + + /** + * CompletionConfig autoLearning. + * @member {boolean} autoLearning + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.autoLearning = false; + + /** + * CompletionConfig suggestionsInputConfig. + * @member {google.cloud.retail.v2.ICompletionDataInputConfig|null|undefined} suggestionsInputConfig + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.suggestionsInputConfig = null; + + /** + * CompletionConfig lastSuggestionsImportOperation. + * @member {string} lastSuggestionsImportOperation + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastSuggestionsImportOperation = ""; + + /** + * CompletionConfig denylistInputConfig. + * @member {google.cloud.retail.v2.ICompletionDataInputConfig|null|undefined} denylistInputConfig + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.denylistInputConfig = null; + + /** + * CompletionConfig lastDenylistImportOperation. + * @member {string} lastDenylistImportOperation + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastDenylistImportOperation = ""; + + /** + * CompletionConfig allowlistInputConfig. + * @member {google.cloud.retail.v2.ICompletionDataInputConfig|null|undefined} allowlistInputConfig + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.allowlistInputConfig = null; + + /** + * CompletionConfig lastAllowlistImportOperation. + * @member {string} lastAllowlistImportOperation + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastAllowlistImportOperation = ""; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {google.cloud.retail.v2.ICompletionConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompletionConfig} CompletionConfig instance + */ + CompletionConfig.create = function create(properties) { + return new CompletionConfig(properties); + }; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2.CompletionConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {google.cloud.retail.v2.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.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.matchingOrder != null && Object.hasOwnProperty.call(message, "matchingOrder")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.matchingOrder); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.maxSuggestions); + if (message.minPrefixLength != null && Object.hasOwnProperty.call(message, "minPrefixLength")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.minPrefixLength); + if (message.suggestionsInputConfig != null && Object.hasOwnProperty.call(message, "suggestionsInputConfig")) + $root.google.cloud.retail.v2.CompletionDataInputConfig.encode(message.suggestionsInputConfig, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.lastSuggestionsImportOperation != null && Object.hasOwnProperty.call(message, "lastSuggestionsImportOperation")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.lastSuggestionsImportOperation); + if (message.denylistInputConfig != null && Object.hasOwnProperty.call(message, "denylistInputConfig")) + $root.google.cloud.retail.v2.CompletionDataInputConfig.encode(message.denylistInputConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.lastDenylistImportOperation != null && Object.hasOwnProperty.call(message, "lastDenylistImportOperation")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.lastDenylistImportOperation); + if (message.allowlistInputConfig != null && Object.hasOwnProperty.call(message, "allowlistInputConfig")) + $root.google.cloud.retail.v2.CompletionDataInputConfig.encode(message.allowlistInputConfig, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.lastAllowlistImportOperation != null && Object.hasOwnProperty.call(message, "lastAllowlistImportOperation")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.lastAllowlistImportOperation); + if (message.autoLearning != null && Object.hasOwnProperty.call(message, "autoLearning")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.autoLearning); + return writer; + }; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {google.cloud.retail.v2.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.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.cloud.retail.v2.CompletionConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.matchingOrder = reader.string(); + break; + } + case 3: { + message.maxSuggestions = reader.int32(); + break; + } + case 4: { + message.minPrefixLength = reader.int32(); + break; + } + case 11: { + message.autoLearning = reader.bool(); + break; + } + case 5: { + message.suggestionsInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 6: { + message.lastSuggestionsImportOperation = reader.string(); + break; + } + case 7: { + message.denylistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 8: { + message.lastDenylistImportOperation = reader.string(); + break; + } + case 9: { + message.allowlistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 10: { + message.lastAllowlistImportOperation = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionConfig message. + * @function verify + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionConfig.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.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + if (!$util.isString(message.matchingOrder)) + return "matchingOrder: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + if (!$util.isInteger(message.minPrefixLength)) + return "minPrefixLength: integer expected"; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + if (typeof message.autoLearning !== "boolean") + return "autoLearning: boolean expected"; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) { + var error = $root.google.cloud.retail.v2.CompletionDataInputConfig.verify(message.suggestionsInputConfig); + if (error) + return "suggestionsInputConfig." + error; + } + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + if (!$util.isString(message.lastSuggestionsImportOperation)) + return "lastSuggestionsImportOperation: string expected"; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) { + var error = $root.google.cloud.retail.v2.CompletionDataInputConfig.verify(message.denylistInputConfig); + if (error) + return "denylistInputConfig." + error; + } + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + if (!$util.isString(message.lastDenylistImportOperation)) + return "lastDenylistImportOperation: string expected"; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) { + var error = $root.google.cloud.retail.v2.CompletionDataInputConfig.verify(message.allowlistInputConfig); + if (error) + return "allowlistInputConfig." + error; + } + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + if (!$util.isString(message.lastAllowlistImportOperation)) + return "lastAllowlistImportOperation: string expected"; + return null; + }; + + /** + * Creates a CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompletionConfig} CompletionConfig + */ + CompletionConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompletionConfig) + return object; + var message = new $root.google.cloud.retail.v2.CompletionConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.matchingOrder != null) + message.matchingOrder = String(object.matchingOrder); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + if (object.minPrefixLength != null) + message.minPrefixLength = object.minPrefixLength | 0; + if (object.autoLearning != null) + message.autoLearning = Boolean(object.autoLearning); + if (object.suggestionsInputConfig != null) { + if (typeof object.suggestionsInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.CompletionConfig.suggestionsInputConfig: object expected"); + message.suggestionsInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.fromObject(object.suggestionsInputConfig); + } + if (object.lastSuggestionsImportOperation != null) + message.lastSuggestionsImportOperation = String(object.lastSuggestionsImportOperation); + if (object.denylistInputConfig != null) { + if (typeof object.denylistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.CompletionConfig.denylistInputConfig: object expected"); + message.denylistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.fromObject(object.denylistInputConfig); + } + if (object.lastDenylistImportOperation != null) + message.lastDenylistImportOperation = String(object.lastDenylistImportOperation); + if (object.allowlistInputConfig != null) { + if (typeof object.allowlistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.CompletionConfig.allowlistInputConfig: object expected"); + message.allowlistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.fromObject(object.allowlistInputConfig); + } + if (object.lastAllowlistImportOperation != null) + message.lastAllowlistImportOperation = String(object.lastAllowlistImportOperation); + return message; + }; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {google.cloud.retail.v2.CompletionConfig} message CompletionConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.matchingOrder = ""; + object.maxSuggestions = 0; + object.minPrefixLength = 0; + object.suggestionsInputConfig = null; + object.lastSuggestionsImportOperation = ""; + object.denylistInputConfig = null; + object.lastDenylistImportOperation = ""; + object.allowlistInputConfig = null; + object.lastAllowlistImportOperation = ""; + object.autoLearning = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + object.matchingOrder = message.matchingOrder; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + object.minPrefixLength = message.minPrefixLength; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) + object.suggestionsInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.toObject(message.suggestionsInputConfig, options); + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + object.lastSuggestionsImportOperation = message.lastSuggestionsImportOperation; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) + object.denylistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.toObject(message.denylistInputConfig, options); + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + object.lastDenylistImportOperation = message.lastDenylistImportOperation; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) + object.allowlistInputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.toObject(message.allowlistInputConfig, options); + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + object.lastAllowlistImportOperation = message.lastAllowlistImportOperation; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + object.autoLearning = message.autoLearning; + return object; + }; + + /** + * Converts this CompletionConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompletionConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompletionConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompletionConfig"; + }; + + return CompletionConfig; + })(); + + v2.Catalog = (function() { + + /** + * Properties of a Catalog. + * @memberof google.cloud.retail.v2 + * @interface ICatalog + * @property {string|null} [name] Catalog name + * @property {string|null} [displayName] Catalog displayName + * @property {google.cloud.retail.v2.IProductLevelConfig|null} [productLevelConfig] Catalog productLevelConfig + */ + + /** + * Constructs a new Catalog. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Catalog. + * @implements ICatalog + * @constructor + * @param {google.cloud.retail.v2.ICatalog=} [properties] Properties to set + */ + function Catalog(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]]; + } + + /** + * Catalog name. + * @member {string} name + * @memberof google.cloud.retail.v2.Catalog + * @instance + */ + Catalog.prototype.name = ""; + + /** + * Catalog displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2.Catalog + * @instance + */ + Catalog.prototype.displayName = ""; + + /** + * Catalog productLevelConfig. + * @member {google.cloud.retail.v2.IProductLevelConfig|null|undefined} productLevelConfig + * @memberof google.cloud.retail.v2.Catalog + * @instance + */ + Catalog.prototype.productLevelConfig = null; + + /** + * Creates a new Catalog instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {google.cloud.retail.v2.ICatalog=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Catalog} Catalog instance + */ + Catalog.create = function create(properties) { + return new Catalog(properties); + }; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2.Catalog.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {google.cloud.retail.v2.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.productLevelConfig != null && Object.hasOwnProperty.call(message, "productLevelConfig")) + $root.google.cloud.retail.v2.ProductLevelConfig.encode(message.productLevelConfig, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Catalog.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {google.cloud.retail.v2.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.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.cloud.retail.v2.Catalog(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 4: { + message.productLevelConfig = $root.google.cloud.retail.v2.ProductLevelConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Catalog message. + * @function verify + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Catalog.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) { + var error = $root.google.cloud.retail.v2.ProductLevelConfig.verify(message.productLevelConfig); + if (error) + return "productLevelConfig." + error; + } + return null; + }; + + /** + * Creates a Catalog message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Catalog} Catalog + */ + Catalog.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Catalog) + return object; + var message = new $root.google.cloud.retail.v2.Catalog(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.productLevelConfig != null) { + if (typeof object.productLevelConfig !== "object") + throw TypeError(".google.cloud.retail.v2.Catalog.productLevelConfig: object expected"); + message.productLevelConfig = $root.google.cloud.retail.v2.ProductLevelConfig.fromObject(object.productLevelConfig); + } + return message; + }; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {google.cloud.retail.v2.Catalog} message Catalog + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Catalog.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.productLevelConfig = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) + object.productLevelConfig = $root.google.cloud.retail.v2.ProductLevelConfig.toObject(message.productLevelConfig, options); + return object; + }; + + /** + * Converts this Catalog to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Catalog + * @instance + * @returns {Object.} JSON object + */ + Catalog.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Catalog + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Catalog + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Catalog.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Catalog"; + }; + + return Catalog; + })(); + + /** + * AttributeConfigLevel enum. + * @name google.cloud.retail.v2.AttributeConfigLevel + * @enum {number} + * @property {number} ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED=0 ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED value + * @property {number} PRODUCT_LEVEL_ATTRIBUTE_CONFIG=1 PRODUCT_LEVEL_ATTRIBUTE_CONFIG value + * @property {number} CATALOG_LEVEL_ATTRIBUTE_CONFIG=2 CATALOG_LEVEL_ATTRIBUTE_CONFIG value + */ + v2.AttributeConfigLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_LEVEL_ATTRIBUTE_CONFIG"] = 1; + values[valuesById[2] = "CATALOG_LEVEL_ATTRIBUTE_CONFIG"] = 2; + return values; + })(); + + /** + * SolutionType enum. + * @name google.cloud.retail.v2.SolutionType + * @enum {number} + * @property {number} SOLUTION_TYPE_UNSPECIFIED=0 SOLUTION_TYPE_UNSPECIFIED value + * @property {number} SOLUTION_TYPE_RECOMMENDATION=1 SOLUTION_TYPE_RECOMMENDATION value + * @property {number} SOLUTION_TYPE_SEARCH=2 SOLUTION_TYPE_SEARCH value + */ + v2.SolutionType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SOLUTION_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SOLUTION_TYPE_RECOMMENDATION"] = 1; + values[valuesById[2] = "SOLUTION_TYPE_SEARCH"] = 2; + return values; + })(); + + /** + * SearchSolutionUseCase enum. + * @name google.cloud.retail.v2.SearchSolutionUseCase + * @enum {number} + * @property {number} SEARCH_SOLUTION_USE_CASE_UNSPECIFIED=0 SEARCH_SOLUTION_USE_CASE_UNSPECIFIED value + * @property {number} SEARCH_SOLUTION_USE_CASE_SEARCH=1 SEARCH_SOLUTION_USE_CASE_SEARCH value + * @property {number} SEARCH_SOLUTION_USE_CASE_BROWSE=2 SEARCH_SOLUTION_USE_CASE_BROWSE value + */ + v2.SearchSolutionUseCase = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCH_SOLUTION_USE_CASE_SEARCH"] = 1; + values[valuesById[2] = "SEARCH_SOLUTION_USE_CASE_BROWSE"] = 2; + return values; + })(); + + v2.Condition = (function() { + + /** + * Properties of a Condition. + * @memberof google.cloud.retail.v2 + * @interface ICondition + * @property {Array.|null} [queryTerms] Condition queryTerms + * @property {Array.|null} [activeTimeRange] Condition activeTimeRange + */ + + /** + * Constructs a new Condition. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Condition. + * @implements ICondition + * @constructor + * @param {google.cloud.retail.v2.ICondition=} [properties] Properties to set + */ + function Condition(properties) { + this.queryTerms = []; + this.activeTimeRange = []; + 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]]; + } + + /** + * Condition queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2.Condition + * @instance + */ + Condition.prototype.queryTerms = $util.emptyArray; + + /** + * Condition activeTimeRange. + * @member {Array.} activeTimeRange + * @memberof google.cloud.retail.v2.Condition + * @instance + */ + Condition.prototype.activeTimeRange = $util.emptyArray; + + /** + * Creates a new Condition instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {google.cloud.retail.v2.ICondition=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Condition} Condition instance + */ + Condition.create = function create(properties) { + return new Condition(properties); + }; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2.Condition.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {google.cloud.retail.v2.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + $root.google.cloud.retail.v2.Condition.QueryTerm.encode(message.queryTerms[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.activeTimeRange != null && message.activeTimeRange.length) + for (var i = 0; i < message.activeTimeRange.length; ++i) + $root.google.cloud.retail.v2.Condition.TimeRange.encode(message.activeTimeRange[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {google.cloud.retail.v2.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.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.cloud.retail.v2.Condition(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push($root.google.cloud.retail.v2.Condition.QueryTerm.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.activeTimeRange && message.activeTimeRange.length)) + message.activeTimeRange = []; + message.activeTimeRange.push($root.google.cloud.retail.v2.Condition.TimeRange.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Condition message. + * @function verify + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Condition.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) { + var error = $root.google.cloud.retail.v2.Condition.QueryTerm.verify(message.queryTerms[i]); + if (error) + return "queryTerms." + error; + } + } + if (message.activeTimeRange != null && message.hasOwnProperty("activeTimeRange")) { + if (!Array.isArray(message.activeTimeRange)) + return "activeTimeRange: array expected"; + for (var i = 0; i < message.activeTimeRange.length; ++i) { + var error = $root.google.cloud.retail.v2.Condition.TimeRange.verify(message.activeTimeRange[i]); + if (error) + return "activeTimeRange." + error; + } + } + return null; + }; + + /** + * Creates a Condition message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Condition} Condition + */ + Condition.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Condition) + return object; + var message = new $root.google.cloud.retail.v2.Condition(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2.Condition.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) { + if (typeof object.queryTerms[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Condition.queryTerms: object expected"); + message.queryTerms[i] = $root.google.cloud.retail.v2.Condition.QueryTerm.fromObject(object.queryTerms[i]); + } + } + if (object.activeTimeRange) { + if (!Array.isArray(object.activeTimeRange)) + throw TypeError(".google.cloud.retail.v2.Condition.activeTimeRange: array expected"); + message.activeTimeRange = []; + for (var i = 0; i < object.activeTimeRange.length; ++i) { + if (typeof object.activeTimeRange[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Condition.activeTimeRange: object expected"); + message.activeTimeRange[i] = $root.google.cloud.retail.v2.Condition.TimeRange.fromObject(object.activeTimeRange[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {google.cloud.retail.v2.Condition} message Condition + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Condition.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.queryTerms = []; + object.activeTimeRange = []; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = $root.google.cloud.retail.v2.Condition.QueryTerm.toObject(message.queryTerms[j], options); + } + if (message.activeTimeRange && message.activeTimeRange.length) { + object.activeTimeRange = []; + for (var j = 0; j < message.activeTimeRange.length; ++j) + object.activeTimeRange[j] = $root.google.cloud.retail.v2.Condition.TimeRange.toObject(message.activeTimeRange[j], options); + } + return object; + }; + + /** + * Converts this Condition to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Condition + * @instance + * @returns {Object.} JSON object + */ + Condition.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Condition + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Condition + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Condition.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Condition"; + }; + + Condition.QueryTerm = (function() { + + /** + * Properties of a QueryTerm. + * @memberof google.cloud.retail.v2.Condition + * @interface IQueryTerm + * @property {string|null} [value] QueryTerm value + * @property {boolean|null} [fullMatch] QueryTerm fullMatch + */ + + /** + * Constructs a new QueryTerm. + * @memberof google.cloud.retail.v2.Condition + * @classdesc Represents a QueryTerm. + * @implements IQueryTerm + * @constructor + * @param {google.cloud.retail.v2.Condition.IQueryTerm=} [properties] Properties to set + */ + function QueryTerm(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]]; + } + + /** + * QueryTerm value. + * @member {string} value + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.value = ""; + + /** + * QueryTerm fullMatch. + * @member {boolean} fullMatch + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.fullMatch = false; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2.Condition.IQueryTerm=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Condition.QueryTerm} QueryTerm instance + */ + QueryTerm.create = function create(properties) { + return new QueryTerm(properties); + }; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2.Condition.QueryTerm.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.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); + if (message.fullMatch != null && Object.hasOwnProperty.call(message, "fullMatch")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullMatch); + return writer; + }; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.QueryTerm.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.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.cloud.retail.v2.Condition.QueryTerm(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.fullMatch = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryTerm message. + * @function verify + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryTerm.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"; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + if (typeof message.fullMatch !== "boolean") + return "fullMatch: boolean expected"; + return null; + }; + + /** + * Creates a QueryTerm message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Condition.QueryTerm} QueryTerm + */ + QueryTerm.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Condition.QueryTerm) + return object; + var message = new $root.google.cloud.retail.v2.Condition.QueryTerm(); + if (object.value != null) + message.value = String(object.value); + if (object.fullMatch != null) + message.fullMatch = Boolean(object.fullMatch); + return message; + }; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2.Condition.QueryTerm} message QueryTerm + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryTerm.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.fullMatch = false; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + object.fullMatch = message.fullMatch; + return object; + }; + + /** + * Converts this QueryTerm to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @instance + * @returns {Object.} JSON object + */ + QueryTerm.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryTerm + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Condition.QueryTerm + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryTerm.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Condition.QueryTerm"; + }; + + return QueryTerm; + })(); + + Condition.TimeRange = (function() { + + /** + * Properties of a TimeRange. + * @memberof google.cloud.retail.v2.Condition + * @interface ITimeRange + * @property {google.protobuf.ITimestamp|null} [startTime] TimeRange startTime + * @property {google.protobuf.ITimestamp|null} [endTime] TimeRange endTime + */ + + /** + * Constructs a new TimeRange. + * @memberof google.cloud.retail.v2.Condition + * @classdesc Represents a TimeRange. + * @implements ITimeRange + * @constructor + * @param {google.cloud.retail.v2.Condition.ITimeRange=} [properties] Properties to set + */ + function TimeRange(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]]; + } + + /** + * TimeRange startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @instance + */ + TimeRange.prototype.startTime = null; + + /** + * TimeRange endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @instance + */ + TimeRange.prototype.endTime = null; + + /** + * Creates a new TimeRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2.Condition.ITimeRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Condition.TimeRange} TimeRange instance + */ + TimeRange.create = function create(properties) { + return new TimeRange(properties); + }; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2.Condition.TimeRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.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(); + return writer; + }; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Condition.TimeRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.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.cloud.retail.v2.Condition.TimeRange(); + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TimeRange message. + * @function verify + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TimeRange.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; + } + return null; + }; + + /** + * Creates a TimeRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Condition.TimeRange} TimeRange + */ + TimeRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Condition.TimeRange) + return object; + var message = new $root.google.cloud.retail.v2.Condition.TimeRange(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.cloud.retail.v2.Condition.TimeRange.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.retail.v2.Condition.TimeRange.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2.Condition.TimeRange} message TimeRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TimeRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + } + 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); + return object; + }; + + /** + * Converts this TimeRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @instance + * @returns {Object.} JSON object + */ + TimeRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TimeRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Condition.TimeRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TimeRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Condition.TimeRange"; + }; + + return TimeRange; + })(); + + return Condition; + })(); + + v2.Rule = (function() { + + /** + * Properties of a Rule. + * @memberof google.cloud.retail.v2 + * @interface IRule + * @property {google.cloud.retail.v2.Rule.IBoostAction|null} [boostAction] Rule boostAction + * @property {google.cloud.retail.v2.Rule.IRedirectAction|null} [redirectAction] Rule redirectAction + * @property {google.cloud.retail.v2.Rule.IOnewaySynonymsAction|null} [onewaySynonymsAction] Rule onewaySynonymsAction + * @property {google.cloud.retail.v2.Rule.IDoNotAssociateAction|null} [doNotAssociateAction] Rule doNotAssociateAction + * @property {google.cloud.retail.v2.Rule.IReplacementAction|null} [replacementAction] Rule replacementAction + * @property {google.cloud.retail.v2.Rule.IIgnoreAction|null} [ignoreAction] Rule ignoreAction + * @property {google.cloud.retail.v2.Rule.IFilterAction|null} [filterAction] Rule filterAction + * @property {google.cloud.retail.v2.Rule.ITwowaySynonymsAction|null} [twowaySynonymsAction] Rule twowaySynonymsAction + * @property {google.cloud.retail.v2.ICondition|null} [condition] Rule condition + */ + + /** + * Constructs a new Rule. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Rule. + * @implements IRule + * @constructor + * @param {google.cloud.retail.v2.IRule=} [properties] Properties to set + */ + function Rule(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]]; + } + + /** + * Rule boostAction. + * @member {google.cloud.retail.v2.Rule.IBoostAction|null|undefined} boostAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.boostAction = null; + + /** + * Rule redirectAction. + * @member {google.cloud.retail.v2.Rule.IRedirectAction|null|undefined} redirectAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.redirectAction = null; + + /** + * Rule onewaySynonymsAction. + * @member {google.cloud.retail.v2.Rule.IOnewaySynonymsAction|null|undefined} onewaySynonymsAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.onewaySynonymsAction = null; + + /** + * Rule doNotAssociateAction. + * @member {google.cloud.retail.v2.Rule.IDoNotAssociateAction|null|undefined} doNotAssociateAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.doNotAssociateAction = null; + + /** + * Rule replacementAction. + * @member {google.cloud.retail.v2.Rule.IReplacementAction|null|undefined} replacementAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.replacementAction = null; + + /** + * Rule ignoreAction. + * @member {google.cloud.retail.v2.Rule.IIgnoreAction|null|undefined} ignoreAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.ignoreAction = null; + + /** + * Rule filterAction. + * @member {google.cloud.retail.v2.Rule.IFilterAction|null|undefined} filterAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.filterAction = null; + + /** + * Rule twowaySynonymsAction. + * @member {google.cloud.retail.v2.Rule.ITwowaySynonymsAction|null|undefined} twowaySynonymsAction + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.twowaySynonymsAction = null; + + /** + * Rule condition. + * @member {google.cloud.retail.v2.ICondition|null|undefined} condition + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Rule.prototype.condition = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Rule action. + * @member {"boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"|undefined} action + * @memberof google.cloud.retail.v2.Rule + * @instance + */ + Object.defineProperty(Rule.prototype, "action", { + get: $util.oneOfGetter($oneOfFields = ["boostAction", "redirectAction", "onewaySynonymsAction", "doNotAssociateAction", "replacementAction", "ignoreAction", "filterAction", "twowaySynonymsAction"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Rule instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {google.cloud.retail.v2.IRule=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule} Rule instance + */ + Rule.create = function create(properties) { + return new Rule(properties); + }; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2.Rule.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {google.cloud.retail.v2.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + $root.google.cloud.retail.v2.Condition.encode(message.condition, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.boostAction != null && Object.hasOwnProperty.call(message, "boostAction")) + $root.google.cloud.retail.v2.Rule.BoostAction.encode(message.boostAction, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.redirectAction != null && Object.hasOwnProperty.call(message, "redirectAction")) + $root.google.cloud.retail.v2.Rule.RedirectAction.encode(message.redirectAction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.onewaySynonymsAction != null && Object.hasOwnProperty.call(message, "onewaySynonymsAction")) + $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction.encode(message.onewaySynonymsAction, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.doNotAssociateAction != null && Object.hasOwnProperty.call(message, "doNotAssociateAction")) + $root.google.cloud.retail.v2.Rule.DoNotAssociateAction.encode(message.doNotAssociateAction, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.replacementAction != null && Object.hasOwnProperty.call(message, "replacementAction")) + $root.google.cloud.retail.v2.Rule.ReplacementAction.encode(message.replacementAction, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.ignoreAction != null && Object.hasOwnProperty.call(message, "ignoreAction")) + $root.google.cloud.retail.v2.Rule.IgnoreAction.encode(message.ignoreAction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.filterAction != null && Object.hasOwnProperty.call(message, "filterAction")) + $root.google.cloud.retail.v2.Rule.FilterAction.encode(message.filterAction, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.twowaySynonymsAction != null && Object.hasOwnProperty.call(message, "twowaySynonymsAction")) + $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction.encode(message.twowaySynonymsAction, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {google.cloud.retail.v2.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.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.cloud.retail.v2.Rule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.boostAction = $root.google.cloud.retail.v2.Rule.BoostAction.decode(reader, reader.uint32()); + break; + } + case 3: { + message.redirectAction = $root.google.cloud.retail.v2.Rule.RedirectAction.decode(reader, reader.uint32()); + break; + } + case 6: { + message.onewaySynonymsAction = $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 7: { + message.doNotAssociateAction = $root.google.cloud.retail.v2.Rule.DoNotAssociateAction.decode(reader, reader.uint32()); + break; + } + case 8: { + message.replacementAction = $root.google.cloud.retail.v2.Rule.ReplacementAction.decode(reader, reader.uint32()); + break; + } + case 9: { + message.ignoreAction = $root.google.cloud.retail.v2.Rule.IgnoreAction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.filterAction = $root.google.cloud.retail.v2.Rule.FilterAction.decode(reader, reader.uint32()); + break; + } + case 11: { + message.twowaySynonymsAction = $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 1: { + message.condition = $root.google.cloud.retail.v2.Condition.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rule message. + * @function verify + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.BoostAction.verify(message.boostAction); + if (error) + return "boostAction." + error; + } + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.RedirectAction.verify(message.redirectAction); + if (error) + return "redirectAction." + error; + } + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction.verify(message.onewaySynonymsAction); + if (error) + return "onewaySynonymsAction." + error; + } + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.DoNotAssociateAction.verify(message.doNotAssociateAction); + if (error) + return "doNotAssociateAction." + error; + } + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.ReplacementAction.verify(message.replacementAction); + if (error) + return "replacementAction." + error; + } + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.IgnoreAction.verify(message.ignoreAction); + if (error) + return "ignoreAction." + error; + } + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.FilterAction.verify(message.filterAction); + if (error) + return "filterAction." + error; + } + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction.verify(message.twowaySynonymsAction); + if (error) + return "twowaySynonymsAction." + error; + } + } + if (message.condition != null && message.hasOwnProperty("condition")) { + var error = $root.google.cloud.retail.v2.Condition.verify(message.condition); + if (error) + return "condition." + error; + } + return null; + }; + + /** + * Creates a Rule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule} Rule + */ + Rule.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule) + return object; + var message = new $root.google.cloud.retail.v2.Rule(); + if (object.boostAction != null) { + if (typeof object.boostAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.boostAction: object expected"); + message.boostAction = $root.google.cloud.retail.v2.Rule.BoostAction.fromObject(object.boostAction); + } + if (object.redirectAction != null) { + if (typeof object.redirectAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.redirectAction: object expected"); + message.redirectAction = $root.google.cloud.retail.v2.Rule.RedirectAction.fromObject(object.redirectAction); + } + if (object.onewaySynonymsAction != null) { + if (typeof object.onewaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.onewaySynonymsAction: object expected"); + message.onewaySynonymsAction = $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction.fromObject(object.onewaySynonymsAction); + } + if (object.doNotAssociateAction != null) { + if (typeof object.doNotAssociateAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.doNotAssociateAction: object expected"); + message.doNotAssociateAction = $root.google.cloud.retail.v2.Rule.DoNotAssociateAction.fromObject(object.doNotAssociateAction); + } + if (object.replacementAction != null) { + if (typeof object.replacementAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.replacementAction: object expected"); + message.replacementAction = $root.google.cloud.retail.v2.Rule.ReplacementAction.fromObject(object.replacementAction); + } + if (object.ignoreAction != null) { + if (typeof object.ignoreAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.ignoreAction: object expected"); + message.ignoreAction = $root.google.cloud.retail.v2.Rule.IgnoreAction.fromObject(object.ignoreAction); + } + if (object.filterAction != null) { + if (typeof object.filterAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.filterAction: object expected"); + message.filterAction = $root.google.cloud.retail.v2.Rule.FilterAction.fromObject(object.filterAction); + } + if (object.twowaySynonymsAction != null) { + if (typeof object.twowaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.twowaySynonymsAction: object expected"); + message.twowaySynonymsAction = $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction.fromObject(object.twowaySynonymsAction); + } + if (object.condition != null) { + if (typeof object.condition !== "object") + throw TypeError(".google.cloud.retail.v2.Rule.condition: object expected"); + message.condition = $root.google.cloud.retail.v2.Condition.fromObject(object.condition); + } + return message; + }; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {google.cloud.retail.v2.Rule} message Rule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.condition = null; + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = $root.google.cloud.retail.v2.Condition.toObject(message.condition, options); + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + object.boostAction = $root.google.cloud.retail.v2.Rule.BoostAction.toObject(message.boostAction, options); + if (options.oneofs) + object.action = "boostAction"; + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + object.redirectAction = $root.google.cloud.retail.v2.Rule.RedirectAction.toObject(message.redirectAction, options); + if (options.oneofs) + object.action = "redirectAction"; + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + object.onewaySynonymsAction = $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction.toObject(message.onewaySynonymsAction, options); + if (options.oneofs) + object.action = "onewaySynonymsAction"; + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + object.doNotAssociateAction = $root.google.cloud.retail.v2.Rule.DoNotAssociateAction.toObject(message.doNotAssociateAction, options); + if (options.oneofs) + object.action = "doNotAssociateAction"; + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + object.replacementAction = $root.google.cloud.retail.v2.Rule.ReplacementAction.toObject(message.replacementAction, options); + if (options.oneofs) + object.action = "replacementAction"; + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + object.ignoreAction = $root.google.cloud.retail.v2.Rule.IgnoreAction.toObject(message.ignoreAction, options); + if (options.oneofs) + object.action = "ignoreAction"; + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + object.filterAction = $root.google.cloud.retail.v2.Rule.FilterAction.toObject(message.filterAction, options); + if (options.oneofs) + object.action = "filterAction"; + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + object.twowaySynonymsAction = $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction.toObject(message.twowaySynonymsAction, options); + if (options.oneofs) + object.action = "twowaySynonymsAction"; + } + return object; + }; + + /** + * Converts this Rule to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule + * @instance + * @returns {Object.} JSON object + */ + Rule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rule + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule"; + }; + + Rule.BoostAction = (function() { + + /** + * Properties of a BoostAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IBoostAction + * @property {number|null} [boost] BoostAction boost + * @property {string|null} [productsFilter] BoostAction productsFilter + */ + + /** + * Constructs a new BoostAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a BoostAction. + * @implements IBoostAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IBoostAction=} [properties] Properties to set + */ + function BoostAction(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]]; + } + + /** + * BoostAction boost. + * @member {number} boost + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @instance + */ + BoostAction.prototype.boost = 0; + + /** + * BoostAction productsFilter. + * @member {string} productsFilter + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @instance + */ + BoostAction.prototype.productsFilter = ""; + + /** + * Creates a new BoostAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2.Rule.IBoostAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.BoostAction} BoostAction instance + */ + BoostAction.create = function create(properties) { + return new BoostAction(properties); + }; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.BoostAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.boost); + if (message.productsFilter != null && Object.hasOwnProperty.call(message, "productsFilter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.productsFilter); + return writer; + }; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.BoostAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.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.cloud.retail.v2.Rule.BoostAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.boost = reader.float(); + break; + } + case 2: { + message.productsFilter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + if (!$util.isString(message.productsFilter)) + return "productsFilter: string expected"; + return null; + }; + + /** + * Creates a BoostAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.BoostAction} BoostAction + */ + BoostAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.BoostAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.BoostAction(); + if (object.boost != null) + message.boost = Number(object.boost); + if (object.productsFilter != null) + message.productsFilter = String(object.productsFilter); + return message; + }; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2.Rule.BoostAction} message BoostAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.boost = 0; + object.productsFilter = ""; + } + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + object.productsFilter = message.productsFilter; + return object; + }; + + /** + * Converts this BoostAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @instance + * @returns {Object.} JSON object + */ + BoostAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.BoostAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.BoostAction"; + }; + + return BoostAction; + })(); + + Rule.FilterAction = (function() { + + /** + * Properties of a FilterAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IFilterAction + * @property {string|null} [filter] FilterAction filter + */ + + /** + * Constructs a new FilterAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a FilterAction. + * @implements IFilterAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IFilterAction=} [properties] Properties to set + */ + function FilterAction(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]]; + } + + /** + * FilterAction filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @instance + */ + FilterAction.prototype.filter = ""; + + /** + * Creates a new FilterAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2.Rule.IFilterAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.FilterAction} FilterAction instance + */ + FilterAction.create = function create(properties) { + return new FilterAction(properties); + }; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.FilterAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.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); + return writer; + }; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.FilterAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.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.cloud.retail.v2.Rule.FilterAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FilterAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FilterAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a FilterAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.FilterAction} FilterAction + */ + FilterAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.FilterAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.FilterAction(); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2.Rule.FilterAction} message FilterAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FilterAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.filter = ""; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this FilterAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @instance + * @returns {Object.} JSON object + */ + FilterAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FilterAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.FilterAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FilterAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.FilterAction"; + }; + + return FilterAction; + })(); + + Rule.RedirectAction = (function() { + + /** + * Properties of a RedirectAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IRedirectAction + * @property {string|null} [redirectUri] RedirectAction redirectUri + */ + + /** + * Constructs a new RedirectAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a RedirectAction. + * @implements IRedirectAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IRedirectAction=} [properties] Properties to set + */ + function RedirectAction(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]]; + } + + /** + * RedirectAction redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @instance + */ + RedirectAction.prototype.redirectUri = ""; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2.Rule.IRedirectAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.RedirectAction} RedirectAction instance + */ + RedirectAction.create = function create(properties) { + return new RedirectAction(properties); + }; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.RedirectAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.redirectUri); + return writer; + }; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.RedirectAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.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.cloud.retail.v2.Rule.RedirectAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.redirectUri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RedirectAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RedirectAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + return null; + }; + + /** + * Creates a RedirectAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.RedirectAction} RedirectAction + */ + RedirectAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.RedirectAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.RedirectAction(); + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + return message; + }; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2.Rule.RedirectAction} message RedirectAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RedirectAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.redirectUri = ""; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + return object; + }; + + /** + * Converts this RedirectAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @instance + * @returns {Object.} JSON object + */ + RedirectAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RedirectAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.RedirectAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RedirectAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.RedirectAction"; + }; + + return RedirectAction; + })(); + + Rule.TwowaySynonymsAction = (function() { + + /** + * Properties of a TwowaySynonymsAction. + * @memberof google.cloud.retail.v2.Rule + * @interface ITwowaySynonymsAction + * @property {Array.|null} [synonyms] TwowaySynonymsAction synonyms + */ + + /** + * Constructs a new TwowaySynonymsAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a TwowaySynonymsAction. + * @implements ITwowaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2.Rule.ITwowaySynonymsAction=} [properties] Properties to set + */ + function TwowaySynonymsAction(properties) { + this.synonyms = []; + 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]]; + } + + /** + * TwowaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @instance + */ + TwowaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.ITwowaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.TwowaySynonymsAction} TwowaySynonymsAction instance + */ + TwowaySynonymsAction.create = function create(properties) { + return new TwowaySynonymsAction(properties); + }; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.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.cloud.retail.v2.Rule.TwowaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TwowaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TwowaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + return null; + }; + + /** + * Creates a TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.TwowaySynonymsAction} TwowaySynonymsAction + */ + TwowaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.TwowaySynonymsAction(); + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2.Rule.TwowaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + return message; + }; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.TwowaySynonymsAction} message TwowaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TwowaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.synonyms = []; + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + TwowaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.TwowaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TwowaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.TwowaySynonymsAction"; + }; + + return TwowaySynonymsAction; + })(); + + Rule.OnewaySynonymsAction = (function() { + + /** + * Properties of an OnewaySynonymsAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IOnewaySynonymsAction + * @property {Array.|null} [queryTerms] OnewaySynonymsAction queryTerms + * @property {Array.|null} [synonyms] OnewaySynonymsAction synonyms + * @property {Array.|null} [onewayTerms] OnewaySynonymsAction onewayTerms + */ + + /** + * Constructs a new OnewaySynonymsAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents an OnewaySynonymsAction. + * @implements IOnewaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IOnewaySynonymsAction=} [properties] Properties to set + */ + function OnewaySynonymsAction(properties) { + this.queryTerms = []; + this.synonyms = []; + this.onewayTerms = []; + 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]]; + } + + /** + * OnewaySynonymsAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.queryTerms = $util.emptyArray; + + /** + * OnewaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * OnewaySynonymsAction onewayTerms. + * @member {Array.} onewayTerms + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.onewayTerms = $util.emptyArray; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.IOnewaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.OnewaySynonymsAction} OnewaySynonymsAction instance + */ + OnewaySynonymsAction.create = function create(properties) { + return new OnewaySynonymsAction(properties); + }; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.onewayTerms != null && message.onewayTerms.length) + for (var i = 0; i < message.onewayTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.onewayTerms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.queryTerms[i]); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.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.cloud.retail.v2.Rule.OnewaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 4: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + case 2: { + if (!(message.onewayTerms && message.onewayTerms.length)) + message.onewayTerms = []; + message.onewayTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OnewaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OnewaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + if (message.onewayTerms != null && message.hasOwnProperty("onewayTerms")) { + if (!Array.isArray(message.onewayTerms)) + return "onewayTerms: array expected"; + for (var i = 0; i < message.onewayTerms.length; ++i) + if (!$util.isString(message.onewayTerms[i])) + return "onewayTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.OnewaySynonymsAction} OnewaySynonymsAction + */ + OnewaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.OnewaySynonymsAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.OnewaySynonymsAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2.Rule.OnewaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + if (object.onewayTerms) { + if (!Array.isArray(object.onewayTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.OnewaySynonymsAction.onewayTerms: array expected"); + message.onewayTerms = []; + for (var i = 0; i < object.onewayTerms.length; ++i) + message.onewayTerms[i] = String(object.onewayTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2.Rule.OnewaySynonymsAction} message OnewaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OnewaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.onewayTerms = []; + object.queryTerms = []; + object.synonyms = []; + } + if (message.onewayTerms && message.onewayTerms.length) { + object.onewayTerms = []; + for (var j = 0; j < message.onewayTerms.length; ++j) + object.onewayTerms[j] = message.onewayTerms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + OnewaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.OnewaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OnewaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.OnewaySynonymsAction"; + }; + + return OnewaySynonymsAction; + })(); + + Rule.DoNotAssociateAction = (function() { + + /** + * Properties of a DoNotAssociateAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IDoNotAssociateAction + * @property {Array.|null} [queryTerms] DoNotAssociateAction queryTerms + * @property {Array.|null} [doNotAssociateTerms] DoNotAssociateAction doNotAssociateTerms + * @property {Array.|null} [terms] DoNotAssociateAction terms + */ + + /** + * Constructs a new DoNotAssociateAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a DoNotAssociateAction. + * @implements IDoNotAssociateAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IDoNotAssociateAction=} [properties] Properties to set + */ + function DoNotAssociateAction(properties) { + this.queryTerms = []; + this.doNotAssociateTerms = []; + this.terms = []; + 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]]; + } + + /** + * DoNotAssociateAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.queryTerms = $util.emptyArray; + + /** + * DoNotAssociateAction doNotAssociateTerms. + * @member {Array.} doNotAssociateTerms + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.doNotAssociateTerms = $util.emptyArray; + + /** + * DoNotAssociateAction terms. + * @member {Array.} terms + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.terms = $util.emptyArray; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2.Rule.IDoNotAssociateAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.DoNotAssociateAction} DoNotAssociateAction instance + */ + DoNotAssociateAction.create = function create(properties) { + return new DoNotAssociateAction(properties); + }; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.terms != null && message.terms.length) + for (var i = 0; i < message.terms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.terms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.doNotAssociateTerms != null && message.doNotAssociateTerms.length) + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.doNotAssociateTerms[i]); + return writer; + }; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.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.cloud.retail.v2.Rule.DoNotAssociateAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + if (!(message.doNotAssociateTerms && message.doNotAssociateTerms.length)) + message.doNotAssociateTerms = []; + message.doNotAssociateTerms.push(reader.string()); + break; + } + case 1: { + if (!(message.terms && message.terms.length)) + message.terms = []; + message.terms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DoNotAssociateAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DoNotAssociateAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.doNotAssociateTerms != null && message.hasOwnProperty("doNotAssociateTerms")) { + if (!Array.isArray(message.doNotAssociateTerms)) + return "doNotAssociateTerms: array expected"; + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + if (!$util.isString(message.doNotAssociateTerms[i])) + return "doNotAssociateTerms: string[] expected"; + } + if (message.terms != null && message.hasOwnProperty("terms")) { + if (!Array.isArray(message.terms)) + return "terms: array expected"; + for (var i = 0; i < message.terms.length; ++i) + if (!$util.isString(message.terms[i])) + return "terms: string[] expected"; + } + return null; + }; + + /** + * Creates a DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.DoNotAssociateAction} DoNotAssociateAction + */ + DoNotAssociateAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.DoNotAssociateAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.DoNotAssociateAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.DoNotAssociateAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.doNotAssociateTerms) { + if (!Array.isArray(object.doNotAssociateTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.DoNotAssociateAction.doNotAssociateTerms: array expected"); + message.doNotAssociateTerms = []; + for (var i = 0; i < object.doNotAssociateTerms.length; ++i) + message.doNotAssociateTerms[i] = String(object.doNotAssociateTerms[i]); + } + if (object.terms) { + if (!Array.isArray(object.terms)) + throw TypeError(".google.cloud.retail.v2.Rule.DoNotAssociateAction.terms: array expected"); + message.terms = []; + for (var i = 0; i < object.terms.length; ++i) + message.terms[i] = String(object.terms[i]); + } + return message; + }; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2.Rule.DoNotAssociateAction} message DoNotAssociateAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoNotAssociateAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.terms = []; + object.queryTerms = []; + object.doNotAssociateTerms = []; + } + if (message.terms && message.terms.length) { + object.terms = []; + for (var j = 0; j < message.terms.length; ++j) + object.terms[j] = message.terms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.doNotAssociateTerms && message.doNotAssociateTerms.length) { + object.doNotAssociateTerms = []; + for (var j = 0; j < message.doNotAssociateTerms.length; ++j) + object.doNotAssociateTerms[j] = message.doNotAssociateTerms[j]; + } + return object; + }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @instance + * @returns {Object.} JSON object + */ + DoNotAssociateAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DoNotAssociateAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.DoNotAssociateAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DoNotAssociateAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.DoNotAssociateAction"; + }; + + return DoNotAssociateAction; + })(); + + Rule.ReplacementAction = (function() { + + /** + * Properties of a ReplacementAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IReplacementAction + * @property {Array.|null} [queryTerms] ReplacementAction queryTerms + * @property {string|null} [replacementTerm] ReplacementAction replacementTerm + * @property {string|null} [term] ReplacementAction term + */ + + /** + * Constructs a new ReplacementAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents a ReplacementAction. + * @implements IReplacementAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IReplacementAction=} [properties] Properties to set + */ + function ReplacementAction(properties) { + this.queryTerms = []; + 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]]; + } + + /** + * ReplacementAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.queryTerms = $util.emptyArray; + + /** + * ReplacementAction replacementTerm. + * @member {string} replacementTerm + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.replacementTerm = ""; + + /** + * ReplacementAction term. + * @member {string} term + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.term = ""; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2.Rule.IReplacementAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.ReplacementAction} ReplacementAction instance + */ + ReplacementAction.create = function create(properties) { + return new ReplacementAction(properties); + }; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.ReplacementAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.term != null && Object.hasOwnProperty.call(message, "term")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.term); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.replacementTerm != null && Object.hasOwnProperty.call(message, "replacementTerm")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.replacementTerm); + return writer; + }; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.ReplacementAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.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.cloud.retail.v2.Rule.ReplacementAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + message.replacementTerm = reader.string(); + break; + } + case 1: { + message.term = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplacementAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplacementAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + if (!$util.isString(message.replacementTerm)) + return "replacementTerm: string expected"; + if (message.term != null && message.hasOwnProperty("term")) + if (!$util.isString(message.term)) + return "term: string expected"; + return null; + }; + + /** + * Creates a ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.ReplacementAction} ReplacementAction + */ + ReplacementAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.ReplacementAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.ReplacementAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.ReplacementAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.replacementTerm != null) + message.replacementTerm = String(object.replacementTerm); + if (object.term != null) + message.term = String(object.term); + return message; + }; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2.Rule.ReplacementAction} message ReplacementAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplacementAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.queryTerms = []; + if (options.defaults) { + object.term = ""; + object.replacementTerm = ""; + } + if (message.term != null && message.hasOwnProperty("term")) + object.term = message.term; + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + object.replacementTerm = message.replacementTerm; + return object; + }; + + /** + * Converts this ReplacementAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @instance + * @returns {Object.} JSON object + */ + ReplacementAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplacementAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.ReplacementAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplacementAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.ReplacementAction"; + }; + + return ReplacementAction; + })(); + + Rule.IgnoreAction = (function() { + + /** + * Properties of an IgnoreAction. + * @memberof google.cloud.retail.v2.Rule + * @interface IIgnoreAction + * @property {Array.|null} [ignoreTerms] IgnoreAction ignoreTerms + */ + + /** + * Constructs a new IgnoreAction. + * @memberof google.cloud.retail.v2.Rule + * @classdesc Represents an IgnoreAction. + * @implements IIgnoreAction + * @constructor + * @param {google.cloud.retail.v2.Rule.IIgnoreAction=} [properties] Properties to set + */ + function IgnoreAction(properties) { + this.ignoreTerms = []; + 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]]; + } + + /** + * IgnoreAction ignoreTerms. + * @member {Array.} ignoreTerms + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @instance + */ + IgnoreAction.prototype.ignoreTerms = $util.emptyArray; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2.Rule.IIgnoreAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rule.IgnoreAction} IgnoreAction instance + */ + IgnoreAction.create = function create(properties) { + return new IgnoreAction(properties); + }; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2.Rule.IgnoreAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ignoreTerms != null && message.ignoreTerms.length) + for (var i = 0; i < message.ignoreTerms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ignoreTerms[i]); + return writer; + }; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rule.IgnoreAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.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.cloud.retail.v2.Rule.IgnoreAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.ignoreTerms && message.ignoreTerms.length)) + message.ignoreTerms = []; + message.ignoreTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IgnoreAction message. + * @function verify + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IgnoreAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ignoreTerms != null && message.hasOwnProperty("ignoreTerms")) { + if (!Array.isArray(message.ignoreTerms)) + return "ignoreTerms: array expected"; + for (var i = 0; i < message.ignoreTerms.length; ++i) + if (!$util.isString(message.ignoreTerms[i])) + return "ignoreTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rule.IgnoreAction} IgnoreAction + */ + IgnoreAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rule.IgnoreAction) + return object; + var message = new $root.google.cloud.retail.v2.Rule.IgnoreAction(); + if (object.ignoreTerms) { + if (!Array.isArray(object.ignoreTerms)) + throw TypeError(".google.cloud.retail.v2.Rule.IgnoreAction.ignoreTerms: array expected"); + message.ignoreTerms = []; + for (var i = 0; i < object.ignoreTerms.length; ++i) + message.ignoreTerms[i] = String(object.ignoreTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2.Rule.IgnoreAction} message IgnoreAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IgnoreAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ignoreTerms = []; + if (message.ignoreTerms && message.ignoreTerms.length) { + object.ignoreTerms = []; + for (var j = 0; j < message.ignoreTerms.length; ++j) + object.ignoreTerms[j] = message.ignoreTerms[j]; + } + return object; + }; + + /** + * Converts this IgnoreAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @instance + * @returns {Object.} JSON object + */ + IgnoreAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IgnoreAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rule.IgnoreAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IgnoreAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rule.IgnoreAction"; + }; + + return IgnoreAction; + })(); + + return Rule; + })(); + + v2.Audience = (function() { + + /** + * Properties of an Audience. + * @memberof google.cloud.retail.v2 + * @interface IAudience + * @property {Array.|null} [genders] Audience genders + * @property {Array.|null} [ageGroups] Audience ageGroups + */ + + /** + * Constructs a new Audience. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an Audience. + * @implements IAudience + * @constructor + * @param {google.cloud.retail.v2.IAudience=} [properties] Properties to set + */ + function Audience(properties) { + this.genders = []; + this.ageGroups = []; + 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]]; + } + + /** + * Audience genders. + * @member {Array.} genders + * @memberof google.cloud.retail.v2.Audience + * @instance + */ + Audience.prototype.genders = $util.emptyArray; + + /** + * Audience ageGroups. + * @member {Array.} ageGroups + * @memberof google.cloud.retail.v2.Audience + * @instance + */ + Audience.prototype.ageGroups = $util.emptyArray; + + /** + * Creates a new Audience instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {google.cloud.retail.v2.IAudience=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Audience} Audience instance + */ + Audience.create = function create(properties) { + return new Audience(properties); + }; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2.Audience.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {google.cloud.retail.v2.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.genders != null && message.genders.length) + for (var i = 0; i < message.genders.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.genders[i]); + if (message.ageGroups != null && message.ageGroups.length) + for (var i = 0; i < message.ageGroups.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ageGroups[i]); + return writer; + }; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Audience.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {google.cloud.retail.v2.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.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.cloud.retail.v2.Audience(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.genders && message.genders.length)) + message.genders = []; + message.genders.push(reader.string()); + break; + } + case 2: { + if (!(message.ageGroups && message.ageGroups.length)) + message.ageGroups = []; + message.ageGroups.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Audience message. + * @function verify + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Audience.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.genders != null && message.hasOwnProperty("genders")) { + if (!Array.isArray(message.genders)) + return "genders: array expected"; + for (var i = 0; i < message.genders.length; ++i) + if (!$util.isString(message.genders[i])) + return "genders: string[] expected"; + } + if (message.ageGroups != null && message.hasOwnProperty("ageGroups")) { + if (!Array.isArray(message.ageGroups)) + return "ageGroups: array expected"; + for (var i = 0; i < message.ageGroups.length; ++i) + if (!$util.isString(message.ageGroups[i])) + return "ageGroups: string[] expected"; + } + return null; + }; + + /** + * Creates an Audience message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Audience} Audience + */ + Audience.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Audience) + return object; + var message = new $root.google.cloud.retail.v2.Audience(); + if (object.genders) { + if (!Array.isArray(object.genders)) + throw TypeError(".google.cloud.retail.v2.Audience.genders: array expected"); + message.genders = []; + for (var i = 0; i < object.genders.length; ++i) + message.genders[i] = String(object.genders[i]); + } + if (object.ageGroups) { + if (!Array.isArray(object.ageGroups)) + throw TypeError(".google.cloud.retail.v2.Audience.ageGroups: array expected"); + message.ageGroups = []; + for (var i = 0; i < object.ageGroups.length; ++i) + message.ageGroups[i] = String(object.ageGroups[i]); + } + return message; + }; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {google.cloud.retail.v2.Audience} message Audience + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Audience.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.genders = []; + object.ageGroups = []; + } + if (message.genders && message.genders.length) { + object.genders = []; + for (var j = 0; j < message.genders.length; ++j) + object.genders[j] = message.genders[j]; + } + if (message.ageGroups && message.ageGroups.length) { + object.ageGroups = []; + for (var j = 0; j < message.ageGroups.length; ++j) + object.ageGroups[j] = message.ageGroups[j]; + } + return object; + }; + + /** + * Converts this Audience to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Audience + * @instance + * @returns {Object.} JSON object + */ + Audience.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Audience + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Audience + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Audience.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Audience"; + }; + + return Audience; + })(); + + v2.ColorInfo = (function() { + + /** + * Properties of a ColorInfo. + * @memberof google.cloud.retail.v2 + * @interface IColorInfo + * @property {Array.|null} [colorFamilies] ColorInfo colorFamilies + * @property {Array.|null} [colors] ColorInfo colors + */ + + /** + * Constructs a new ColorInfo. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ColorInfo. + * @implements IColorInfo + * @constructor + * @param {google.cloud.retail.v2.IColorInfo=} [properties] Properties to set + */ + function ColorInfo(properties) { + this.colorFamilies = []; + this.colors = []; + 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]]; + } + + /** + * ColorInfo colorFamilies. + * @member {Array.} colorFamilies + * @memberof google.cloud.retail.v2.ColorInfo + * @instance + */ + ColorInfo.prototype.colorFamilies = $util.emptyArray; + + /** + * ColorInfo colors. + * @member {Array.} colors + * @memberof google.cloud.retail.v2.ColorInfo + * @instance + */ + ColorInfo.prototype.colors = $util.emptyArray; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {google.cloud.retail.v2.IColorInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ColorInfo} ColorInfo instance + */ + ColorInfo.create = function create(properties) { + return new ColorInfo(properties); + }; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2.ColorInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {google.cloud.retail.v2.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.colorFamilies != null && message.colorFamilies.length) + for (var i = 0; i < message.colorFamilies.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.colorFamilies[i]); + if (message.colors != null && message.colors.length) + for (var i = 0; i < message.colors.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.colors[i]); + return writer; + }; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ColorInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {google.cloud.retail.v2.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.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.cloud.retail.v2.ColorInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.colorFamilies && message.colorFamilies.length)) + message.colorFamilies = []; + message.colorFamilies.push(reader.string()); + break; + } + case 2: { + if (!(message.colors && message.colors.length)) + message.colors = []; + message.colors.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ColorInfo message. + * @function verify + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ColorInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.colorFamilies != null && message.hasOwnProperty("colorFamilies")) { + if (!Array.isArray(message.colorFamilies)) + return "colorFamilies: array expected"; + for (var i = 0; i < message.colorFamilies.length; ++i) + if (!$util.isString(message.colorFamilies[i])) + return "colorFamilies: string[] expected"; + } + if (message.colors != null && message.hasOwnProperty("colors")) { + if (!Array.isArray(message.colors)) + return "colors: array expected"; + for (var i = 0; i < message.colors.length; ++i) + if (!$util.isString(message.colors[i])) + return "colors: string[] expected"; + } + return null; + }; + + /** + * Creates a ColorInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ColorInfo} ColorInfo + */ + ColorInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ColorInfo) + return object; + var message = new $root.google.cloud.retail.v2.ColorInfo(); + if (object.colorFamilies) { + if (!Array.isArray(object.colorFamilies)) + throw TypeError(".google.cloud.retail.v2.ColorInfo.colorFamilies: array expected"); + message.colorFamilies = []; + for (var i = 0; i < object.colorFamilies.length; ++i) + message.colorFamilies[i] = String(object.colorFamilies[i]); + } + if (object.colors) { + if (!Array.isArray(object.colors)) + throw TypeError(".google.cloud.retail.v2.ColorInfo.colors: array expected"); + message.colors = []; + for (var i = 0; i < object.colors.length; ++i) + message.colors[i] = String(object.colors[i]); + } + return message; + }; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {google.cloud.retail.v2.ColorInfo} message ColorInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ColorInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.colorFamilies = []; + object.colors = []; + } + if (message.colorFamilies && message.colorFamilies.length) { + object.colorFamilies = []; + for (var j = 0; j < message.colorFamilies.length; ++j) + object.colorFamilies[j] = message.colorFamilies[j]; + } + if (message.colors && message.colors.length) { + object.colors = []; + for (var j = 0; j < message.colors.length; ++j) + object.colors[j] = message.colors[j]; + } + return object; + }; + + /** + * Converts this ColorInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ColorInfo + * @instance + * @returns {Object.} JSON object + */ + ColorInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ColorInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ColorInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ColorInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ColorInfo"; + }; + + return ColorInfo; + })(); + + v2.CustomAttribute = (function() { + + /** + * Properties of a CustomAttribute. + * @memberof google.cloud.retail.v2 + * @interface ICustomAttribute + * @property {Array.|null} [text] CustomAttribute text + * @property {Array.|null} [numbers] CustomAttribute numbers + * @property {boolean|null} [searchable] CustomAttribute searchable + * @property {boolean|null} [indexable] CustomAttribute indexable + */ + + /** + * Constructs a new CustomAttribute. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CustomAttribute. + * @implements ICustomAttribute + * @constructor + * @param {google.cloud.retail.v2.ICustomAttribute=} [properties] Properties to set + */ + function CustomAttribute(properties) { + this.text = []; + this.numbers = []; + 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]]; + } + + /** + * CustomAttribute text. + * @member {Array.} text + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + CustomAttribute.prototype.text = $util.emptyArray; + + /** + * CustomAttribute numbers. + * @member {Array.} numbers + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + CustomAttribute.prototype.numbers = $util.emptyArray; + + /** + * CustomAttribute searchable. + * @member {boolean|null|undefined} searchable + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + CustomAttribute.prototype.searchable = null; + + /** + * CustomAttribute indexable. + * @member {boolean|null|undefined} indexable + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + CustomAttribute.prototype.indexable = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CustomAttribute _searchable. + * @member {"searchable"|undefined} _searchable + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_searchable", { + get: $util.oneOfGetter($oneOfFields = ["searchable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CustomAttribute _indexable. + * @member {"indexable"|undefined} _indexable + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_indexable", { + get: $util.oneOfGetter($oneOfFields = ["indexable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {google.cloud.retail.v2.ICustomAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CustomAttribute} CustomAttribute instance + */ + CustomAttribute.create = function create(properties) { + return new CustomAttribute(properties); + }; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2.CustomAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {google.cloud.retail.v2.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.text != null && message.text.length) + for (var i = 0; i < message.text.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.text[i]); + if (message.numbers != null && message.numbers.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.numbers.length; ++i) + writer.double(message.numbers[i]); + writer.ldelim(); + } + if (message.searchable != null && Object.hasOwnProperty.call(message, "searchable")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.searchable); + if (message.indexable != null && Object.hasOwnProperty.call(message, "indexable")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.indexable); + return writer; + }; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CustomAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {google.cloud.retail.v2.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.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.cloud.retail.v2.CustomAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.text && message.text.length)) + message.text = []; + message.text.push(reader.string()); + break; + } + case 2: { + if (!(message.numbers && message.numbers.length)) + message.numbers = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.numbers.push(reader.double()); + } else + message.numbers.push(reader.double()); + break; + } + case 3: { + message.searchable = reader.bool(); + break; + } + case 4: { + message.indexable = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomAttribute message. + * @function verify + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.text != null && message.hasOwnProperty("text")) { + if (!Array.isArray(message.text)) + return "text: array expected"; + for (var i = 0; i < message.text.length; ++i) + if (!$util.isString(message.text[i])) + return "text: string[] expected"; + } + if (message.numbers != null && message.hasOwnProperty("numbers")) { + if (!Array.isArray(message.numbers)) + return "numbers: array expected"; + for (var i = 0; i < message.numbers.length; ++i) + if (typeof message.numbers[i] !== "number") + return "numbers: number[] expected"; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + properties._searchable = 1; + if (typeof message.searchable !== "boolean") + return "searchable: boolean expected"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + properties._indexable = 1; + if (typeof message.indexable !== "boolean") + return "indexable: boolean expected"; + } + return null; + }; + + /** + * Creates a CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CustomAttribute} CustomAttribute + */ + CustomAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CustomAttribute) + return object; + var message = new $root.google.cloud.retail.v2.CustomAttribute(); + if (object.text) { + if (!Array.isArray(object.text)) + throw TypeError(".google.cloud.retail.v2.CustomAttribute.text: array expected"); + message.text = []; + for (var i = 0; i < object.text.length; ++i) + message.text[i] = String(object.text[i]); + } + if (object.numbers) { + if (!Array.isArray(object.numbers)) + throw TypeError(".google.cloud.retail.v2.CustomAttribute.numbers: array expected"); + message.numbers = []; + for (var i = 0; i < object.numbers.length; ++i) + message.numbers[i] = Number(object.numbers[i]); + } + if (object.searchable != null) + message.searchable = Boolean(object.searchable); + if (object.indexable != null) + message.indexable = Boolean(object.indexable); + return message; + }; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {google.cloud.retail.v2.CustomAttribute} message CustomAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.text = []; + object.numbers = []; + } + if (message.text && message.text.length) { + object.text = []; + for (var j = 0; j < message.text.length; ++j) + object.text[j] = message.text[j]; + } + if (message.numbers && message.numbers.length) { + object.numbers = []; + for (var j = 0; j < message.numbers.length; ++j) + object.numbers[j] = options.json && !isFinite(message.numbers[j]) ? String(message.numbers[j]) : message.numbers[j]; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + object.searchable = message.searchable; + if (options.oneofs) + object._searchable = "searchable"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + object.indexable = message.indexable; + if (options.oneofs) + object._indexable = "indexable"; + } + return object; + }; + + /** + * Converts this CustomAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CustomAttribute + * @instance + * @returns {Object.} JSON object + */ + CustomAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CustomAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CustomAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CustomAttribute"; + }; + + return CustomAttribute; + })(); + + v2.FulfillmentInfo = (function() { + + /** + * Properties of a FulfillmentInfo. + * @memberof google.cloud.retail.v2 + * @interface IFulfillmentInfo + * @property {string|null} [type] FulfillmentInfo type + * @property {Array.|null} [placeIds] FulfillmentInfo placeIds + */ + + /** + * Constructs a new FulfillmentInfo. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a FulfillmentInfo. + * @implements IFulfillmentInfo + * @constructor + * @param {google.cloud.retail.v2.IFulfillmentInfo=} [properties] Properties to set + */ + function FulfillmentInfo(properties) { + this.placeIds = []; + 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]]; + } + + /** + * FulfillmentInfo type. + * @member {string} type + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.type = ""; + + /** + * FulfillmentInfo placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.placeIds = $util.emptyArray; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2.IFulfillmentInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2.FulfillmentInfo} FulfillmentInfo instance + */ + FulfillmentInfo.create = function create(properties) { + return new FulfillmentInfo(properties); + }; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2.FulfillmentInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + return writer; + }; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.FulfillmentInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.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.cloud.retail.v2.FulfillmentInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FulfillmentInfo message. + * @function verify + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FulfillmentInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + return null; + }; + + /** + * Creates a FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.FulfillmentInfo} FulfillmentInfo + */ + FulfillmentInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.FulfillmentInfo) + return object; + var message = new $root.google.cloud.retail.v2.FulfillmentInfo(); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2.FulfillmentInfo.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2.FulfillmentInfo} message FulfillmentInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FulfillmentInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) + object.type = ""; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + return object; + }; + + /** + * Converts this FulfillmentInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @instance + * @returns {Object.} JSON object + */ + FulfillmentInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FulfillmentInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2.FulfillmentInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FulfillmentInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.FulfillmentInfo"; + }; + + return FulfillmentInfo; + })(); + + v2.Image = (function() { + + /** + * Properties of an Image. + * @memberof google.cloud.retail.v2 + * @interface IImage + * @property {string|null} [uri] Image uri + * @property {number|null} [height] Image height + * @property {number|null} [width] Image width + */ + + /** + * Constructs a new Image. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an Image. + * @implements IImage + * @constructor + * @param {google.cloud.retail.v2.IImage=} [properties] Properties to set + */ + function Image(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]]; + } + + /** + * Image uri. + * @member {string} uri + * @memberof google.cloud.retail.v2.Image + * @instance + */ + Image.prototype.uri = ""; + + /** + * Image height. + * @member {number} height + * @memberof google.cloud.retail.v2.Image + * @instance + */ + Image.prototype.height = 0; + + /** + * Image width. + * @member {number} width + * @memberof google.cloud.retail.v2.Image + * @instance + */ + Image.prototype.width = 0; + + /** + * Creates a new Image instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Image + * @static + * @param {google.cloud.retail.v2.IImage=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Image} Image instance + */ + Image.create = function create(properties) { + return new Image(properties); + }; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2.Image.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Image + * @static + * @param {google.cloud.retail.v2.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri); + if (message.height != null && Object.hasOwnProperty.call(message, "height")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.height); + if (message.width != null && Object.hasOwnProperty.call(message, "width")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.width); + return writer; + }; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Image.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Image + * @static + * @param {google.cloud.retail.v2.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Image message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.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.cloud.retail.v2.Image(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.uri = reader.string(); + break; + } + case 2: { + message.height = reader.int32(); + break; + } + case 3: { + message.width = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Image message. + * @function verify + * @memberof google.cloud.retail.v2.Image + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Image.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.height != null && message.hasOwnProperty("height")) + if (!$util.isInteger(message.height)) + return "height: integer expected"; + if (message.width != null && message.hasOwnProperty("width")) + if (!$util.isInteger(message.width)) + return "width: integer expected"; + return null; + }; + + /** + * Creates an Image message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Image + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Image} Image + */ + Image.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Image) + return object; + var message = new $root.google.cloud.retail.v2.Image(); + if (object.uri != null) + message.uri = String(object.uri); + if (object.height != null) + message.height = object.height | 0; + if (object.width != null) + message.width = object.width | 0; + return message; + }; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Image + * @static + * @param {google.cloud.retail.v2.Image} message Image + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Image.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.uri = ""; + object.height = 0; + object.width = 0; + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.height != null && message.hasOwnProperty("height")) + object.height = message.height; + if (message.width != null && message.hasOwnProperty("width")) + object.width = message.width; + return object; + }; + + /** + * Converts this Image to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Image + * @instance + * @returns {Object.} JSON object + */ + Image.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Image + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Image + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Image.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Image"; + }; + + return Image; + })(); + + v2.Interval = (function() { + + /** + * Properties of an Interval. + * @memberof google.cloud.retail.v2 + * @interface IInterval + * @property {number|null} [minimum] Interval minimum + * @property {number|null} [exclusiveMinimum] Interval exclusiveMinimum + * @property {number|null} [maximum] Interval maximum + * @property {number|null} [exclusiveMaximum] Interval exclusiveMaximum + */ + + /** + * Constructs a new Interval. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an Interval. + * @implements IInterval + * @constructor + * @param {google.cloud.retail.v2.IInterval=} [properties] Properties to set + */ + function Interval(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]]; + } + + /** + * Interval minimum. + * @member {number|null|undefined} minimum + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Interval.prototype.minimum = null; + + /** + * Interval exclusiveMinimum. + * @member {number|null|undefined} exclusiveMinimum + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Interval.prototype.exclusiveMinimum = null; + + /** + * Interval maximum. + * @member {number|null|undefined} maximum + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Interval.prototype.maximum = null; + + /** + * Interval exclusiveMaximum. + * @member {number|null|undefined} exclusiveMaximum + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Interval.prototype.exclusiveMaximum = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Interval min. + * @member {"minimum"|"exclusiveMinimum"|undefined} min + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "min", { + get: $util.oneOfGetter($oneOfFields = ["minimum", "exclusiveMinimum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Interval max. + * @member {"maximum"|"exclusiveMaximum"|undefined} max + * @memberof google.cloud.retail.v2.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "max", { + get: $util.oneOfGetter($oneOfFields = ["maximum", "exclusiveMaximum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Interval instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {google.cloud.retail.v2.IInterval=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Interval} Interval instance + */ + Interval.create = function create(properties) { + return new Interval(properties); + }; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2.Interval.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {google.cloud.retail.v2.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.minimum != null && Object.hasOwnProperty.call(message, "minimum")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.minimum); + if (message.exclusiveMinimum != null && Object.hasOwnProperty.call(message, "exclusiveMinimum")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.exclusiveMinimum); + if (message.maximum != null && Object.hasOwnProperty.call(message, "maximum")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.maximum); + if (message.exclusiveMaximum != null && Object.hasOwnProperty.call(message, "exclusiveMaximum")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.exclusiveMaximum); + return writer; + }; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Interval.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {google.cloud.retail.v2.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.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.cloud.retail.v2.Interval(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.minimum = reader.double(); + break; + } + case 2: { + message.exclusiveMinimum = reader.double(); + break; + } + case 3: { + message.maximum = reader.double(); + break; + } + case 4: { + message.exclusiveMaximum = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Interval message. + * @function verify + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Interval.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + properties.min = 1; + if (typeof message.minimum !== "number") + return "minimum: number expected"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + if (properties.min === 1) + return "min: multiple values"; + properties.min = 1; + if (typeof message.exclusiveMinimum !== "number") + return "exclusiveMinimum: number expected"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + properties.max = 1; + if (typeof message.maximum !== "number") + return "maximum: number expected"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + if (properties.max === 1) + return "max: multiple values"; + properties.max = 1; + if (typeof message.exclusiveMaximum !== "number") + return "exclusiveMaximum: number expected"; + } + return null; + }; + + /** + * Creates an Interval message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Interval} Interval + */ + Interval.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Interval) + return object; + var message = new $root.google.cloud.retail.v2.Interval(); + if (object.minimum != null) + message.minimum = Number(object.minimum); + if (object.exclusiveMinimum != null) + message.exclusiveMinimum = Number(object.exclusiveMinimum); + if (object.maximum != null) + message.maximum = Number(object.maximum); + if (object.exclusiveMaximum != null) + message.exclusiveMaximum = Number(object.exclusiveMaximum); + return message; + }; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {google.cloud.retail.v2.Interval} message Interval + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Interval.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = options.json && !isFinite(message.minimum) ? String(message.minimum) : message.minimum; + if (options.oneofs) + object.min = "minimum"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + object.exclusiveMinimum = options.json && !isFinite(message.exclusiveMinimum) ? String(message.exclusiveMinimum) : message.exclusiveMinimum; + if (options.oneofs) + object.min = "exclusiveMinimum"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = options.json && !isFinite(message.maximum) ? String(message.maximum) : message.maximum; + if (options.oneofs) + object.max = "maximum"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + object.exclusiveMaximum = options.json && !isFinite(message.exclusiveMaximum) ? String(message.exclusiveMaximum) : message.exclusiveMaximum; + if (options.oneofs) + object.max = "exclusiveMaximum"; + } + return object; + }; + + /** + * Converts this Interval to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Interval + * @instance + * @returns {Object.} JSON object + */ + Interval.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Interval + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Interval + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Interval.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Interval"; + }; + + return Interval; + })(); + + v2.PriceInfo = (function() { + + /** + * Properties of a PriceInfo. + * @memberof google.cloud.retail.v2 + * @interface IPriceInfo + * @property {string|null} [currencyCode] PriceInfo currencyCode + * @property {number|null} [price] PriceInfo price + * @property {number|null} [originalPrice] PriceInfo originalPrice + * @property {number|null} [cost] PriceInfo cost + * @property {google.protobuf.ITimestamp|null} [priceEffectiveTime] PriceInfo priceEffectiveTime + * @property {google.protobuf.ITimestamp|null} [priceExpireTime] PriceInfo priceExpireTime + * @property {google.cloud.retail.v2.PriceInfo.IPriceRange|null} [priceRange] PriceInfo priceRange + */ + + /** + * Constructs a new PriceInfo. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PriceInfo. + * @implements IPriceInfo + * @constructor + * @param {google.cloud.retail.v2.IPriceInfo=} [properties] Properties to set + */ + function PriceInfo(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]]; + } + + /** + * PriceInfo currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.currencyCode = ""; + + /** + * PriceInfo price. + * @member {number} price + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.price = 0; + + /** + * PriceInfo originalPrice. + * @member {number} originalPrice + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.originalPrice = 0; + + /** + * PriceInfo cost. + * @member {number} cost + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.cost = 0; + + /** + * PriceInfo priceEffectiveTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceEffectiveTime + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.priceEffectiveTime = null; + + /** + * PriceInfo priceExpireTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceExpireTime + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.priceExpireTime = null; + + /** + * PriceInfo priceRange. + * @member {google.cloud.retail.v2.PriceInfo.IPriceRange|null|undefined} priceRange + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + */ + PriceInfo.prototype.priceRange = null; + + /** + * Creates a new PriceInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {google.cloud.retail.v2.IPriceInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PriceInfo} PriceInfo instance + */ + PriceInfo.create = function create(properties) { + return new PriceInfo(properties); + }; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {google.cloud.retail.v2.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.currencyCode); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.price); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.originalPrice); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.priceEffectiveTime != null && Object.hasOwnProperty.call(message, "priceEffectiveTime")) + $root.google.protobuf.Timestamp.encode(message.priceEffectiveTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.priceExpireTime != null && Object.hasOwnProperty.call(message, "priceExpireTime")) + $root.google.protobuf.Timestamp.encode(message.priceExpireTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.priceRange != null && Object.hasOwnProperty.call(message, "priceRange")) + $root.google.cloud.retail.v2.PriceInfo.PriceRange.encode(message.priceRange, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {google.cloud.retail.v2.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.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.cloud.retail.v2.PriceInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.currencyCode = reader.string(); + break; + } + case 2: { + message.price = reader.float(); + break; + } + case 3: { + message.originalPrice = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.priceEffectiveTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.priceExpireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 7: { + message.priceRange = $root.google.cloud.retail.v2.PriceInfo.PriceRange.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceInfo message. + * @function verify + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + if (message.price != null && message.hasOwnProperty("price")) + if (typeof message.price !== "number") + return "price: number expected"; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + if (typeof message.originalPrice !== "number") + return "originalPrice: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceEffectiveTime); + if (error) + return "priceEffectiveTime." + error; + } + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceExpireTime); + if (error) + return "priceExpireTime." + error; + } + if (message.priceRange != null && message.hasOwnProperty("priceRange")) { + var error = $root.google.cloud.retail.v2.PriceInfo.PriceRange.verify(message.priceRange); + if (error) + return "priceRange." + error; + } + return null; + }; + + /** + * Creates a PriceInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PriceInfo} PriceInfo + */ + PriceInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PriceInfo) + return object; + var message = new $root.google.cloud.retail.v2.PriceInfo(); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + if (object.price != null) + message.price = Number(object.price); + if (object.originalPrice != null) + message.originalPrice = Number(object.originalPrice); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.priceEffectiveTime != null) { + if (typeof object.priceEffectiveTime !== "object") + throw TypeError(".google.cloud.retail.v2.PriceInfo.priceEffectiveTime: object expected"); + message.priceEffectiveTime = $root.google.protobuf.Timestamp.fromObject(object.priceEffectiveTime); + } + if (object.priceExpireTime != null) { + if (typeof object.priceExpireTime !== "object") + throw TypeError(".google.cloud.retail.v2.PriceInfo.priceExpireTime: object expected"); + message.priceExpireTime = $root.google.protobuf.Timestamp.fromObject(object.priceExpireTime); + } + if (object.priceRange != null) { + if (typeof object.priceRange !== "object") + throw TypeError(".google.cloud.retail.v2.PriceInfo.priceRange: object expected"); + message.priceRange = $root.google.cloud.retail.v2.PriceInfo.PriceRange.fromObject(object.priceRange); + } + return message; + }; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {google.cloud.retail.v2.PriceInfo} message PriceInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.currencyCode = ""; + object.price = 0; + object.originalPrice = 0; + object.cost = 0; + object.priceEffectiveTime = null; + object.priceExpireTime = null; + object.priceRange = null; + } + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + if (message.price != null && message.hasOwnProperty("price")) + object.price = options.json && !isFinite(message.price) ? String(message.price) : message.price; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = options.json && !isFinite(message.originalPrice) ? String(message.originalPrice) : message.originalPrice; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) + object.priceEffectiveTime = $root.google.protobuf.Timestamp.toObject(message.priceEffectiveTime, options); + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) + object.priceExpireTime = $root.google.protobuf.Timestamp.toObject(message.priceExpireTime, options); + if (message.priceRange != null && message.hasOwnProperty("priceRange")) + object.priceRange = $root.google.cloud.retail.v2.PriceInfo.PriceRange.toObject(message.priceRange, options); + return object; + }; + + /** + * Converts this PriceInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PriceInfo + * @instance + * @returns {Object.} JSON object + */ + PriceInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PriceInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PriceInfo"; + }; + + PriceInfo.PriceRange = (function() { + + /** + * Properties of a PriceRange. + * @memberof google.cloud.retail.v2.PriceInfo + * @interface IPriceRange + * @property {google.cloud.retail.v2.IInterval|null} [price] PriceRange price + * @property {google.cloud.retail.v2.IInterval|null} [originalPrice] PriceRange originalPrice + */ + + /** + * Constructs a new PriceRange. + * @memberof google.cloud.retail.v2.PriceInfo + * @classdesc Represents a PriceRange. + * @implements IPriceRange + * @constructor + * @param {google.cloud.retail.v2.PriceInfo.IPriceRange=} [properties] Properties to set + */ + function PriceRange(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]]; + } + + /** + * PriceRange price. + * @member {google.cloud.retail.v2.IInterval|null|undefined} price + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.price = null; + + /** + * PriceRange originalPrice. + * @member {google.cloud.retail.v2.IInterval|null|undefined} originalPrice + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.originalPrice = null; + + /** + * Creates a new PriceRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2.PriceInfo.IPriceRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PriceInfo.PriceRange} PriceRange instance + */ + PriceRange.create = function create(properties) { + return new PriceRange(properties); + }; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.PriceRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + $root.google.cloud.retail.v2.Interval.encode(message.price, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + $root.google.cloud.retail.v2.Interval.encode(message.originalPrice, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PriceInfo.PriceRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.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.cloud.retail.v2.PriceInfo.PriceRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.price = $root.google.cloud.retail.v2.Interval.decode(reader, reader.uint32()); + break; + } + case 2: { + message.originalPrice = $root.google.cloud.retail.v2.Interval.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceRange message. + * @function verify + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.price != null && message.hasOwnProperty("price")) { + var error = $root.google.cloud.retail.v2.Interval.verify(message.price); + if (error) + return "price." + error; + } + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) { + var error = $root.google.cloud.retail.v2.Interval.verify(message.originalPrice); + if (error) + return "originalPrice." + error; + } + return null; + }; + + /** + * Creates a PriceRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PriceInfo.PriceRange} PriceRange + */ + PriceRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PriceInfo.PriceRange) + return object; + var message = new $root.google.cloud.retail.v2.PriceInfo.PriceRange(); + if (object.price != null) { + if (typeof object.price !== "object") + throw TypeError(".google.cloud.retail.v2.PriceInfo.PriceRange.price: object expected"); + message.price = $root.google.cloud.retail.v2.Interval.fromObject(object.price); + } + if (object.originalPrice != null) { + if (typeof object.originalPrice !== "object") + throw TypeError(".google.cloud.retail.v2.PriceInfo.PriceRange.originalPrice: object expected"); + message.originalPrice = $root.google.cloud.retail.v2.Interval.fromObject(object.originalPrice); + } + return message; + }; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2.PriceInfo.PriceRange} message PriceRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.price = null; + object.originalPrice = null; + } + if (message.price != null && message.hasOwnProperty("price")) + object.price = $root.google.cloud.retail.v2.Interval.toObject(message.price, options); + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = $root.google.cloud.retail.v2.Interval.toObject(message.originalPrice, options); + return object; + }; + + /** + * Converts this PriceRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @instance + * @returns {Object.} JSON object + */ + PriceRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PriceInfo.PriceRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PriceInfo.PriceRange"; + }; + + return PriceRange; + })(); + + return PriceInfo; + })(); + + v2.Rating = (function() { + + /** + * Properties of a Rating. + * @memberof google.cloud.retail.v2 + * @interface IRating + * @property {number|null} [ratingCount] Rating ratingCount + * @property {number|null} [averageRating] Rating averageRating + * @property {Array.|null} [ratingHistogram] Rating ratingHistogram + */ + + /** + * Constructs a new Rating. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Rating. + * @implements IRating + * @constructor + * @param {google.cloud.retail.v2.IRating=} [properties] Properties to set + */ + function Rating(properties) { + this.ratingHistogram = []; + 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]]; + } + + /** + * Rating ratingCount. + * @member {number} ratingCount + * @memberof google.cloud.retail.v2.Rating + * @instance + */ + Rating.prototype.ratingCount = 0; + + /** + * Rating averageRating. + * @member {number} averageRating + * @memberof google.cloud.retail.v2.Rating + * @instance + */ + Rating.prototype.averageRating = 0; + + /** + * Rating ratingHistogram. + * @member {Array.} ratingHistogram + * @memberof google.cloud.retail.v2.Rating + * @instance + */ + Rating.prototype.ratingHistogram = $util.emptyArray; + + /** + * Creates a new Rating instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {google.cloud.retail.v2.IRating=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Rating} Rating instance + */ + Rating.create = function create(properties) { + return new Rating(properties); + }; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2.Rating.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {google.cloud.retail.v2.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ratingCount != null && Object.hasOwnProperty.call(message, "ratingCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ratingCount); + if (message.averageRating != null && Object.hasOwnProperty.call(message, "averageRating")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.averageRating); + if (message.ratingHistogram != null && message.ratingHistogram.length) { + writer.uint32(/* id 3, wireType 2 =*/26).fork(); + for (var i = 0; i < message.ratingHistogram.length; ++i) + writer.int32(message.ratingHistogram[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Rating.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {google.cloud.retail.v2.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.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.cloud.retail.v2.Rating(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ratingCount = reader.int32(); + break; + } + case 2: { + message.averageRating = reader.float(); + break; + } + case 3: { + if (!(message.ratingHistogram && message.ratingHistogram.length)) + message.ratingHistogram = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.ratingHistogram.push(reader.int32()); + } else + message.ratingHistogram.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rating message. + * @function verify + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rating.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + if (!$util.isInteger(message.ratingCount)) + return "ratingCount: integer expected"; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + if (typeof message.averageRating !== "number") + return "averageRating: number expected"; + if (message.ratingHistogram != null && message.hasOwnProperty("ratingHistogram")) { + if (!Array.isArray(message.ratingHistogram)) + return "ratingHistogram: array expected"; + for (var i = 0; i < message.ratingHistogram.length; ++i) + if (!$util.isInteger(message.ratingHistogram[i])) + return "ratingHistogram: integer[] expected"; + } + return null; + }; + + /** + * Creates a Rating message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Rating} Rating + */ + Rating.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Rating) + return object; + var message = new $root.google.cloud.retail.v2.Rating(); + if (object.ratingCount != null) + message.ratingCount = object.ratingCount | 0; + if (object.averageRating != null) + message.averageRating = Number(object.averageRating); + if (object.ratingHistogram) { + if (!Array.isArray(object.ratingHistogram)) + throw TypeError(".google.cloud.retail.v2.Rating.ratingHistogram: array expected"); + message.ratingHistogram = []; + for (var i = 0; i < object.ratingHistogram.length; ++i) + message.ratingHistogram[i] = object.ratingHistogram[i] | 0; + } + return message; + }; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {google.cloud.retail.v2.Rating} message Rating + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rating.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ratingHistogram = []; + if (options.defaults) { + object.ratingCount = 0; + object.averageRating = 0; + } + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + object.ratingCount = message.ratingCount; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + object.averageRating = options.json && !isFinite(message.averageRating) ? String(message.averageRating) : message.averageRating; + if (message.ratingHistogram && message.ratingHistogram.length) { + object.ratingHistogram = []; + for (var j = 0; j < message.ratingHistogram.length; ++j) + object.ratingHistogram[j] = message.ratingHistogram[j]; + } + return object; + }; + + /** + * Converts this Rating to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Rating + * @instance + * @returns {Object.} JSON object + */ + Rating.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rating + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Rating + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rating.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Rating"; + }; + + return Rating; + })(); + + v2.UserInfo = (function() { + + /** + * Properties of a UserInfo. + * @memberof google.cloud.retail.v2 + * @interface IUserInfo + * @property {string|null} [userId] UserInfo userId + * @property {string|null} [ipAddress] UserInfo ipAddress + * @property {string|null} [userAgent] UserInfo userAgent + * @property {boolean|null} [directUserRequest] UserInfo directUserRequest + */ + + /** + * Constructs a new UserInfo. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserInfo. + * @implements IUserInfo + * @constructor + * @param {google.cloud.retail.v2.IUserInfo=} [properties] Properties to set + */ + function UserInfo(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]]; + } + + /** + * UserInfo userId. + * @member {string} userId + * @memberof google.cloud.retail.v2.UserInfo + * @instance + */ + UserInfo.prototype.userId = ""; + + /** + * UserInfo ipAddress. + * @member {string} ipAddress + * @memberof google.cloud.retail.v2.UserInfo + * @instance + */ + UserInfo.prototype.ipAddress = ""; + + /** + * UserInfo userAgent. + * @member {string} userAgent + * @memberof google.cloud.retail.v2.UserInfo + * @instance + */ + UserInfo.prototype.userAgent = ""; + + /** + * UserInfo directUserRequest. + * @member {boolean} directUserRequest + * @memberof google.cloud.retail.v2.UserInfo + * @instance + */ + UserInfo.prototype.directUserRequest = false; + + /** + * Creates a new UserInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {google.cloud.retail.v2.IUserInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UserInfo} UserInfo instance + */ + UserInfo.create = function create(properties) { + return new UserInfo(properties); + }; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2.UserInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {google.cloud.retail.v2.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userId != null && Object.hasOwnProperty.call(message, "userId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.userId); + if (message.ipAddress != null && Object.hasOwnProperty.call(message, "ipAddress")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ipAddress); + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.userAgent); + if (message.directUserRequest != null && Object.hasOwnProperty.call(message, "directUserRequest")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.directUserRequest); + return writer; + }; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {google.cloud.retail.v2.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.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.cloud.retail.v2.UserInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userId = reader.string(); + break; + } + case 2: { + message.ipAddress = reader.string(); + break; + } + case 3: { + message.userAgent = reader.string(); + break; + } + case 4: { + message.directUserRequest = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserInfo message. + * @function verify + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userId != null && message.hasOwnProperty("userId")) + if (!$util.isString(message.userId)) + return "userId: string expected"; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + if (!$util.isString(message.ipAddress)) + return "ipAddress: string expected"; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + if (!$util.isString(message.userAgent)) + return "userAgent: string expected"; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + if (typeof message.directUserRequest !== "boolean") + return "directUserRequest: boolean expected"; + return null; + }; + + /** + * Creates a UserInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UserInfo} UserInfo + */ + UserInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UserInfo) + return object; + var message = new $root.google.cloud.retail.v2.UserInfo(); + if (object.userId != null) + message.userId = String(object.userId); + if (object.ipAddress != null) + message.ipAddress = String(object.ipAddress); + if (object.userAgent != null) + message.userAgent = String(object.userAgent); + if (object.directUserRequest != null) + message.directUserRequest = Boolean(object.directUserRequest); + return message; + }; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {google.cloud.retail.v2.UserInfo} message UserInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.userId = ""; + object.ipAddress = ""; + object.userAgent = ""; + object.directUserRequest = false; + } + if (message.userId != null && message.hasOwnProperty("userId")) + object.userId = message.userId; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + object.ipAddress = message.ipAddress; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + object.userAgent = message.userAgent; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + object.directUserRequest = message.directUserRequest; + return object; + }; + + /** + * Converts this UserInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UserInfo + * @instance + * @returns {Object.} JSON object + */ + UserInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UserInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UserInfo"; + }; + + return UserInfo; + })(); + + v2.LocalInventory = (function() { + + /** + * Properties of a LocalInventory. + * @memberof google.cloud.retail.v2 + * @interface ILocalInventory + * @property {string|null} [placeId] LocalInventory placeId + * @property {google.cloud.retail.v2.IPriceInfo|null} [priceInfo] LocalInventory priceInfo + * @property {Object.|null} [attributes] LocalInventory attributes + * @property {Array.|null} [fulfillmentTypes] LocalInventory fulfillmentTypes + */ + + /** + * Constructs a new LocalInventory. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a LocalInventory. + * @implements ILocalInventory + * @constructor + * @param {google.cloud.retail.v2.ILocalInventory=} [properties] Properties to set + */ + function LocalInventory(properties) { + this.attributes = {}; + this.fulfillmentTypes = []; + 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]]; + } + + /** + * LocalInventory placeId. + * @member {string} placeId + * @memberof google.cloud.retail.v2.LocalInventory + * @instance + */ + LocalInventory.prototype.placeId = ""; + + /** + * LocalInventory priceInfo. + * @member {google.cloud.retail.v2.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2.LocalInventory + * @instance + */ + LocalInventory.prototype.priceInfo = null; + + /** + * LocalInventory attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2.LocalInventory + * @instance + */ + LocalInventory.prototype.attributes = $util.emptyObject; + + /** + * LocalInventory fulfillmentTypes. + * @member {Array.} fulfillmentTypes + * @memberof google.cloud.retail.v2.LocalInventory + * @instance + */ + LocalInventory.prototype.fulfillmentTypes = $util.emptyArray; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {google.cloud.retail.v2.ILocalInventory=} [properties] Properties to set + * @returns {google.cloud.retail.v2.LocalInventory} LocalInventory instance + */ + LocalInventory.create = function create(properties) { + return new LocalInventory(properties); + }; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2.LocalInventory.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {google.cloud.retail.v2.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placeId != null && Object.hasOwnProperty.call(message, "placeId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placeId); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.fulfillmentTypes != null && message.fulfillmentTypes.length) + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.fulfillmentTypes[i]); + return writer; + }; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2.LocalInventory.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {google.cloud.retail.v2.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.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.cloud.retail.v2.LocalInventory(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placeId = reader.string(); + break; + } + case 2: { + message.priceInfo = $root.google.cloud.retail.v2.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 3: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 4: { + if (!(message.fulfillmentTypes && message.fulfillmentTypes.length)) + message.fulfillmentTypes = []; + message.fulfillmentTypes.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LocalInventory message. + * @function verify + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LocalInventory.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placeId != null && message.hasOwnProperty("placeId")) + if (!$util.isString(message.placeId)) + return "placeId: string expected"; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.fulfillmentTypes != null && message.hasOwnProperty("fulfillmentTypes")) { + if (!Array.isArray(message.fulfillmentTypes)) + return "fulfillmentTypes: array expected"; + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + if (!$util.isString(message.fulfillmentTypes[i])) + return "fulfillmentTypes: string[] expected"; + } + return null; + }; + + /** + * Creates a LocalInventory message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.LocalInventory} LocalInventory + */ + LocalInventory.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.LocalInventory) + return object; + var message = new $root.google.cloud.retail.v2.LocalInventory(); + if (object.placeId != null) + message.placeId = String(object.placeId); + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2.LocalInventory.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2.PriceInfo.fromObject(object.priceInfo); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2.LocalInventory.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.LocalInventory.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.fulfillmentTypes) { + if (!Array.isArray(object.fulfillmentTypes)) + throw TypeError(".google.cloud.retail.v2.LocalInventory.fulfillmentTypes: array expected"); + message.fulfillmentTypes = []; + for (var i = 0; i < object.fulfillmentTypes.length; ++i) + message.fulfillmentTypes[i] = String(object.fulfillmentTypes[i]); + } + return message; + }; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {google.cloud.retail.v2.LocalInventory} message LocalInventory + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocalInventory.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fulfillmentTypes = []; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.placeId = ""; + object.priceInfo = null; + } + if (message.placeId != null && message.hasOwnProperty("placeId")) + object.placeId = message.placeId; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2.PriceInfo.toObject(message.priceInfo, options); + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.fulfillmentTypes && message.fulfillmentTypes.length) { + object.fulfillmentTypes = []; + for (var j = 0; j < message.fulfillmentTypes.length; ++j) + object.fulfillmentTypes[j] = message.fulfillmentTypes[j]; + } + return object; + }; + + /** + * Converts this LocalInventory to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.LocalInventory + * @instance + * @returns {Object.} JSON object + */ + LocalInventory.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LocalInventory + * @function getTypeUrl + * @memberof google.cloud.retail.v2.LocalInventory + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LocalInventory.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.LocalInventory"; + }; + + return LocalInventory; + })(); + + v2.GcsSource = (function() { + + /** + * Properties of a GcsSource. + * @memberof google.cloud.retail.v2 + * @interface IGcsSource + * @property {Array.|null} [inputUris] GcsSource inputUris + * @property {string|null} [dataSchema] GcsSource dataSchema + */ + + /** + * Constructs a new GcsSource. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GcsSource. + * @implements IGcsSource + * @constructor + * @param {google.cloud.retail.v2.IGcsSource=} [properties] Properties to set + */ + function GcsSource(properties) { + this.inputUris = []; + 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]]; + } + + /** + * GcsSource inputUris. + * @member {Array.} inputUris + * @memberof google.cloud.retail.v2.GcsSource + * @instance + */ + GcsSource.prototype.inputUris = $util.emptyArray; + + /** + * GcsSource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2.GcsSource + * @instance + */ + GcsSource.prototype.dataSchema = ""; + + /** + * Creates a new GcsSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {google.cloud.retail.v2.IGcsSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GcsSource} GcsSource instance + */ + GcsSource.create = function create(properties) { + return new GcsSource(properties); + }; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2.GcsSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {google.cloud.retail.v2.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputUris != null && message.inputUris.length) + for (var i = 0; i < message.inputUris.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.inputUris[i]); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.dataSchema); + return writer; + }; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GcsSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {google.cloud.retail.v2.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.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.cloud.retail.v2.GcsSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.inputUris && message.inputUris.length)) + message.inputUris = []; + message.inputUris.push(reader.string()); + break; + } + case 2: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GcsSource message. + * @function verify + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GcsSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputUris != null && message.hasOwnProperty("inputUris")) { + if (!Array.isArray(message.inputUris)) + return "inputUris: array expected"; + for (var i = 0; i < message.inputUris.length; ++i) + if (!$util.isString(message.inputUris[i])) + return "inputUris: string[] expected"; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a GcsSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GcsSource} GcsSource + */ + GcsSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GcsSource) + return object; + var message = new $root.google.cloud.retail.v2.GcsSource(); + if (object.inputUris) { + if (!Array.isArray(object.inputUris)) + throw TypeError(".google.cloud.retail.v2.GcsSource.inputUris: array expected"); + message.inputUris = []; + for (var i = 0; i < object.inputUris.length; ++i) + message.inputUris[i] = String(object.inputUris[i]); + } + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {google.cloud.retail.v2.GcsSource} message GcsSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GcsSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputUris = []; + if (options.defaults) + object.dataSchema = ""; + if (message.inputUris && message.inputUris.length) { + object.inputUris = []; + for (var j = 0; j < message.inputUris.length; ++j) + object.inputUris[j] = message.inputUris[j]; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + return object; + }; + + /** + * Converts this GcsSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GcsSource + * @instance + * @returns {Object.} JSON object + */ + GcsSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GcsSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GcsSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GcsSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GcsSource"; + }; + + return GcsSource; + })(); + + v2.BigQuerySource = (function() { + + /** + * Properties of a BigQuerySource. + * @memberof google.cloud.retail.v2 + * @interface IBigQuerySource + * @property {google.type.IDate|null} [partitionDate] BigQuerySource partitionDate + * @property {string|null} [projectId] BigQuerySource projectId + * @property {string|null} [datasetId] BigQuerySource datasetId + * @property {string|null} [tableId] BigQuerySource tableId + * @property {string|null} [gcsStagingDir] BigQuerySource gcsStagingDir + * @property {string|null} [dataSchema] BigQuerySource dataSchema + */ + + /** + * Constructs a new BigQuerySource. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a BigQuerySource. + * @implements IBigQuerySource + * @constructor + * @param {google.cloud.retail.v2.IBigQuerySource=} [properties] Properties to set + */ + function BigQuerySource(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]]; + } + + /** + * BigQuerySource partitionDate. + * @member {google.type.IDate|null|undefined} partitionDate + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.partitionDate = null; + + /** + * BigQuerySource projectId. + * @member {string} projectId + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.projectId = ""; + + /** + * BigQuerySource datasetId. + * @member {string} datasetId + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.datasetId = ""; + + /** + * BigQuerySource tableId. + * @member {string} tableId + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.tableId = ""; + + /** + * BigQuerySource gcsStagingDir. + * @member {string} gcsStagingDir + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.gcsStagingDir = ""; + + /** + * BigQuerySource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + BigQuerySource.prototype.dataSchema = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BigQuerySource partition. + * @member {"partitionDate"|undefined} partition + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + */ + Object.defineProperty(BigQuerySource.prototype, "partition", { + get: $util.oneOfGetter($oneOfFields = ["partitionDate"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {google.cloud.retail.v2.IBigQuerySource=} [properties] Properties to set + * @returns {google.cloud.retail.v2.BigQuerySource} BigQuerySource instance + */ + BigQuerySource.create = function create(properties) { + return new BigQuerySource(properties); + }; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2.BigQuerySource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {google.cloud.retail.v2.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.datasetId != null && Object.hasOwnProperty.call(message, "datasetId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.datasetId); + if (message.tableId != null && Object.hasOwnProperty.call(message, "tableId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.tableId); + if (message.gcsStagingDir != null && Object.hasOwnProperty.call(message, "gcsStagingDir")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.gcsStagingDir); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.dataSchema); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.projectId); + if (message.partitionDate != null && Object.hasOwnProperty.call(message, "partitionDate")) + $root.google.type.Date.encode(message.partitionDate, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.BigQuerySource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {google.cloud.retail.v2.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.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.cloud.retail.v2.BigQuerySource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + message.partitionDate = $root.google.type.Date.decode(reader, reader.uint32()); + break; + } + case 5: { + message.projectId = reader.string(); + break; + } + case 1: { + message.datasetId = reader.string(); + break; + } + case 2: { + message.tableId = reader.string(); + break; + } + case 3: { + message.gcsStagingDir = reader.string(); + break; + } + case 4: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQuerySource message. + * @function verify + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQuerySource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + properties.partition = 1; + { + var error = $root.google.type.Date.verify(message.partitionDate); + if (error) + return "partitionDate." + error; + } + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + if (!$util.isString(message.datasetId)) + return "datasetId: string expected"; + if (message.tableId != null && message.hasOwnProperty("tableId")) + if (!$util.isString(message.tableId)) + return "tableId: string expected"; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + if (!$util.isString(message.gcsStagingDir)) + return "gcsStagingDir: string expected"; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.BigQuerySource} BigQuerySource + */ + BigQuerySource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.BigQuerySource) + return object; + var message = new $root.google.cloud.retail.v2.BigQuerySource(); + if (object.partitionDate != null) { + if (typeof object.partitionDate !== "object") + throw TypeError(".google.cloud.retail.v2.BigQuerySource.partitionDate: object expected"); + message.partitionDate = $root.google.type.Date.fromObject(object.partitionDate); + } + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.datasetId != null) + message.datasetId = String(object.datasetId); + if (object.tableId != null) + message.tableId = String(object.tableId); + if (object.gcsStagingDir != null) + message.gcsStagingDir = String(object.gcsStagingDir); + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {google.cloud.retail.v2.BigQuerySource} message BigQuerySource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQuerySource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.datasetId = ""; + object.tableId = ""; + object.gcsStagingDir = ""; + object.dataSchema = ""; + object.projectId = ""; + } + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + object.datasetId = message.datasetId; + if (message.tableId != null && message.hasOwnProperty("tableId")) + object.tableId = message.tableId; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + object.gcsStagingDir = message.gcsStagingDir; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + object.partitionDate = $root.google.type.Date.toObject(message.partitionDate, options); + if (options.oneofs) + object.partition = "partitionDate"; + } + return object; + }; + + /** + * Converts this BigQuerySource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.BigQuerySource + * @instance + * @returns {Object.} JSON object + */ + BigQuerySource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BigQuerySource + * @function getTypeUrl + * @memberof google.cloud.retail.v2.BigQuerySource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BigQuerySource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.BigQuerySource"; + }; + + return BigQuerySource; + })(); + + v2.ProductInlineSource = (function() { + + /** + * Properties of a ProductInlineSource. + * @memberof google.cloud.retail.v2 + * @interface IProductInlineSource + * @property {Array.|null} [products] ProductInlineSource products + */ + + /** + * Constructs a new ProductInlineSource. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ProductInlineSource. + * @implements IProductInlineSource + * @constructor + * @param {google.cloud.retail.v2.IProductInlineSource=} [properties] Properties to set + */ + function ProductInlineSource(properties) { + this.products = []; + 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]]; + } + + /** + * ProductInlineSource products. + * @member {Array.} products + * @memberof google.cloud.retail.v2.ProductInlineSource + * @instance + */ + ProductInlineSource.prototype.products = $util.emptyArray; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {google.cloud.retail.v2.IProductInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ProductInlineSource} ProductInlineSource instance + */ + ProductInlineSource.create = function create(properties) { + return new ProductInlineSource(properties); + }; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2.ProductInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {google.cloud.retail.v2.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2.Product.encode(message.products[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {google.cloud.retail.v2.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.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.cloud.retail.v2.ProductInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2.Product.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + return null; + }; + + /** + * Creates a ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ProductInlineSource} ProductInlineSource + */ + ProductInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ProductInlineSource) + return object; + var message = new $root.google.cloud.retail.v2.ProductInlineSource(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2.ProductInlineSource.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ProductInlineSource.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2.Product.fromObject(object.products[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {google.cloud.retail.v2.ProductInlineSource} message ProductInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2.Product.toObject(message.products[j], options); + } + return object; + }; + + /** + * Converts this ProductInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ProductInlineSource + * @instance + * @returns {Object.} JSON object + */ + ProductInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ProductInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ProductInlineSource"; + }; + + return ProductInlineSource; + })(); + + v2.UserEventInlineSource = (function() { + + /** + * Properties of a UserEventInlineSource. + * @memberof google.cloud.retail.v2 + * @interface IUserEventInlineSource + * @property {Array.|null} [userEvents] UserEventInlineSource userEvents + */ + + /** + * Constructs a new UserEventInlineSource. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserEventInlineSource. + * @implements IUserEventInlineSource + * @constructor + * @param {google.cloud.retail.v2.IUserEventInlineSource=} [properties] Properties to set + */ + function UserEventInlineSource(properties) { + this.userEvents = []; + 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]]; + } + + /** + * UserEventInlineSource userEvents. + * @member {Array.} userEvents + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @instance + */ + UserEventInlineSource.prototype.userEvents = $util.emptyArray; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2.IUserEventInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UserEventInlineSource} UserEventInlineSource instance + */ + UserEventInlineSource.create = function create(properties) { + return new UserEventInlineSource(properties); + }; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2.UserEventInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEvents != null && message.userEvents.length) + for (var i = 0; i < message.userEvents.length; ++i) + $root.google.cloud.retail.v2.UserEvent.encode(message.userEvents[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.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.cloud.retail.v2.UserEventInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.userEvents && message.userEvents.length)) + message.userEvents = []; + message.userEvents.push($root.google.cloud.retail.v2.UserEvent.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userEvents != null && message.hasOwnProperty("userEvents")) { + if (!Array.isArray(message.userEvents)) + return "userEvents: array expected"; + for (var i = 0; i < message.userEvents.length; ++i) { + var error = $root.google.cloud.retail.v2.UserEvent.verify(message.userEvents[i]); + if (error) + return "userEvents." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UserEventInlineSource} UserEventInlineSource + */ + UserEventInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UserEventInlineSource) + return object; + var message = new $root.google.cloud.retail.v2.UserEventInlineSource(); + if (object.userEvents) { + if (!Array.isArray(object.userEvents)) + throw TypeError(".google.cloud.retail.v2.UserEventInlineSource.userEvents: array expected"); + message.userEvents = []; + for (var i = 0; i < object.userEvents.length; ++i) { + if (typeof object.userEvents[i] !== "object") + throw TypeError(".google.cloud.retail.v2.UserEventInlineSource.userEvents: object expected"); + message.userEvents[i] = $root.google.cloud.retail.v2.UserEvent.fromObject(object.userEvents[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2.UserEventInlineSource} message UserEventInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.userEvents = []; + if (message.userEvents && message.userEvents.length) { + object.userEvents = []; + for (var j = 0; j < message.userEvents.length; ++j) + object.userEvents[j] = $root.google.cloud.retail.v2.UserEvent.toObject(message.userEvents[j], options); + } + return object; + }; + + /** + * Converts this UserEventInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @instance + * @returns {Object.} JSON object + */ + UserEventInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UserEventInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UserEventInlineSource"; + }; + + return UserEventInlineSource; + })(); + + v2.ImportErrorsConfig = (function() { + + /** + * Properties of an ImportErrorsConfig. + * @memberof google.cloud.retail.v2 + * @interface IImportErrorsConfig + * @property {string|null} [gcsPrefix] ImportErrorsConfig gcsPrefix + */ + + /** + * Constructs a new ImportErrorsConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportErrorsConfig. + * @implements IImportErrorsConfig + * @constructor + * @param {google.cloud.retail.v2.IImportErrorsConfig=} [properties] Properties to set + */ + function ImportErrorsConfig(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]]; + } + + /** + * ImportErrorsConfig gcsPrefix. + * @member {string|null|undefined} gcsPrefix + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @instance + */ + ImportErrorsConfig.prototype.gcsPrefix = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ImportErrorsConfig destination. + * @member {"gcsPrefix"|undefined} destination + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @instance + */ + Object.defineProperty(ImportErrorsConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsPrefix"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2.IImportErrorsConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportErrorsConfig} ImportErrorsConfig instance + */ + ImportErrorsConfig.create = function create(properties) { + return new ImportErrorsConfig(properties); + }; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2.ImportErrorsConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsPrefix != null && Object.hasOwnProperty.call(message, "gcsPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsPrefix); + return writer; + }; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportErrorsConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.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.cloud.retail.v2.ImportErrorsConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportErrorsConfig message. + * @function verify + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportErrorsConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + properties.destination = 1; + if (!$util.isString(message.gcsPrefix)) + return "gcsPrefix: string expected"; + } + return null; + }; + + /** + * Creates an ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportErrorsConfig} ImportErrorsConfig + */ + ImportErrorsConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportErrorsConfig) + return object; + var message = new $root.google.cloud.retail.v2.ImportErrorsConfig(); + if (object.gcsPrefix != null) + message.gcsPrefix = String(object.gcsPrefix); + return message; + }; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2.ImportErrorsConfig} message ImportErrorsConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportErrorsConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + object.gcsPrefix = message.gcsPrefix; + if (options.oneofs) + object.destination = "gcsPrefix"; + } + return object; + }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @instance + * @returns {Object.} JSON object + */ + ImportErrorsConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportErrorsConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportErrorsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportErrorsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportErrorsConfig"; + }; + + return ImportErrorsConfig; + })(); + + v2.ImportProductsRequest = (function() { + + /** + * Properties of an ImportProductsRequest. + * @memberof google.cloud.retail.v2 + * @interface IImportProductsRequest + * @property {string|null} [parent] ImportProductsRequest parent + * @property {string|null} [requestId] ImportProductsRequest requestId + * @property {google.cloud.retail.v2.IProductInputConfig|null} [inputConfig] ImportProductsRequest inputConfig + * @property {google.cloud.retail.v2.IImportErrorsConfig|null} [errorsConfig] ImportProductsRequest errorsConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] ImportProductsRequest updateMask + * @property {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode|null} [reconciliationMode] ImportProductsRequest reconciliationMode + * @property {string|null} [notificationPubsubTopic] ImportProductsRequest notificationPubsubTopic + */ + + /** + * Constructs a new ImportProductsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportProductsRequest. + * @implements IImportProductsRequest + * @constructor + * @param {google.cloud.retail.v2.IImportProductsRequest=} [properties] Properties to set + */ + function ImportProductsRequest(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]]; + } + + /** + * ImportProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.parent = ""; + + /** + * ImportProductsRequest requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.requestId = ""; + + /** + * ImportProductsRequest inputConfig. + * @member {google.cloud.retail.v2.IProductInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.inputConfig = null; + + /** + * ImportProductsRequest errorsConfig. + * @member {google.cloud.retail.v2.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.errorsConfig = null; + + /** + * ImportProductsRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.updateMask = null; + + /** + * ImportProductsRequest reconciliationMode. + * @member {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} reconciliationMode + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.reconciliationMode = 0; + + /** + * ImportProductsRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2.IImportProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportProductsRequest} ImportProductsRequest instance + */ + ImportProductsRequest.create = function create(properties) { + return new ImportProductsRequest(properties); + }; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2.ProductInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.reconciliationMode != null && Object.hasOwnProperty.call(message, "reconciliationMode")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.reconciliationMode); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.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.cloud.retail.v2.ImportProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 6: { + message.requestId = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2.ProductInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.reconciliationMode = reader.int32(); + break; + } + case 7: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2.ProductInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + switch (message.reconciliationMode) { + default: + return "reconciliationMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportProductsRequest} ImportProductsRequest + */ + ImportProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ImportProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportProductsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2.ProductInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportProductsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.ImportProductsRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + switch (object.reconciliationMode) { + default: + if (typeof object.reconciliationMode === "number") { + message.reconciliationMode = object.reconciliationMode; + break; + } + break; + case "RECONCILIATION_MODE_UNSPECIFIED": + case 0: + message.reconciliationMode = 0; + break; + case "INCREMENTAL": + case 1: + message.reconciliationMode = 1; + break; + case "FULL": + case 2: + message.reconciliationMode = 2; + break; + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2.ImportProductsRequest} message ImportProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + object.updateMask = null; + object.reconciliationMode = options.enums === String ? "RECONCILIATION_MODE_UNSPECIFIED" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2.ProductInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + object.reconciliationMode = options.enums === String ? $root.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] === undefined ? message.reconciliationMode : $root.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] : message.reconciliationMode; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportProductsRequest"; + }; + + /** + * ReconciliationMode enum. + * @name google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode + * @enum {number} + * @property {number} RECONCILIATION_MODE_UNSPECIFIED=0 RECONCILIATION_MODE_UNSPECIFIED value + * @property {number} INCREMENTAL=1 INCREMENTAL value + * @property {number} FULL=2 FULL value + */ + ImportProductsRequest.ReconciliationMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RECONCILIATION_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INCREMENTAL"] = 1; + values[valuesById[2] = "FULL"] = 2; + return values; + })(); + + return ImportProductsRequest; + })(); + + v2.ImportUserEventsRequest = (function() { + + /** + * Properties of an ImportUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @interface IImportUserEventsRequest + * @property {string|null} [parent] ImportUserEventsRequest parent + * @property {google.cloud.retail.v2.IUserEventInputConfig|null} [inputConfig] ImportUserEventsRequest inputConfig + * @property {google.cloud.retail.v2.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsRequest errorsConfig + */ + + /** + * Constructs a new ImportUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportUserEventsRequest. + * @implements IImportUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2.IImportUserEventsRequest=} [properties] Properties to set + */ + function ImportUserEventsRequest(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]]; + } + + /** + * ImportUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.parent = ""; + + /** + * ImportUserEventsRequest inputConfig. + * @member {google.cloud.retail.v2.IUserEventInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.inputConfig = null; + + /** + * ImportUserEventsRequest errorsConfig. + * @member {google.cloud.retail.v2.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.errorsConfig = null; + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IImportUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportUserEventsRequest} ImportUserEventsRequest instance + */ + ImportUserEventsRequest.create = function create(properties) { + return new ImportUserEventsRequest(properties); + }; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2.UserEventInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.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.cloud.retail.v2.ImportUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2.UserEventInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2.UserEventInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportUserEventsRequest} ImportUserEventsRequest + */ + ImportUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ImportUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportUserEventsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2.UserEventInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportUserEventsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2.ImportUserEventsRequest} message ImportUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2.UserEventInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportUserEventsRequest"; + }; + + return ImportUserEventsRequest; + })(); + + v2.ImportCompletionDataRequest = (function() { + + /** + * Properties of an ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2 + * @interface IImportCompletionDataRequest + * @property {string|null} [parent] ImportCompletionDataRequest parent + * @property {google.cloud.retail.v2.ICompletionDataInputConfig|null} [inputConfig] ImportCompletionDataRequest inputConfig + * @property {string|null} [notificationPubsubTopic] ImportCompletionDataRequest notificationPubsubTopic + */ + + /** + * Constructs a new ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportCompletionDataRequest. + * @implements IImportCompletionDataRequest + * @constructor + * @param {google.cloud.retail.v2.IImportCompletionDataRequest=} [properties] Properties to set + */ + function ImportCompletionDataRequest(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]]; + } + + /** + * ImportCompletionDataRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.parent = ""; + + /** + * ImportCompletionDataRequest inputConfig. + * @member {google.cloud.retail.v2.ICompletionDataInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.inputConfig = null; + + /** + * ImportCompletionDataRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportCompletionDataRequest} ImportCompletionDataRequest instance + */ + ImportCompletionDataRequest.create = function create(properties) { + return new ImportCompletionDataRequest(properties); + }; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2.CompletionDataInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.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.cloud.retail.v2.ImportCompletionDataRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2.CompletionDataInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportCompletionDataRequest} ImportCompletionDataRequest + */ + ImportCompletionDataRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportCompletionDataRequest) + return object; + var message = new $root.google.cloud.retail.v2.ImportCompletionDataRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportCompletionDataRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.fromObject(object.inputConfig); + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2.ImportCompletionDataRequest} message ImportCompletionDataRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.notificationPubsubTopic = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2.CompletionDataInputConfig.toObject(message.inputConfig, options); + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportCompletionDataRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportCompletionDataRequest"; + }; + + return ImportCompletionDataRequest; + })(); + + v2.ProductInputConfig = (function() { + + /** + * Properties of a ProductInputConfig. + * @memberof google.cloud.retail.v2 + * @interface IProductInputConfig + * @property {google.cloud.retail.v2.IProductInlineSource|null} [productInlineSource] ProductInputConfig productInlineSource + * @property {google.cloud.retail.v2.IGcsSource|null} [gcsSource] ProductInputConfig gcsSource + * @property {google.cloud.retail.v2.IBigQuerySource|null} [bigQuerySource] ProductInputConfig bigQuerySource + */ + + /** + * Constructs a new ProductInputConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ProductInputConfig. + * @implements IProductInputConfig + * @constructor + * @param {google.cloud.retail.v2.IProductInputConfig=} [properties] Properties to set + */ + function ProductInputConfig(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]]; + } + + /** + * ProductInputConfig productInlineSource. + * @member {google.cloud.retail.v2.IProductInlineSource|null|undefined} productInlineSource + * @memberof google.cloud.retail.v2.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.productInlineSource = null; + + /** + * ProductInputConfig gcsSource. + * @member {google.cloud.retail.v2.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.gcsSource = null; + + /** + * ProductInputConfig bigQuerySource. + * @member {google.cloud.retail.v2.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ProductInputConfig source. + * @member {"productInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2.ProductInputConfig + * @instance + */ + Object.defineProperty(ProductInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["productInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {google.cloud.retail.v2.IProductInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ProductInputConfig} ProductInputConfig instance + */ + ProductInputConfig.create = function create(properties) { + return new ProductInputConfig(properties); + }; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2.ProductInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {google.cloud.retail.v2.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.productInlineSource != null && Object.hasOwnProperty.call(message, "productInlineSource")) + $root.google.cloud.retail.v2.ProductInlineSource.encode(message.productInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {google.cloud.retail.v2.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.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.cloud.retail.v2.ProductInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.productInlineSource = $root.google.cloud.retail.v2.ProductInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.ProductInlineSource.verify(message.productInlineSource); + if (error) + return "productInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ProductInputConfig} ProductInputConfig + */ + ProductInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ProductInputConfig) + return object; + var message = new $root.google.cloud.retail.v2.ProductInputConfig(); + if (object.productInlineSource != null) { + if (typeof object.productInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2.ProductInputConfig.productInlineSource: object expected"); + message.productInlineSource = $root.google.cloud.retail.v2.ProductInlineSource.fromObject(object.productInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2.ProductInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2.ProductInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {google.cloud.retail.v2.ProductInputConfig} message ProductInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + object.productInlineSource = $root.google.cloud.retail.v2.ProductInlineSource.toObject(message.productInlineSource, options); + if (options.oneofs) + object.source = "productInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this ProductInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ProductInputConfig + * @instance + * @returns {Object.} JSON object + */ + ProductInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ProductInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ProductInputConfig"; + }; + + return ProductInputConfig; + })(); + + v2.UserEventInputConfig = (function() { + + /** + * Properties of a UserEventInputConfig. + * @memberof google.cloud.retail.v2 + * @interface IUserEventInputConfig + * @property {google.cloud.retail.v2.IUserEventInlineSource|null} [userEventInlineSource] UserEventInputConfig userEventInlineSource + * @property {google.cloud.retail.v2.IGcsSource|null} [gcsSource] UserEventInputConfig gcsSource + * @property {google.cloud.retail.v2.IBigQuerySource|null} [bigQuerySource] UserEventInputConfig bigQuerySource + */ + + /** + * Constructs a new UserEventInputConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserEventInputConfig. + * @implements IUserEventInputConfig + * @constructor + * @param {google.cloud.retail.v2.IUserEventInputConfig=} [properties] Properties to set + */ + function UserEventInputConfig(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]]; + } + + /** + * UserEventInputConfig userEventInlineSource. + * @member {google.cloud.retail.v2.IUserEventInlineSource|null|undefined} userEventInlineSource + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.userEventInlineSource = null; + + /** + * UserEventInputConfig gcsSource. + * @member {google.cloud.retail.v2.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.gcsSource = null; + + /** + * UserEventInputConfig bigQuerySource. + * @member {google.cloud.retail.v2.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UserEventInputConfig source. + * @member {"userEventInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @instance + */ + Object.defineProperty(UserEventInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["userEventInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2.IUserEventInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UserEventInputConfig} UserEventInputConfig instance + */ + UserEventInputConfig.create = function create(properties) { + return new UserEventInputConfig(properties); + }; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2.UserEventInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEventInlineSource != null && Object.hasOwnProperty.call(message, "userEventInlineSource")) + $root.google.cloud.retail.v2.UserEventInlineSource.encode(message.userEventInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.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.cloud.retail.v2.UserEventInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userEventInlineSource = $root.google.cloud.retail.v2.UserEventInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.UserEventInlineSource.verify(message.userEventInlineSource); + if (error) + return "userEventInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UserEventInputConfig} UserEventInputConfig + */ + UserEventInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UserEventInputConfig) + return object; + var message = new $root.google.cloud.retail.v2.UserEventInputConfig(); + if (object.userEventInlineSource != null) { + if (typeof object.userEventInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2.UserEventInputConfig.userEventInlineSource: object expected"); + message.userEventInlineSource = $root.google.cloud.retail.v2.UserEventInlineSource.fromObject(object.userEventInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2.UserEventInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2.UserEventInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2.UserEventInputConfig} message UserEventInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + object.userEventInlineSource = $root.google.cloud.retail.v2.UserEventInlineSource.toObject(message.userEventInlineSource, options); + if (options.oneofs) + object.source = "userEventInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this UserEventInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @instance + * @returns {Object.} JSON object + */ + UserEventInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UserEventInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UserEventInputConfig"; + }; + + return UserEventInputConfig; + })(); + + v2.CompletionDataInputConfig = (function() { + + /** + * Properties of a CompletionDataInputConfig. + * @memberof google.cloud.retail.v2 + * @interface ICompletionDataInputConfig + * @property {google.cloud.retail.v2.IBigQuerySource|null} [bigQuerySource] CompletionDataInputConfig bigQuerySource + */ + + /** + * Constructs a new CompletionDataInputConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompletionDataInputConfig. + * @implements ICompletionDataInputConfig + * @constructor + * @param {google.cloud.retail.v2.ICompletionDataInputConfig=} [properties] Properties to set + */ + function CompletionDataInputConfig(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]]; + } + + /** + * CompletionDataInputConfig bigQuerySource. + * @member {google.cloud.retail.v2.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @instance + */ + CompletionDataInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CompletionDataInputConfig source. + * @member {"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @instance + */ + Object.defineProperty(CompletionDataInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2.ICompletionDataInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompletionDataInputConfig} CompletionDataInputConfig instance + */ + CompletionDataInputConfig.create = function create(properties) { + return new CompletionDataInputConfig(properties); + }; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2.CompletionDataInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionDataInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.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.cloud.retail.v2.CompletionDataInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDataInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDataInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompletionDataInputConfig} CompletionDataInputConfig + */ + CompletionDataInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompletionDataInputConfig) + return object; + var message = new $root.google.cloud.retail.v2.CompletionDataInputConfig(); + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2.CompletionDataInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2.CompletionDataInputConfig} message CompletionDataInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDataInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionDataInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompletionDataInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDataInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompletionDataInputConfig"; + }; + + return CompletionDataInputConfig; + })(); + + v2.ImportMetadata = (function() { + + /** + * Properties of an ImportMetadata. + * @memberof google.cloud.retail.v2 + * @interface IImportMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] ImportMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ImportMetadata updateTime + * @property {number|Long|null} [successCount] ImportMetadata successCount + * @property {number|Long|null} [failureCount] ImportMetadata failureCount + * @property {string|null} [requestId] ImportMetadata requestId + * @property {string|null} [notificationPubsubTopic] ImportMetadata notificationPubsubTopic + */ + + /** + * Constructs a new ImportMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportMetadata. + * @implements IImportMetadata + * @constructor + * @param {google.cloud.retail.v2.IImportMetadata=} [properties] Properties to set + */ + function ImportMetadata(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]]; + } + + /** + * ImportMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.createTime = null; + + /** + * ImportMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.updateTime = null; + + /** + * ImportMetadata successCount. + * @member {number|Long} successCount + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.successCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata failureCount. + * @member {number|Long} failureCount + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.failureCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.requestId = ""; + + /** + * ImportMetadata notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + */ + ImportMetadata.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {google.cloud.retail.v2.IImportMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportMetadata} ImportMetadata instance + */ + ImportMetadata.create = function create(properties) { + return new ImportMetadata(properties); + }; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2.ImportMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {google.cloud.retail.v2.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.successCount != null && Object.hasOwnProperty.call(message, "successCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.successCount); + if (message.failureCount != null && Object.hasOwnProperty.call(message, "failureCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.failureCount); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {google.cloud.retail.v2.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.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.cloud.retail.v2.ImportMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.successCount = reader.int64(); + break; + } + case 4: { + message.failureCount = reader.int64(); + break; + } + case 5: { + message.requestId = reader.string(); + break; + } + case 6: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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.successCount != null && message.hasOwnProperty("successCount")) + if (!$util.isInteger(message.successCount) && !(message.successCount && $util.isInteger(message.successCount.low) && $util.isInteger(message.successCount.high))) + return "successCount: integer|Long expected"; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (!$util.isInteger(message.failureCount) && !(message.failureCount && $util.isInteger(message.failureCount.low) && $util.isInteger(message.failureCount.high))) + return "failureCount: integer|Long expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportMetadata} ImportMetadata + */ + ImportMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportMetadata) + return object; + var message = new $root.google.cloud.retail.v2.ImportMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2.ImportMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2.ImportMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.successCount != null) + if ($util.Long) + (message.successCount = $util.Long.fromValue(object.successCount)).unsigned = false; + else if (typeof object.successCount === "string") + message.successCount = parseInt(object.successCount, 10); + else if (typeof object.successCount === "number") + message.successCount = object.successCount; + else if (typeof object.successCount === "object") + message.successCount = new $util.LongBits(object.successCount.low >>> 0, object.successCount.high >>> 0).toNumber(); + if (object.failureCount != null) + if ($util.Long) + (message.failureCount = $util.Long.fromValue(object.failureCount)).unsigned = false; + else if (typeof object.failureCount === "string") + message.failureCount = parseInt(object.failureCount, 10); + else if (typeof object.failureCount === "number") + message.failureCount = object.failureCount; + else if (typeof object.failureCount === "object") + message.failureCount = new $util.LongBits(object.failureCount.low >>> 0, object.failureCount.high >>> 0).toNumber(); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {google.cloud.retail.v2.ImportMetadata} message ImportMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.successCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.successCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failureCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failureCount = options.longs === String ? "0" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.successCount != null && message.hasOwnProperty("successCount")) + if (typeof message.successCount === "number") + object.successCount = options.longs === String ? String(message.successCount) : message.successCount; + else + object.successCount = options.longs === String ? $util.Long.prototype.toString.call(message.successCount) : options.longs === Number ? new $util.LongBits(message.successCount.low >>> 0, message.successCount.high >>> 0).toNumber() : message.successCount; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (typeof message.failureCount === "number") + object.failureCount = options.longs === String ? String(message.failureCount) : message.failureCount; + else + object.failureCount = options.longs === String ? $util.Long.prototype.toString.call(message.failureCount) : options.longs === Number ? new $util.LongBits(message.failureCount.low >>> 0, message.failureCount.high >>> 0).toNumber() : message.failureCount; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportMetadata"; + }; + + return ImportMetadata; + })(); + + v2.ImportProductsResponse = (function() { + + /** + * Properties of an ImportProductsResponse. + * @memberof google.cloud.retail.v2 + * @interface IImportProductsResponse + * @property {Array.|null} [errorSamples] ImportProductsResponse errorSamples + * @property {google.cloud.retail.v2.IImportErrorsConfig|null} [errorsConfig] ImportProductsResponse errorsConfig + */ + + /** + * Constructs a new ImportProductsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportProductsResponse. + * @implements IImportProductsResponse + * @constructor + * @param {google.cloud.retail.v2.IImportProductsResponse=} [properties] Properties to set + */ + function ImportProductsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportProductsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportProductsResponse errorsConfig. + * @member {google.cloud.retail.v2.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorsConfig = null; + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2.IImportProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportProductsResponse} ImportProductsResponse instance + */ + ImportProductsResponse.create = function create(properties) { + return new ImportProductsResponse(properties); + }; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.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.cloud.retail.v2.ImportProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportProductsResponse} ImportProductsResponse + */ + ImportProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ImportProductsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2.ImportProductsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ImportProductsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportProductsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2.ImportProductsResponse} message ImportProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) + object.errorsConfig = null; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportProductsResponse"; + }; + + return ImportProductsResponse; + })(); + + v2.ImportUserEventsResponse = (function() { + + /** + * Properties of an ImportUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @interface IImportUserEventsResponse + * @property {Array.|null} [errorSamples] ImportUserEventsResponse errorSamples + * @property {google.cloud.retail.v2.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsResponse errorsConfig + * @property {google.cloud.retail.v2.IUserEventImportSummary|null} [importSummary] ImportUserEventsResponse importSummary + */ + + /** + * Constructs a new ImportUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportUserEventsResponse. + * @implements IImportUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2.IImportUserEventsResponse=} [properties] Properties to set + */ + function ImportUserEventsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportUserEventsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportUserEventsResponse errorsConfig. + * @member {google.cloud.retail.v2.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorsConfig = null; + + /** + * ImportUserEventsResponse importSummary. + * @member {google.cloud.retail.v2.IUserEventImportSummary|null|undefined} importSummary + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.importSummary = null; + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IImportUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportUserEventsResponse} ImportUserEventsResponse instance + */ + ImportUserEventsResponse.create = function create(properties) { + return new ImportUserEventsResponse(properties); + }; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.importSummary != null && Object.hasOwnProperty.call(message, "importSummary")) + $root.google.cloud.retail.v2.UserEventImportSummary.encode(message.importSummary, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.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.cloud.retail.v2.ImportUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.importSummary = $root.google.cloud.retail.v2.UserEventImportSummary.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.importSummary != null && message.hasOwnProperty("importSummary")) { + var error = $root.google.cloud.retail.v2.UserEventImportSummary.verify(message.importSummary); + if (error) + return "importSummary." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportUserEventsResponse} ImportUserEventsResponse + */ + ImportUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ImportUserEventsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2.ImportUserEventsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ImportUserEventsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2.ImportUserEventsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.importSummary != null) { + if (typeof object.importSummary !== "object") + throw TypeError(".google.cloud.retail.v2.ImportUserEventsResponse.importSummary: object expected"); + message.importSummary = $root.google.cloud.retail.v2.UserEventImportSummary.fromObject(object.importSummary); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2.ImportUserEventsResponse} message ImportUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.importSummary = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.importSummary != null && message.hasOwnProperty("importSummary")) + object.importSummary = $root.google.cloud.retail.v2.UserEventImportSummary.toObject(message.importSummary, options); + return object; + }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportUserEventsResponse"; + }; + + return ImportUserEventsResponse; + })(); + + v2.UserEventImportSummary = (function() { + + /** + * Properties of a UserEventImportSummary. + * @memberof google.cloud.retail.v2 + * @interface IUserEventImportSummary + * @property {number|Long|null} [joinedEventsCount] UserEventImportSummary joinedEventsCount + * @property {number|Long|null} [unjoinedEventsCount] UserEventImportSummary unjoinedEventsCount + */ + + /** + * Constructs a new UserEventImportSummary. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserEventImportSummary. + * @implements IUserEventImportSummary + * @constructor + * @param {google.cloud.retail.v2.IUserEventImportSummary=} [properties] Properties to set + */ + function UserEventImportSummary(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]]; + } + + /** + * UserEventImportSummary joinedEventsCount. + * @member {number|Long} joinedEventsCount + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.joinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UserEventImportSummary unjoinedEventsCount. + * @member {number|Long} unjoinedEventsCount + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.unjoinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2.IUserEventImportSummary=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UserEventImportSummary} UserEventImportSummary instance + */ + UserEventImportSummary.create = function create(properties) { + return new UserEventImportSummary(properties); + }; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2.UserEventImportSummary.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.joinedEventsCount != null && Object.hasOwnProperty.call(message, "joinedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.joinedEventsCount); + if (message.unjoinedEventsCount != null && Object.hasOwnProperty.call(message, "unjoinedEventsCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.unjoinedEventsCount); + return writer; + }; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEventImportSummary.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.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.cloud.retail.v2.UserEventImportSummary(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.joinedEventsCount = reader.int64(); + break; + } + case 2: { + message.unjoinedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventImportSummary message. + * @function verify + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventImportSummary.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (!$util.isInteger(message.joinedEventsCount) && !(message.joinedEventsCount && $util.isInteger(message.joinedEventsCount.low) && $util.isInteger(message.joinedEventsCount.high))) + return "joinedEventsCount: integer|Long expected"; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (!$util.isInteger(message.unjoinedEventsCount) && !(message.unjoinedEventsCount && $util.isInteger(message.unjoinedEventsCount.low) && $util.isInteger(message.unjoinedEventsCount.high))) + return "unjoinedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UserEventImportSummary} UserEventImportSummary + */ + UserEventImportSummary.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UserEventImportSummary) + return object; + var message = new $root.google.cloud.retail.v2.UserEventImportSummary(); + if (object.joinedEventsCount != null) + if ($util.Long) + (message.joinedEventsCount = $util.Long.fromValue(object.joinedEventsCount)).unsigned = false; + else if (typeof object.joinedEventsCount === "string") + message.joinedEventsCount = parseInt(object.joinedEventsCount, 10); + else if (typeof object.joinedEventsCount === "number") + message.joinedEventsCount = object.joinedEventsCount; + else if (typeof object.joinedEventsCount === "object") + message.joinedEventsCount = new $util.LongBits(object.joinedEventsCount.low >>> 0, object.joinedEventsCount.high >>> 0).toNumber(); + if (object.unjoinedEventsCount != null) + if ($util.Long) + (message.unjoinedEventsCount = $util.Long.fromValue(object.unjoinedEventsCount)).unsigned = false; + else if (typeof object.unjoinedEventsCount === "string") + message.unjoinedEventsCount = parseInt(object.unjoinedEventsCount, 10); + else if (typeof object.unjoinedEventsCount === "number") + message.unjoinedEventsCount = object.unjoinedEventsCount; + else if (typeof object.unjoinedEventsCount === "object") + message.unjoinedEventsCount = new $util.LongBits(object.unjoinedEventsCount.low >>> 0, object.unjoinedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2.UserEventImportSummary} message UserEventImportSummary + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventImportSummary.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.joinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.joinedEventsCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.unjoinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.unjoinedEventsCount = options.longs === String ? "0" : 0; + } + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (typeof message.joinedEventsCount === "number") + object.joinedEventsCount = options.longs === String ? String(message.joinedEventsCount) : message.joinedEventsCount; + else + object.joinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.joinedEventsCount) : options.longs === Number ? new $util.LongBits(message.joinedEventsCount.low >>> 0, message.joinedEventsCount.high >>> 0).toNumber() : message.joinedEventsCount; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (typeof message.unjoinedEventsCount === "number") + object.unjoinedEventsCount = options.longs === String ? String(message.unjoinedEventsCount) : message.unjoinedEventsCount; + else + object.unjoinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.unjoinedEventsCount) : options.longs === Number ? new $util.LongBits(message.unjoinedEventsCount.low >>> 0, message.unjoinedEventsCount.high >>> 0).toNumber() : message.unjoinedEventsCount; + return object; + }; + + /** + * Converts this UserEventImportSummary to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @instance + * @returns {Object.} JSON object + */ + UserEventImportSummary.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventImportSummary + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UserEventImportSummary + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventImportSummary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UserEventImportSummary"; + }; + + return UserEventImportSummary; + })(); + + v2.ImportCompletionDataResponse = (function() { + + /** + * Properties of an ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2 + * @interface IImportCompletionDataResponse + * @property {Array.|null} [errorSamples] ImportCompletionDataResponse errorSamples + */ + + /** + * Constructs a new ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an ImportCompletionDataResponse. + * @implements IImportCompletionDataResponse + * @constructor + * @param {google.cloud.retail.v2.IImportCompletionDataResponse=} [properties] Properties to set + */ + function ImportCompletionDataResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportCompletionDataResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @instance + */ + ImportCompletionDataResponse.prototype.errorSamples = $util.emptyArray; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ImportCompletionDataResponse} ImportCompletionDataResponse instance + */ + ImportCompletionDataResponse.create = function create(properties) { + return new ImportCompletionDataResponse(properties); + }; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ImportCompletionDataResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.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.cloud.retail.v2.ImportCompletionDataResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + return null; + }; + + /** + * Creates an ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ImportCompletionDataResponse} ImportCompletionDataResponse + */ + ImportCompletionDataResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ImportCompletionDataResponse) + return object; + var message = new $root.google.cloud.retail.v2.ImportCompletionDataResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2.ImportCompletionDataResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ImportCompletionDataResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2.ImportCompletionDataResponse} message ImportCompletionDataResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + return object; + }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ImportCompletionDataResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ImportCompletionDataResponse"; + }; + + return ImportCompletionDataResponse; + })(); + + v2.Product = (function() { + + /** + * Properties of a Product. + * @memberof google.cloud.retail.v2 + * @interface IProduct + * @property {google.protobuf.ITimestamp|null} [expireTime] Product expireTime + * @property {google.protobuf.IDuration|null} [ttl] Product ttl + * @property {string|null} [name] Product name + * @property {string|null} [id] Product id + * @property {google.cloud.retail.v2.Product.Type|null} [type] Product type + * @property {string|null} [primaryProductId] Product primaryProductId + * @property {Array.|null} [collectionMemberIds] Product collectionMemberIds + * @property {string|null} [gtin] Product gtin + * @property {Array.|null} [categories] Product categories + * @property {string|null} [title] Product title + * @property {Array.|null} [brands] Product brands + * @property {string|null} [description] Product description + * @property {string|null} [languageCode] Product languageCode + * @property {Object.|null} [attributes] Product attributes + * @property {Array.|null} [tags] Product tags + * @property {google.cloud.retail.v2.IPriceInfo|null} [priceInfo] Product priceInfo + * @property {google.cloud.retail.v2.IRating|null} [rating] Product rating + * @property {google.protobuf.ITimestamp|null} [availableTime] Product availableTime + * @property {google.cloud.retail.v2.Product.Availability|null} [availability] Product availability + * @property {google.protobuf.IInt32Value|null} [availableQuantity] Product availableQuantity + * @property {Array.|null} [fulfillmentInfo] Product fulfillmentInfo + * @property {string|null} [uri] Product uri + * @property {Array.|null} [images] Product images + * @property {google.cloud.retail.v2.IAudience|null} [audience] Product audience + * @property {google.cloud.retail.v2.IColorInfo|null} [colorInfo] Product colorInfo + * @property {Array.|null} [sizes] Product sizes + * @property {Array.|null} [materials] Product materials + * @property {Array.|null} [patterns] Product patterns + * @property {Array.|null} [conditions] Product conditions + * @property {Array.|null} [promotions] Product promotions + * @property {google.protobuf.ITimestamp|null} [publishTime] Product publishTime + * @property {google.protobuf.IFieldMask|null} [retrievableFields] Product retrievableFields + * @property {Array.|null} [variants] Product variants + * @property {Array.|null} [localInventories] Product localInventories + */ + + /** + * Constructs a new Product. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Product. + * @implements IProduct + * @constructor + * @param {google.cloud.retail.v2.IProduct=} [properties] Properties to set + */ + function Product(properties) { + this.collectionMemberIds = []; + this.categories = []; + this.brands = []; + this.attributes = {}; + this.tags = []; + this.fulfillmentInfo = []; + this.images = []; + this.sizes = []; + this.materials = []; + this.patterns = []; + this.conditions = []; + this.promotions = []; + this.variants = []; + this.localInventories = []; + 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]]; + } + + /** + * Product expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.expireTime = null; + + /** + * Product ttl. + * @member {google.protobuf.IDuration|null|undefined} ttl + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.ttl = null; + + /** + * Product name. + * @member {string} name + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.name = ""; + + /** + * Product id. + * @member {string} id + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.id = ""; + + /** + * Product type. + * @member {google.cloud.retail.v2.Product.Type} type + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.type = 0; + + /** + * Product primaryProductId. + * @member {string} primaryProductId + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.primaryProductId = ""; + + /** + * Product collectionMemberIds. + * @member {Array.} collectionMemberIds + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.collectionMemberIds = $util.emptyArray; + + /** + * Product gtin. + * @member {string} gtin + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.gtin = ""; + + /** + * Product categories. + * @member {Array.} categories + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.categories = $util.emptyArray; + + /** + * Product title. + * @member {string} title + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.title = ""; + + /** + * Product brands. + * @member {Array.} brands + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.brands = $util.emptyArray; + + /** + * Product description. + * @member {string} description + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.description = ""; + + /** + * Product languageCode. + * @member {string} languageCode + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.languageCode = ""; + + /** + * Product attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.attributes = $util.emptyObject; + + /** + * Product tags. + * @member {Array.} tags + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.tags = $util.emptyArray; + + /** + * Product priceInfo. + * @member {google.cloud.retail.v2.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.priceInfo = null; + + /** + * Product rating. + * @member {google.cloud.retail.v2.IRating|null|undefined} rating + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.rating = null; + + /** + * Product availableTime. + * @member {google.protobuf.ITimestamp|null|undefined} availableTime + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.availableTime = null; + + /** + * Product availability. + * @member {google.cloud.retail.v2.Product.Availability} availability + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.availability = 0; + + /** + * Product availableQuantity. + * @member {google.protobuf.IInt32Value|null|undefined} availableQuantity + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.availableQuantity = null; + + /** + * Product fulfillmentInfo. + * @member {Array.} fulfillmentInfo + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.fulfillmentInfo = $util.emptyArray; + + /** + * Product uri. + * @member {string} uri + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.uri = ""; + + /** + * Product images. + * @member {Array.} images + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.images = $util.emptyArray; + + /** + * Product audience. + * @member {google.cloud.retail.v2.IAudience|null|undefined} audience + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.audience = null; + + /** + * Product colorInfo. + * @member {google.cloud.retail.v2.IColorInfo|null|undefined} colorInfo + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.colorInfo = null; + + /** + * Product sizes. + * @member {Array.} sizes + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.sizes = $util.emptyArray; + + /** + * Product materials. + * @member {Array.} materials + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.materials = $util.emptyArray; + + /** + * Product patterns. + * @member {Array.} patterns + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.patterns = $util.emptyArray; + + /** + * Product conditions. + * @member {Array.} conditions + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.conditions = $util.emptyArray; + + /** + * Product promotions. + * @member {Array.} promotions + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.promotions = $util.emptyArray; + + /** + * Product publishTime. + * @member {google.protobuf.ITimestamp|null|undefined} publishTime + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.publishTime = null; + + /** + * Product retrievableFields. + * @member {google.protobuf.IFieldMask|null|undefined} retrievableFields + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.retrievableFields = null; + + /** + * Product variants. + * @member {Array.} variants + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.variants = $util.emptyArray; + + /** + * Product localInventories. + * @member {Array.} localInventories + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Product.prototype.localInventories = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Product expiration. + * @member {"expireTime"|"ttl"|undefined} expiration + * @memberof google.cloud.retail.v2.Product + * @instance + */ + Object.defineProperty(Product.prototype, "expiration", { + get: $util.oneOfGetter($oneOfFields = ["expireTime", "ttl"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Product instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Product + * @static + * @param {google.cloud.retail.v2.IProduct=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Product} Product instance + */ + Product.create = function create(properties) { + return new Product(properties); + }; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2.Product.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Product + * @static + * @param {google.cloud.retail.v2.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.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.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.primaryProductId != null && Object.hasOwnProperty.call(message, "primaryProductId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.primaryProductId); + if (message.collectionMemberIds != null && message.collectionMemberIds.length) + for (var i = 0; i < message.collectionMemberIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.collectionMemberIds[i]); + if (message.gtin != null && Object.hasOwnProperty.call(message, "gtin")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.gtin); + if (message.categories != null && message.categories.length) + for (var i = 0; i < message.categories.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.categories[i]); + if (message.title != null && Object.hasOwnProperty.call(message, "title")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.title); + if (message.brands != null && message.brands.length) + for (var i = 0; i < message.brands.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.brands[i]); + if (message.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.description); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.languageCode); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 12, wireType 2 =*/98).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.tags != null && message.tags.length) + for (var i = 0; i < message.tags.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.tags[i]); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.rating != null && Object.hasOwnProperty.call(message, "rating")) + $root.google.cloud.retail.v2.Rating.encode(message.rating, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.ttl != null && Object.hasOwnProperty.call(message, "ttl")) + $root.google.protobuf.Duration.encode(message.ttl, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.availableTime != null && Object.hasOwnProperty.call(message, "availableTime")) + $root.google.protobuf.Timestamp.encode(message.availableTime, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.availability != null && Object.hasOwnProperty.call(message, "availability")) + writer.uint32(/* id 19, wireType 0 =*/152).int32(message.availability); + if (message.availableQuantity != null && Object.hasOwnProperty.call(message, "availableQuantity")) + $root.google.protobuf.Int32Value.encode(message.availableQuantity, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.fulfillmentInfo != null && message.fulfillmentInfo.length) + for (var i = 0; i < message.fulfillmentInfo.length; ++i) + $root.google.cloud.retail.v2.FulfillmentInfo.encode(message.fulfillmentInfo[i], writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 22, wireType 2 =*/178).string(message.uri); + if (message.images != null && message.images.length) + for (var i = 0; i < message.images.length; ++i) + $root.google.cloud.retail.v2.Image.encode(message.images[i], writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + if (message.audience != null && Object.hasOwnProperty.call(message, "audience")) + $root.google.cloud.retail.v2.Audience.encode(message.audience, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); + if (message.colorInfo != null && Object.hasOwnProperty.call(message, "colorInfo")) + $root.google.cloud.retail.v2.ColorInfo.encode(message.colorInfo, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim(); + if (message.sizes != null && message.sizes.length) + for (var i = 0; i < message.sizes.length; ++i) + writer.uint32(/* id 26, wireType 2 =*/210).string(message.sizes[i]); + if (message.materials != null && message.materials.length) + for (var i = 0; i < message.materials.length; ++i) + writer.uint32(/* id 27, wireType 2 =*/218).string(message.materials[i]); + if (message.patterns != null && message.patterns.length) + for (var i = 0; i < message.patterns.length; ++i) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.patterns[i]); + if (message.conditions != null && message.conditions.length) + for (var i = 0; i < message.conditions.length; ++i) + writer.uint32(/* id 29, wireType 2 =*/234).string(message.conditions[i]); + if (message.retrievableFields != null && Object.hasOwnProperty.call(message, "retrievableFields")) + $root.google.protobuf.FieldMask.encode(message.retrievableFields, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim(); + if (message.variants != null && message.variants.length) + for (var i = 0; i < message.variants.length; ++i) + $root.google.cloud.retail.v2.Product.encode(message.variants[i], writer.uint32(/* id 31, wireType 2 =*/250).fork()).ldelim(); + if (message.publishTime != null && Object.hasOwnProperty.call(message, "publishTime")) + $root.google.protobuf.Timestamp.encode(message.publishTime, writer.uint32(/* id 33, wireType 2 =*/266).fork()).ldelim(); + if (message.promotions != null && message.promotions.length) + for (var i = 0; i < message.promotions.length; ++i) + $root.google.cloud.retail.v2.Promotion.encode(message.promotions[i], writer.uint32(/* id 34, wireType 2 =*/274).fork()).ldelim(); + if (message.localInventories != null && message.localInventories.length) + for (var i = 0; i < message.localInventories.length; ++i) + $root.google.cloud.retail.v2.LocalInventory.encode(message.localInventories[i], writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Product.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Product + * @static + * @param {google.cloud.retail.v2.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Product message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.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.cloud.retail.v2.Product(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 16: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 17: { + message.ttl = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.id = reader.string(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.primaryProductId = reader.string(); + break; + } + case 5: { + if (!(message.collectionMemberIds && message.collectionMemberIds.length)) + message.collectionMemberIds = []; + message.collectionMemberIds.push(reader.string()); + break; + } + case 6: { + message.gtin = reader.string(); + break; + } + case 7: { + if (!(message.categories && message.categories.length)) + message.categories = []; + message.categories.push(reader.string()); + break; + } + case 8: { + message.title = reader.string(); + break; + } + case 9: { + if (!(message.brands && message.brands.length)) + message.brands = []; + message.brands.push(reader.string()); + break; + } + case 10: { + message.description = reader.string(); + break; + } + case 11: { + message.languageCode = reader.string(); + break; + } + case 12: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 13: { + if (!(message.tags && message.tags.length)) + message.tags = []; + message.tags.push(reader.string()); + break; + } + case 14: { + message.priceInfo = $root.google.cloud.retail.v2.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 15: { + message.rating = $root.google.cloud.retail.v2.Rating.decode(reader, reader.uint32()); + break; + } + case 18: { + message.availableTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 19: { + message.availability = reader.int32(); + break; + } + case 20: { + message.availableQuantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + case 21: { + if (!(message.fulfillmentInfo && message.fulfillmentInfo.length)) + message.fulfillmentInfo = []; + message.fulfillmentInfo.push($root.google.cloud.retail.v2.FulfillmentInfo.decode(reader, reader.uint32())); + break; + } + case 22: { + message.uri = reader.string(); + break; + } + case 23: { + if (!(message.images && message.images.length)) + message.images = []; + message.images.push($root.google.cloud.retail.v2.Image.decode(reader, reader.uint32())); + break; + } + case 24: { + message.audience = $root.google.cloud.retail.v2.Audience.decode(reader, reader.uint32()); + break; + } + case 25: { + message.colorInfo = $root.google.cloud.retail.v2.ColorInfo.decode(reader, reader.uint32()); + break; + } + case 26: { + if (!(message.sizes && message.sizes.length)) + message.sizes = []; + message.sizes.push(reader.string()); + break; + } + case 27: { + if (!(message.materials && message.materials.length)) + message.materials = []; + message.materials.push(reader.string()); + break; + } + case 28: { + if (!(message.patterns && message.patterns.length)) + message.patterns = []; + message.patterns.push(reader.string()); + break; + } + case 29: { + if (!(message.conditions && message.conditions.length)) + message.conditions = []; + message.conditions.push(reader.string()); + break; + } + case 34: { + if (!(message.promotions && message.promotions.length)) + message.promotions = []; + message.promotions.push($root.google.cloud.retail.v2.Promotion.decode(reader, reader.uint32())); + break; + } + case 33: { + message.publishTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 30: { + message.retrievableFields = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 31: { + if (!(message.variants && message.variants.length)) + message.variants = []; + message.variants.push($root.google.cloud.retail.v2.Product.decode(reader, reader.uint32())); + break; + } + case 35: { + if (!(message.localInventories && message.localInventories.length)) + message.localInventories = []; + message.localInventories.push($root.google.cloud.retail.v2.LocalInventory.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Product message. + * @function verify + * @memberof google.cloud.retail.v2.Product + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Product.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + properties.expiration = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + if (properties.expiration === 1) + return "expiration: multiple values"; + properties.expiration = 1; + { + var error = $root.google.protobuf.Duration.verify(message.ttl); + if (error) + return "ttl." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + if (!$util.isString(message.primaryProductId)) + return "primaryProductId: string expected"; + if (message.collectionMemberIds != null && message.hasOwnProperty("collectionMemberIds")) { + if (!Array.isArray(message.collectionMemberIds)) + return "collectionMemberIds: array expected"; + for (var i = 0; i < message.collectionMemberIds.length; ++i) + if (!$util.isString(message.collectionMemberIds[i])) + return "collectionMemberIds: string[] expected"; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + if (!$util.isString(message.gtin)) + return "gtin: string expected"; + if (message.categories != null && message.hasOwnProperty("categories")) { + if (!Array.isArray(message.categories)) + return "categories: array expected"; + for (var i = 0; i < message.categories.length; ++i) + if (!$util.isString(message.categories[i])) + return "categories: string[] expected"; + } + if (message.title != null && message.hasOwnProperty("title")) + if (!$util.isString(message.title)) + return "title: string expected"; + if (message.brands != null && message.hasOwnProperty("brands")) { + if (!Array.isArray(message.brands)) + return "brands: array expected"; + for (var i = 0; i < message.brands.length; ++i) + if (!$util.isString(message.brands[i])) + return "brands: string[] expected"; + } + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.tags != null && message.hasOwnProperty("tags")) { + if (!Array.isArray(message.tags)) + return "tags: array expected"; + for (var i = 0; i < message.tags.length; ++i) + if (!$util.isString(message.tags[i])) + return "tags: string[] expected"; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.rating != null && message.hasOwnProperty("rating")) { + var error = $root.google.cloud.retail.v2.Rating.verify(message.rating); + if (error) + return "rating." + error; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.availableTime); + if (error) + return "availableTime." + error; + } + if (message.availability != null && message.hasOwnProperty("availability")) + switch (message.availability) { + default: + return "availability: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.availableQuantity); + if (error) + return "availableQuantity." + error; + } + if (message.fulfillmentInfo != null && message.hasOwnProperty("fulfillmentInfo")) { + if (!Array.isArray(message.fulfillmentInfo)) + return "fulfillmentInfo: array expected"; + for (var i = 0; i < message.fulfillmentInfo.length; ++i) { + var error = $root.google.cloud.retail.v2.FulfillmentInfo.verify(message.fulfillmentInfo[i]); + if (error) + return "fulfillmentInfo." + error; + } + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.images != null && message.hasOwnProperty("images")) { + if (!Array.isArray(message.images)) + return "images: array expected"; + for (var i = 0; i < message.images.length; ++i) { + var error = $root.google.cloud.retail.v2.Image.verify(message.images[i]); + if (error) + return "images." + error; + } + } + if (message.audience != null && message.hasOwnProperty("audience")) { + var error = $root.google.cloud.retail.v2.Audience.verify(message.audience); + if (error) + return "audience." + error; + } + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) { + var error = $root.google.cloud.retail.v2.ColorInfo.verify(message.colorInfo); + if (error) + return "colorInfo." + error; + } + if (message.sizes != null && message.hasOwnProperty("sizes")) { + if (!Array.isArray(message.sizes)) + return "sizes: array expected"; + for (var i = 0; i < message.sizes.length; ++i) + if (!$util.isString(message.sizes[i])) + return "sizes: string[] expected"; + } + if (message.materials != null && message.hasOwnProperty("materials")) { + if (!Array.isArray(message.materials)) + return "materials: array expected"; + for (var i = 0; i < message.materials.length; ++i) + if (!$util.isString(message.materials[i])) + return "materials: string[] expected"; + } + if (message.patterns != null && message.hasOwnProperty("patterns")) { + if (!Array.isArray(message.patterns)) + return "patterns: array expected"; + for (var i = 0; i < message.patterns.length; ++i) + if (!$util.isString(message.patterns[i])) + return "patterns: string[] expected"; + } + if (message.conditions != null && message.hasOwnProperty("conditions")) { + if (!Array.isArray(message.conditions)) + return "conditions: array expected"; + for (var i = 0; i < message.conditions.length; ++i) + if (!$util.isString(message.conditions[i])) + return "conditions: string[] expected"; + } + if (message.promotions != null && message.hasOwnProperty("promotions")) { + if (!Array.isArray(message.promotions)) + return "promotions: array expected"; + for (var i = 0; i < message.promotions.length; ++i) { + var error = $root.google.cloud.retail.v2.Promotion.verify(message.promotions[i]); + if (error) + return "promotions." + error; + } + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.publishTime); + if (error) + return "publishTime." + error; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) { + var error = $root.google.protobuf.FieldMask.verify(message.retrievableFields); + if (error) + return "retrievableFields." + error; + } + if (message.variants != null && message.hasOwnProperty("variants")) { + if (!Array.isArray(message.variants)) + return "variants: array expected"; + for (var i = 0; i < message.variants.length; ++i) { + var error = $root.google.cloud.retail.v2.Product.verify(message.variants[i]); + if (error) + return "variants." + error; + } + } + if (message.localInventories != null && message.hasOwnProperty("localInventories")) { + if (!Array.isArray(message.localInventories)) + return "localInventories: array expected"; + for (var i = 0; i < message.localInventories.length; ++i) { + var error = $root.google.cloud.retail.v2.LocalInventory.verify(message.localInventories[i]); + if (error) + return "localInventories." + error; + } + } + return null; + }; + + /** + * Creates a Product message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Product + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Product} Product + */ + Product.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Product) + return object; + var message = new $root.google.cloud.retail.v2.Product(); + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.retail.v2.Product.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.ttl != null) { + if (typeof object.ttl !== "object") + throw TypeError(".google.cloud.retail.v2.Product.ttl: object expected"); + message.ttl = $root.google.protobuf.Duration.fromObject(object.ttl); + } + if (object.name != null) + message.name = String(object.name); + if (object.id != null) + message.id = String(object.id); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "PRIMARY": + case 1: + message.type = 1; + break; + case "VARIANT": + case 2: + message.type = 2; + break; + case "COLLECTION": + case 3: + message.type = 3; + break; + } + if (object.primaryProductId != null) + message.primaryProductId = String(object.primaryProductId); + if (object.collectionMemberIds) { + if (!Array.isArray(object.collectionMemberIds)) + throw TypeError(".google.cloud.retail.v2.Product.collectionMemberIds: array expected"); + message.collectionMemberIds = []; + for (var i = 0; i < object.collectionMemberIds.length; ++i) + message.collectionMemberIds[i] = String(object.collectionMemberIds[i]); + } + if (object.gtin != null) + message.gtin = String(object.gtin); + if (object.categories) { + if (!Array.isArray(object.categories)) + throw TypeError(".google.cloud.retail.v2.Product.categories: array expected"); + message.categories = []; + for (var i = 0; i < object.categories.length; ++i) + message.categories[i] = String(object.categories[i]); + } + if (object.title != null) + message.title = String(object.title); + if (object.brands) { + if (!Array.isArray(object.brands)) + throw TypeError(".google.cloud.retail.v2.Product.brands: array expected"); + message.brands = []; + for (var i = 0; i < object.brands.length; ++i) + message.brands[i] = String(object.brands[i]); + } + if (object.description != null) + message.description = String(object.description); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2.Product.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.tags) { + if (!Array.isArray(object.tags)) + throw TypeError(".google.cloud.retail.v2.Product.tags: array expected"); + message.tags = []; + for (var i = 0; i < object.tags.length; ++i) + message.tags[i] = String(object.tags[i]); + } + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2.Product.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2.PriceInfo.fromObject(object.priceInfo); + } + if (object.rating != null) { + if (typeof object.rating !== "object") + throw TypeError(".google.cloud.retail.v2.Product.rating: object expected"); + message.rating = $root.google.cloud.retail.v2.Rating.fromObject(object.rating); + } + if (object.availableTime != null) { + if (typeof object.availableTime !== "object") + throw TypeError(".google.cloud.retail.v2.Product.availableTime: object expected"); + message.availableTime = $root.google.protobuf.Timestamp.fromObject(object.availableTime); + } + switch (object.availability) { + default: + if (typeof object.availability === "number") { + message.availability = object.availability; + break; + } + break; + case "AVAILABILITY_UNSPECIFIED": + case 0: + message.availability = 0; + break; + case "IN_STOCK": + case 1: + message.availability = 1; + break; + case "OUT_OF_STOCK": + case 2: + message.availability = 2; + break; + case "PREORDER": + case 3: + message.availability = 3; + break; + case "BACKORDER": + case 4: + message.availability = 4; + break; + } + if (object.availableQuantity != null) { + if (typeof object.availableQuantity !== "object") + throw TypeError(".google.cloud.retail.v2.Product.availableQuantity: object expected"); + message.availableQuantity = $root.google.protobuf.Int32Value.fromObject(object.availableQuantity); + } + if (object.fulfillmentInfo) { + if (!Array.isArray(object.fulfillmentInfo)) + throw TypeError(".google.cloud.retail.v2.Product.fulfillmentInfo: array expected"); + message.fulfillmentInfo = []; + for (var i = 0; i < object.fulfillmentInfo.length; ++i) { + if (typeof object.fulfillmentInfo[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.fulfillmentInfo: object expected"); + message.fulfillmentInfo[i] = $root.google.cloud.retail.v2.FulfillmentInfo.fromObject(object.fulfillmentInfo[i]); + } + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.images) { + if (!Array.isArray(object.images)) + throw TypeError(".google.cloud.retail.v2.Product.images: array expected"); + message.images = []; + for (var i = 0; i < object.images.length; ++i) { + if (typeof object.images[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.images: object expected"); + message.images[i] = $root.google.cloud.retail.v2.Image.fromObject(object.images[i]); + } + } + if (object.audience != null) { + if (typeof object.audience !== "object") + throw TypeError(".google.cloud.retail.v2.Product.audience: object expected"); + message.audience = $root.google.cloud.retail.v2.Audience.fromObject(object.audience); + } + if (object.colorInfo != null) { + if (typeof object.colorInfo !== "object") + throw TypeError(".google.cloud.retail.v2.Product.colorInfo: object expected"); + message.colorInfo = $root.google.cloud.retail.v2.ColorInfo.fromObject(object.colorInfo); + } + if (object.sizes) { + if (!Array.isArray(object.sizes)) + throw TypeError(".google.cloud.retail.v2.Product.sizes: array expected"); + message.sizes = []; + for (var i = 0; i < object.sizes.length; ++i) + message.sizes[i] = String(object.sizes[i]); + } + if (object.materials) { + if (!Array.isArray(object.materials)) + throw TypeError(".google.cloud.retail.v2.Product.materials: array expected"); + message.materials = []; + for (var i = 0; i < object.materials.length; ++i) + message.materials[i] = String(object.materials[i]); + } + if (object.patterns) { + if (!Array.isArray(object.patterns)) + throw TypeError(".google.cloud.retail.v2.Product.patterns: array expected"); + message.patterns = []; + for (var i = 0; i < object.patterns.length; ++i) + message.patterns[i] = String(object.patterns[i]); + } + if (object.conditions) { + if (!Array.isArray(object.conditions)) + throw TypeError(".google.cloud.retail.v2.Product.conditions: array expected"); + message.conditions = []; + for (var i = 0; i < object.conditions.length; ++i) + message.conditions[i] = String(object.conditions[i]); + } + if (object.promotions) { + if (!Array.isArray(object.promotions)) + throw TypeError(".google.cloud.retail.v2.Product.promotions: array expected"); + message.promotions = []; + for (var i = 0; i < object.promotions.length; ++i) { + if (typeof object.promotions[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.promotions: object expected"); + message.promotions[i] = $root.google.cloud.retail.v2.Promotion.fromObject(object.promotions[i]); + } + } + if (object.publishTime != null) { + if (typeof object.publishTime !== "object") + throw TypeError(".google.cloud.retail.v2.Product.publishTime: object expected"); + message.publishTime = $root.google.protobuf.Timestamp.fromObject(object.publishTime); + } + if (object.retrievableFields != null) { + if (typeof object.retrievableFields !== "object") + throw TypeError(".google.cloud.retail.v2.Product.retrievableFields: object expected"); + message.retrievableFields = $root.google.protobuf.FieldMask.fromObject(object.retrievableFields); + } + if (object.variants) { + if (!Array.isArray(object.variants)) + throw TypeError(".google.cloud.retail.v2.Product.variants: array expected"); + message.variants = []; + for (var i = 0; i < object.variants.length; ++i) { + if (typeof object.variants[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.variants: object expected"); + message.variants[i] = $root.google.cloud.retail.v2.Product.fromObject(object.variants[i]); + } + } + if (object.localInventories) { + if (!Array.isArray(object.localInventories)) + throw TypeError(".google.cloud.retail.v2.Product.localInventories: array expected"); + message.localInventories = []; + for (var i = 0; i < object.localInventories.length; ++i) { + if (typeof object.localInventories[i] !== "object") + throw TypeError(".google.cloud.retail.v2.Product.localInventories: object expected"); + message.localInventories[i] = $root.google.cloud.retail.v2.LocalInventory.fromObject(object.localInventories[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Product + * @static + * @param {google.cloud.retail.v2.Product} message Product + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Product.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.collectionMemberIds = []; + object.categories = []; + object.brands = []; + object.tags = []; + object.fulfillmentInfo = []; + object.images = []; + object.sizes = []; + object.materials = []; + object.patterns = []; + object.conditions = []; + object.variants = []; + object.promotions = []; + object.localInventories = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.name = ""; + object.id = ""; + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + object.primaryProductId = ""; + object.gtin = ""; + object.title = ""; + object.description = ""; + object.languageCode = ""; + object.priceInfo = null; + object.rating = null; + object.availableTime = null; + object.availability = options.enums === String ? "AVAILABILITY_UNSPECIFIED" : 0; + object.availableQuantity = null; + object.uri = ""; + object.audience = null; + object.colorInfo = null; + object.retrievableFields = null; + object.publishTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2.Product.Type[message.type] === undefined ? message.type : $root.google.cloud.retail.v2.Product.Type[message.type] : message.type; + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + object.primaryProductId = message.primaryProductId; + if (message.collectionMemberIds && message.collectionMemberIds.length) { + object.collectionMemberIds = []; + for (var j = 0; j < message.collectionMemberIds.length; ++j) + object.collectionMemberIds[j] = message.collectionMemberIds[j]; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + object.gtin = message.gtin; + if (message.categories && message.categories.length) { + object.categories = []; + for (var j = 0; j < message.categories.length; ++j) + object.categories[j] = message.categories[j]; + } + if (message.title != null && message.hasOwnProperty("title")) + object.title = message.title; + if (message.brands && message.brands.length) { + object.brands = []; + for (var j = 0; j < message.brands.length; ++j) + object.brands[j] = message.brands[j]; + } + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.tags && message.tags.length) { + object.tags = []; + for (var j = 0; j < message.tags.length; ++j) + object.tags[j] = message.tags[j]; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2.PriceInfo.toObject(message.priceInfo, options); + if (message.rating != null && message.hasOwnProperty("rating")) + object.rating = $root.google.cloud.retail.v2.Rating.toObject(message.rating, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (options.oneofs) + object.expiration = "expireTime"; + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + object.ttl = $root.google.protobuf.Duration.toObject(message.ttl, options); + if (options.oneofs) + object.expiration = "ttl"; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) + object.availableTime = $root.google.protobuf.Timestamp.toObject(message.availableTime, options); + if (message.availability != null && message.hasOwnProperty("availability")) + object.availability = options.enums === String ? $root.google.cloud.retail.v2.Product.Availability[message.availability] === undefined ? message.availability : $root.google.cloud.retail.v2.Product.Availability[message.availability] : message.availability; + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) + object.availableQuantity = $root.google.protobuf.Int32Value.toObject(message.availableQuantity, options); + if (message.fulfillmentInfo && message.fulfillmentInfo.length) { + object.fulfillmentInfo = []; + for (var j = 0; j < message.fulfillmentInfo.length; ++j) + object.fulfillmentInfo[j] = $root.google.cloud.retail.v2.FulfillmentInfo.toObject(message.fulfillmentInfo[j], options); + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.images && message.images.length) { + object.images = []; + for (var j = 0; j < message.images.length; ++j) + object.images[j] = $root.google.cloud.retail.v2.Image.toObject(message.images[j], options); + } + if (message.audience != null && message.hasOwnProperty("audience")) + object.audience = $root.google.cloud.retail.v2.Audience.toObject(message.audience, options); + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) + object.colorInfo = $root.google.cloud.retail.v2.ColorInfo.toObject(message.colorInfo, options); + if (message.sizes && message.sizes.length) { + object.sizes = []; + for (var j = 0; j < message.sizes.length; ++j) + object.sizes[j] = message.sizes[j]; + } + if (message.materials && message.materials.length) { + object.materials = []; + for (var j = 0; j < message.materials.length; ++j) + object.materials[j] = message.materials[j]; + } + if (message.patterns && message.patterns.length) { + object.patterns = []; + for (var j = 0; j < message.patterns.length; ++j) + object.patterns[j] = message.patterns[j]; + } + if (message.conditions && message.conditions.length) { + object.conditions = []; + for (var j = 0; j < message.conditions.length; ++j) + object.conditions[j] = message.conditions[j]; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) + object.retrievableFields = $root.google.protobuf.FieldMask.toObject(message.retrievableFields, options); + if (message.variants && message.variants.length) { + object.variants = []; + for (var j = 0; j < message.variants.length; ++j) + object.variants[j] = $root.google.cloud.retail.v2.Product.toObject(message.variants[j], options); + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) + object.publishTime = $root.google.protobuf.Timestamp.toObject(message.publishTime, options); + if (message.promotions && message.promotions.length) { + object.promotions = []; + for (var j = 0; j < message.promotions.length; ++j) + object.promotions[j] = $root.google.cloud.retail.v2.Promotion.toObject(message.promotions[j], options); + } + if (message.localInventories && message.localInventories.length) { + object.localInventories = []; + for (var j = 0; j < message.localInventories.length; ++j) + object.localInventories[j] = $root.google.cloud.retail.v2.LocalInventory.toObject(message.localInventories[j], options); + } + return object; + }; + + /** + * Converts this Product to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Product + * @instance + * @returns {Object.} JSON object + */ + Product.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Product + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Product + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Product.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Product"; + }; + + /** + * Type enum. + * @name google.cloud.retail.v2.Product.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} PRIMARY=1 PRIMARY value + * @property {number} VARIANT=2 VARIANT value + * @property {number} COLLECTION=3 COLLECTION value + */ + Product.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRIMARY"] = 1; + values[valuesById[2] = "VARIANT"] = 2; + values[valuesById[3] = "COLLECTION"] = 3; + return values; + })(); + + /** + * Availability enum. + * @name google.cloud.retail.v2.Product.Availability + * @enum {number} + * @property {number} AVAILABILITY_UNSPECIFIED=0 AVAILABILITY_UNSPECIFIED value + * @property {number} IN_STOCK=1 IN_STOCK value + * @property {number} OUT_OF_STOCK=2 OUT_OF_STOCK value + * @property {number} PREORDER=3 PREORDER value + * @property {number} BACKORDER=4 BACKORDER value + */ + Product.Availability = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "AVAILABILITY_UNSPECIFIED"] = 0; + values[valuesById[1] = "IN_STOCK"] = 1; + values[valuesById[2] = "OUT_OF_STOCK"] = 2; + values[valuesById[3] = "PREORDER"] = 3; + values[valuesById[4] = "BACKORDER"] = 4; + return values; + })(); + + return Product; + })(); + + v2.Promotion = (function() { + + /** + * Properties of a Promotion. + * @memberof google.cloud.retail.v2 + * @interface IPromotion + * @property {string|null} [promotionId] Promotion promotionId + */ + + /** + * Constructs a new Promotion. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Promotion. + * @implements IPromotion + * @constructor + * @param {google.cloud.retail.v2.IPromotion=} [properties] Properties to set + */ + function Promotion(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]]; + } + + /** + * Promotion promotionId. + * @member {string} promotionId + * @memberof google.cloud.retail.v2.Promotion + * @instance + */ + Promotion.prototype.promotionId = ""; + + /** + * Creates a new Promotion instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {google.cloud.retail.v2.IPromotion=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Promotion} Promotion instance + */ + Promotion.create = function create(properties) { + return new Promotion(properties); + }; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2.Promotion.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {google.cloud.retail.v2.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.promotionId != null && Object.hasOwnProperty.call(message, "promotionId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.promotionId); + return writer; + }; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Promotion.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {google.cloud.retail.v2.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.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.cloud.retail.v2.Promotion(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.promotionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Promotion message. + * @function verify + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Promotion.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + if (!$util.isString(message.promotionId)) + return "promotionId: string expected"; + return null; + }; + + /** + * Creates a Promotion message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Promotion} Promotion + */ + Promotion.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Promotion) + return object; + var message = new $root.google.cloud.retail.v2.Promotion(); + if (object.promotionId != null) + message.promotionId = String(object.promotionId); + return message; + }; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {google.cloud.retail.v2.Promotion} message Promotion + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Promotion.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.promotionId = ""; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + object.promotionId = message.promotionId; + return object; + }; + + /** + * Converts this Promotion to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Promotion + * @instance + * @returns {Object.} JSON object + */ + Promotion.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Promotion + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Promotion + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Promotion.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Promotion"; + }; + + return Promotion; + })(); + + v2.UserEvent = (function() { + + /** + * Properties of a UserEvent. + * @memberof google.cloud.retail.v2 + * @interface IUserEvent + * @property {string|null} [eventType] UserEvent eventType + * @property {string|null} [visitorId] UserEvent visitorId + * @property {string|null} [sessionId] UserEvent sessionId + * @property {google.protobuf.ITimestamp|null} [eventTime] UserEvent eventTime + * @property {Array.|null} [experimentIds] UserEvent experimentIds + * @property {string|null} [attributionToken] UserEvent attributionToken + * @property {Array.|null} [productDetails] UserEvent productDetails + * @property {google.cloud.retail.v2.ICompletionDetail|null} [completionDetail] UserEvent completionDetail + * @property {Object.|null} [attributes] UserEvent attributes + * @property {string|null} [cartId] UserEvent cartId + * @property {google.cloud.retail.v2.IPurchaseTransaction|null} [purchaseTransaction] UserEvent purchaseTransaction + * @property {string|null} [searchQuery] UserEvent searchQuery + * @property {string|null} [filter] UserEvent filter + * @property {string|null} [orderBy] UserEvent orderBy + * @property {number|null} [offset] UserEvent offset + * @property {Array.|null} [pageCategories] UserEvent pageCategories + * @property {google.cloud.retail.v2.IUserInfo|null} [userInfo] UserEvent userInfo + * @property {string|null} [uri] UserEvent uri + * @property {string|null} [referrerUri] UserEvent referrerUri + * @property {string|null} [pageViewId] UserEvent pageViewId + */ + + /** + * Constructs a new UserEvent. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserEvent. + * @implements IUserEvent + * @constructor + * @param {google.cloud.retail.v2.IUserEvent=} [properties] Properties to set + */ + function UserEvent(properties) { + this.experimentIds = []; + this.productDetails = []; + this.attributes = {}; + this.pageCategories = []; + 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]]; + } + + /** + * UserEvent eventType. + * @member {string} eventType + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.eventType = ""; + + /** + * UserEvent visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.visitorId = ""; + + /** + * UserEvent sessionId. + * @member {string} sessionId + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.sessionId = ""; + + /** + * UserEvent eventTime. + * @member {google.protobuf.ITimestamp|null|undefined} eventTime + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.eventTime = null; + + /** + * UserEvent experimentIds. + * @member {Array.} experimentIds + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.experimentIds = $util.emptyArray; + + /** + * UserEvent attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.attributionToken = ""; + + /** + * UserEvent productDetails. + * @member {Array.} productDetails + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.productDetails = $util.emptyArray; + + /** + * UserEvent completionDetail. + * @member {google.cloud.retail.v2.ICompletionDetail|null|undefined} completionDetail + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.completionDetail = null; + + /** + * UserEvent attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.attributes = $util.emptyObject; + + /** + * UserEvent cartId. + * @member {string} cartId + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.cartId = ""; + + /** + * UserEvent purchaseTransaction. + * @member {google.cloud.retail.v2.IPurchaseTransaction|null|undefined} purchaseTransaction + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.purchaseTransaction = null; + + /** + * UserEvent searchQuery. + * @member {string} searchQuery + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.searchQuery = ""; + + /** + * UserEvent filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.filter = ""; + + /** + * UserEvent orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.orderBy = ""; + + /** + * UserEvent offset. + * @member {number} offset + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.offset = 0; + + /** + * UserEvent pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.pageCategories = $util.emptyArray; + + /** + * UserEvent userInfo. + * @member {google.cloud.retail.v2.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.userInfo = null; + + /** + * UserEvent uri. + * @member {string} uri + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.uri = ""; + + /** + * UserEvent referrerUri. + * @member {string} referrerUri + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.referrerUri = ""; + + /** + * UserEvent pageViewId. + * @member {string} pageViewId + * @memberof google.cloud.retail.v2.UserEvent + * @instance + */ + UserEvent.prototype.pageViewId = ""; + + /** + * Creates a new UserEvent instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {google.cloud.retail.v2.IUserEvent=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UserEvent} UserEvent instance + */ + UserEvent.create = function create(properties) { + return new UserEvent(properties); + }; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2.UserEvent.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {google.cloud.retail.v2.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.eventType != null && Object.hasOwnProperty.call(message, "eventType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.eventType); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.visitorId); + if (message.eventTime != null && Object.hasOwnProperty.call(message, "eventTime")) + $root.google.protobuf.Timestamp.encode(message.eventTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.experimentIds != null && message.experimentIds.length) + for (var i = 0; i < message.experimentIds.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.experimentIds[i]); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.productDetails != null && message.productDetails.length) + for (var i = 0; i < message.productDetails.length; ++i) + $root.google.cloud.retail.v2.ProductDetail.encode(message.productDetails[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.cartId != null && Object.hasOwnProperty.call(message, "cartId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.cartId); + if (message.purchaseTransaction != null && Object.hasOwnProperty.call(message, "purchaseTransaction")) + $root.google.cloud.retail.v2.PurchaseTransaction.encode(message.purchaseTransaction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.searchQuery != null && Object.hasOwnProperty.call(message, "searchQuery")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.searchQuery); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.pageCategories[i]); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2.UserInfo.encode(message.userInfo, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.uri); + if (message.referrerUri != null && Object.hasOwnProperty.call(message, "referrerUri")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.referrerUri); + if (message.pageViewId != null && Object.hasOwnProperty.call(message, "pageViewId")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.pageViewId); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.orderBy); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 18, wireType 0 =*/144).int32(message.offset); + if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId")) + writer.uint32(/* id 21, wireType 2 =*/170).string(message.sessionId); + if (message.completionDetail != null && Object.hasOwnProperty.call(message, "completionDetail")) + $root.google.cloud.retail.v2.CompletionDetail.encode(message.completionDetail, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UserEvent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {google.cloud.retail.v2.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.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.cloud.retail.v2.UserEvent(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.eventType = reader.string(); + break; + } + case 2: { + message.visitorId = reader.string(); + break; + } + case 21: { + message.sessionId = reader.string(); + break; + } + case 3: { + message.eventTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.experimentIds && message.experimentIds.length)) + message.experimentIds = []; + message.experimentIds.push(reader.string()); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + if (!(message.productDetails && message.productDetails.length)) + message.productDetails = []; + message.productDetails.push($root.google.cloud.retail.v2.ProductDetail.decode(reader, reader.uint32())); + break; + } + case 22: { + message.completionDetail = $root.google.cloud.retail.v2.CompletionDetail.decode(reader, reader.uint32()); + break; + } + case 7: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 8: { + message.cartId = reader.string(); + break; + } + case 9: { + message.purchaseTransaction = $root.google.cloud.retail.v2.PurchaseTransaction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.searchQuery = reader.string(); + break; + } + case 16: { + message.filter = reader.string(); + break; + } + case 17: { + message.orderBy = reader.string(); + break; + } + case 18: { + message.offset = reader.int32(); + break; + } + case 11: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 12: { + message.userInfo = $root.google.cloud.retail.v2.UserInfo.decode(reader, reader.uint32()); + break; + } + case 13: { + message.uri = reader.string(); + break; + } + case 14: { + message.referrerUri = reader.string(); + break; + } + case 15: { + message.pageViewId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEvent message. + * @function verify + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEvent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.eventType != null && message.hasOwnProperty("eventType")) + if (!$util.isString(message.eventType)) + return "eventType: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + if (!$util.isString(message.sessionId)) + return "sessionId: string expected"; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.eventTime); + if (error) + return "eventTime." + error; + } + if (message.experimentIds != null && message.hasOwnProperty("experimentIds")) { + if (!Array.isArray(message.experimentIds)) + return "experimentIds: array expected"; + for (var i = 0; i < message.experimentIds.length; ++i) + if (!$util.isString(message.experimentIds[i])) + return "experimentIds: string[] expected"; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.productDetails != null && message.hasOwnProperty("productDetails")) { + if (!Array.isArray(message.productDetails)) + return "productDetails: array expected"; + for (var i = 0; i < message.productDetails.length; ++i) { + var error = $root.google.cloud.retail.v2.ProductDetail.verify(message.productDetails[i]); + if (error) + return "productDetails." + error; + } + } + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) { + var error = $root.google.cloud.retail.v2.CompletionDetail.verify(message.completionDetail); + if (error) + return "completionDetail." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + if (!$util.isString(message.cartId)) + return "cartId: string expected"; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) { + var error = $root.google.cloud.retail.v2.PurchaseTransaction.verify(message.purchaseTransaction); + if (error) + return "purchaseTransaction." + error; + } + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + if (!$util.isString(message.searchQuery)) + return "searchQuery: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + if (!$util.isString(message.referrerUri)) + return "referrerUri: string expected"; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + if (!$util.isString(message.pageViewId)) + return "pageViewId: string expected"; + return null; + }; + + /** + * Creates a UserEvent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UserEvent} UserEvent + */ + UserEvent.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UserEvent) + return object; + var message = new $root.google.cloud.retail.v2.UserEvent(); + if (object.eventType != null) + message.eventType = String(object.eventType); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.sessionId != null) + message.sessionId = String(object.sessionId); + if (object.eventTime != null) { + if (typeof object.eventTime !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.eventTime: object expected"); + message.eventTime = $root.google.protobuf.Timestamp.fromObject(object.eventTime); + } + if (object.experimentIds) { + if (!Array.isArray(object.experimentIds)) + throw TypeError(".google.cloud.retail.v2.UserEvent.experimentIds: array expected"); + message.experimentIds = []; + for (var i = 0; i < object.experimentIds.length; ++i) + message.experimentIds[i] = String(object.experimentIds[i]); + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.productDetails) { + if (!Array.isArray(object.productDetails)) + throw TypeError(".google.cloud.retail.v2.UserEvent.productDetails: array expected"); + message.productDetails = []; + for (var i = 0; i < object.productDetails.length; ++i) { + if (typeof object.productDetails[i] !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.productDetails: object expected"); + message.productDetails[i] = $root.google.cloud.retail.v2.ProductDetail.fromObject(object.productDetails[i]); + } + } + if (object.completionDetail != null) { + if (typeof object.completionDetail !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.completionDetail: object expected"); + message.completionDetail = $root.google.cloud.retail.v2.CompletionDetail.fromObject(object.completionDetail); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.cartId != null) + message.cartId = String(object.cartId); + if (object.purchaseTransaction != null) { + if (typeof object.purchaseTransaction !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.purchaseTransaction: object expected"); + message.purchaseTransaction = $root.google.cloud.retail.v2.PurchaseTransaction.fromObject(object.purchaseTransaction); + } + if (object.searchQuery != null) + message.searchQuery = String(object.searchQuery); + if (object.filter != null) + message.filter = String(object.filter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2.UserEvent.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2.UserEvent.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2.UserInfo.fromObject(object.userInfo); + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.referrerUri != null) + message.referrerUri = String(object.referrerUri); + if (object.pageViewId != null) + message.pageViewId = String(object.pageViewId); + return message; + }; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {google.cloud.retail.v2.UserEvent} message UserEvent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEvent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.experimentIds = []; + object.productDetails = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.eventType = ""; + object.visitorId = ""; + object.eventTime = null; + object.attributionToken = ""; + object.cartId = ""; + object.purchaseTransaction = null; + object.searchQuery = ""; + object.userInfo = null; + object.uri = ""; + object.referrerUri = ""; + object.pageViewId = ""; + object.filter = ""; + object.orderBy = ""; + object.offset = 0; + object.sessionId = ""; + object.completionDetail = null; + } + if (message.eventType != null && message.hasOwnProperty("eventType")) + object.eventType = message.eventType; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) + object.eventTime = $root.google.protobuf.Timestamp.toObject(message.eventTime, options); + if (message.experimentIds && message.experimentIds.length) { + object.experimentIds = []; + for (var j = 0; j < message.experimentIds.length; ++j) + object.experimentIds[j] = message.experimentIds[j]; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.productDetails && message.productDetails.length) { + object.productDetails = []; + for (var j = 0; j < message.productDetails.length; ++j) + object.productDetails[j] = $root.google.cloud.retail.v2.ProductDetail.toObject(message.productDetails[j], options); + } + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + object.cartId = message.cartId; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) + object.purchaseTransaction = $root.google.cloud.retail.v2.PurchaseTransaction.toObject(message.purchaseTransaction, options); + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + object.searchQuery = message.searchQuery; + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2.UserInfo.toObject(message.userInfo, options); + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + object.referrerUri = message.referrerUri; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + object.pageViewId = message.pageViewId; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + object.sessionId = message.sessionId; + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) + object.completionDetail = $root.google.cloud.retail.v2.CompletionDetail.toObject(message.completionDetail, options); + return object; + }; + + /** + * Converts this UserEvent to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UserEvent + * @instance + * @returns {Object.} JSON object + */ + UserEvent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEvent + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UserEvent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UserEvent"; + }; + + return UserEvent; + })(); + + v2.ProductDetail = (function() { + + /** + * Properties of a ProductDetail. + * @memberof google.cloud.retail.v2 + * @interface IProductDetail + * @property {google.cloud.retail.v2.IProduct|null} [product] ProductDetail product + * @property {google.protobuf.IInt32Value|null} [quantity] ProductDetail quantity + */ + + /** + * Constructs a new ProductDetail. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ProductDetail. + * @implements IProductDetail + * @constructor + * @param {google.cloud.retail.v2.IProductDetail=} [properties] Properties to set + */ + function ProductDetail(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]]; + } + + /** + * ProductDetail product. + * @member {google.cloud.retail.v2.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2.ProductDetail + * @instance + */ + ProductDetail.prototype.product = null; + + /** + * ProductDetail quantity. + * @member {google.protobuf.IInt32Value|null|undefined} quantity + * @memberof google.cloud.retail.v2.ProductDetail + * @instance + */ + ProductDetail.prototype.quantity = null; + + /** + * Creates a new ProductDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {google.cloud.retail.v2.IProductDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ProductDetail} ProductDetail instance + */ + ProductDetail.create = function create(properties) { + return new ProductDetail(properties); + }; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2.ProductDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {google.cloud.retail.v2.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.quantity != null && Object.hasOwnProperty.call(message, "quantity")) + $root.google.protobuf.Int32Value.encode(message.quantity, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ProductDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {google.cloud.retail.v2.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.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.cloud.retail.v2.ProductDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.quantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductDetail message. + * @function verify + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.quantity != null && message.hasOwnProperty("quantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.quantity); + if (error) + return "quantity." + error; + } + return null; + }; + + /** + * Creates a ProductDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ProductDetail} ProductDetail + */ + ProductDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ProductDetail) + return object; + var message = new $root.google.cloud.retail.v2.ProductDetail(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2.ProductDetail.product: object expected"); + message.product = $root.google.cloud.retail.v2.Product.fromObject(object.product); + } + if (object.quantity != null) { + if (typeof object.quantity !== "object") + throw TypeError(".google.cloud.retail.v2.ProductDetail.quantity: object expected"); + message.quantity = $root.google.protobuf.Int32Value.fromObject(object.quantity); + } + return message; + }; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {google.cloud.retail.v2.ProductDetail} message ProductDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.quantity = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2.Product.toObject(message.product, options); + if (message.quantity != null && message.hasOwnProperty("quantity")) + object.quantity = $root.google.protobuf.Int32Value.toObject(message.quantity, options); + return object; + }; + + /** + * Converts this ProductDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ProductDetail + * @instance + * @returns {Object.} JSON object + */ + ProductDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ProductDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ProductDetail"; + }; + + return ProductDetail; + })(); + + v2.CompletionDetail = (function() { + + /** + * Properties of a CompletionDetail. + * @memberof google.cloud.retail.v2 + * @interface ICompletionDetail + * @property {string|null} [completionAttributionToken] CompletionDetail completionAttributionToken + * @property {string|null} [selectedSuggestion] CompletionDetail selectedSuggestion + * @property {number|null} [selectedPosition] CompletionDetail selectedPosition + */ + + /** + * Constructs a new CompletionDetail. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompletionDetail. + * @implements ICompletionDetail + * @constructor + * @param {google.cloud.retail.v2.ICompletionDetail=} [properties] Properties to set + */ + function CompletionDetail(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]]; + } + + /** + * CompletionDetail completionAttributionToken. + * @member {string} completionAttributionToken + * @memberof google.cloud.retail.v2.CompletionDetail + * @instance + */ + CompletionDetail.prototype.completionAttributionToken = ""; + + /** + * CompletionDetail selectedSuggestion. + * @member {string} selectedSuggestion + * @memberof google.cloud.retail.v2.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedSuggestion = ""; + + /** + * CompletionDetail selectedPosition. + * @member {number} selectedPosition + * @memberof google.cloud.retail.v2.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedPosition = 0; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {google.cloud.retail.v2.ICompletionDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompletionDetail} CompletionDetail instance + */ + CompletionDetail.create = function create(properties) { + return new CompletionDetail(properties); + }; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2.CompletionDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {google.cloud.retail.v2.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionAttributionToken != null && Object.hasOwnProperty.call(message, "completionAttributionToken")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.completionAttributionToken); + if (message.selectedSuggestion != null && Object.hasOwnProperty.call(message, "selectedSuggestion")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.selectedSuggestion); + if (message.selectedPosition != null && Object.hasOwnProperty.call(message, "selectedPosition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.selectedPosition); + return writer; + }; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompletionDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {google.cloud.retail.v2.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.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.cloud.retail.v2.CompletionDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionAttributionToken = reader.string(); + break; + } + case 2: { + message.selectedSuggestion = reader.string(); + break; + } + case 3: { + message.selectedPosition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDetail message. + * @function verify + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + if (!$util.isString(message.completionAttributionToken)) + return "completionAttributionToken: string expected"; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + if (!$util.isString(message.selectedSuggestion)) + return "selectedSuggestion: string expected"; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + if (!$util.isInteger(message.selectedPosition)) + return "selectedPosition: integer expected"; + return null; + }; + + /** + * Creates a CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompletionDetail} CompletionDetail + */ + CompletionDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompletionDetail) + return object; + var message = new $root.google.cloud.retail.v2.CompletionDetail(); + if (object.completionAttributionToken != null) + message.completionAttributionToken = String(object.completionAttributionToken); + if (object.selectedSuggestion != null) + message.selectedSuggestion = String(object.selectedSuggestion); + if (object.selectedPosition != null) + message.selectedPosition = object.selectedPosition | 0; + return message; + }; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {google.cloud.retail.v2.CompletionDetail} message CompletionDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionAttributionToken = ""; + object.selectedSuggestion = ""; + object.selectedPosition = 0; + } + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + object.completionAttributionToken = message.completionAttributionToken; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + object.selectedSuggestion = message.selectedSuggestion; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + object.selectedPosition = message.selectedPosition; + return object; + }; + + /** + * Converts this CompletionDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompletionDetail + * @instance + * @returns {Object.} JSON object + */ + CompletionDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompletionDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompletionDetail"; + }; + + return CompletionDetail; + })(); + + v2.PurchaseTransaction = (function() { + + /** + * Properties of a PurchaseTransaction. + * @memberof google.cloud.retail.v2 + * @interface IPurchaseTransaction + * @property {string|null} [id] PurchaseTransaction id + * @property {number|null} [revenue] PurchaseTransaction revenue + * @property {number|null} [tax] PurchaseTransaction tax + * @property {number|null} [cost] PurchaseTransaction cost + * @property {string|null} [currencyCode] PurchaseTransaction currencyCode + */ + + /** + * Constructs a new PurchaseTransaction. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PurchaseTransaction. + * @implements IPurchaseTransaction + * @constructor + * @param {google.cloud.retail.v2.IPurchaseTransaction=} [properties] Properties to set + */ + function PurchaseTransaction(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]]; + } + + /** + * PurchaseTransaction id. + * @member {string} id + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.id = ""; + + /** + * PurchaseTransaction revenue. + * @member {number} revenue + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.revenue = 0; + + /** + * PurchaseTransaction tax. + * @member {number} tax + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.tax = 0; + + /** + * PurchaseTransaction cost. + * @member {number} cost + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.cost = 0; + + /** + * PurchaseTransaction currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.currencyCode = ""; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2.IPurchaseTransaction=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PurchaseTransaction} PurchaseTransaction instance + */ + PurchaseTransaction.create = function create(properties) { + return new PurchaseTransaction(properties); + }; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2.PurchaseTransaction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.revenue != null && Object.hasOwnProperty.call(message, "revenue")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.revenue); + if (message.tax != null && Object.hasOwnProperty.call(message, "tax")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.tax); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.currencyCode); + return writer; + }; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurchaseTransaction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.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.cloud.retail.v2.PurchaseTransaction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.revenue = reader.float(); + break; + } + case 3: { + message.tax = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.currencyCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurchaseTransaction message. + * @function verify + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurchaseTransaction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.revenue != null && message.hasOwnProperty("revenue")) + if (typeof message.revenue !== "number") + return "revenue: number expected"; + if (message.tax != null && message.hasOwnProperty("tax")) + if (typeof message.tax !== "number") + return "tax: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + return null; + }; + + /** + * Creates a PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PurchaseTransaction} PurchaseTransaction + */ + PurchaseTransaction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PurchaseTransaction) + return object; + var message = new $root.google.cloud.retail.v2.PurchaseTransaction(); + if (object.id != null) + message.id = String(object.id); + if (object.revenue != null) + message.revenue = Number(object.revenue); + if (object.tax != null) + message.tax = Number(object.tax); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + return message; + }; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2.PurchaseTransaction} message PurchaseTransaction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurchaseTransaction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.revenue = 0; + object.tax = 0; + object.cost = 0; + object.currencyCode = ""; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.revenue != null && message.hasOwnProperty("revenue")) + object.revenue = options.json && !isFinite(message.revenue) ? String(message.revenue) : message.revenue; + if (message.tax != null && message.hasOwnProperty("tax")) + object.tax = options.json && !isFinite(message.tax) ? String(message.tax) : message.tax; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + return object; + }; + + /** + * Converts this PurchaseTransaction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @instance + * @returns {Object.} JSON object + */ + PurchaseTransaction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurchaseTransaction + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PurchaseTransaction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurchaseTransaction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PurchaseTransaction"; + }; + + return PurchaseTransaction; + })(); + + v2.CatalogService = (function() { + + /** + * Constructs a new CatalogService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CatalogService + * @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 CatalogService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CatalogService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CatalogService; + + /** + * Creates new CatalogService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.CatalogService + * @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 {CatalogService} RPC service. Useful where requests and/or responses are streamed. + */ + CatalogService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|listCatalogs}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef ListCatalogsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ListCatalogsResponse} [response] ListCatalogsResponse + */ + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.ListCatalogsCallback} callback Node-style callback called with the error, if any, and ListCatalogsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.listCatalogs = function listCatalogs(request, callback) { + return this.rpcCall(listCatalogs, $root.google.cloud.retail.v2.ListCatalogsRequest, $root.google.cloud.retail.v2.ListCatalogsResponse, request, callback); + }, "name", { value: "ListCatalogs" }); + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateCatalog}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef UpdateCatalogCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Catalog} [response] Catalog + */ + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.UpdateCatalogCallback} callback Node-style callback called with the error, if any, and Catalog + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCatalog = function updateCatalog(request, callback) { + return this.rpcCall(updateCatalog, $root.google.cloud.retail.v2.UpdateCatalogRequest, $root.google.cloud.retail.v2.Catalog, request, callback); + }, "name", { value: "UpdateCatalog" }); + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|setDefaultBranch}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef SetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.SetDefaultBranchCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.setDefaultBranch = function setDefaultBranch(request, callback) { + return this.rpcCall(setDefaultBranch, $root.google.cloud.retail.v2.SetDefaultBranchRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "SetDefaultBranch" }); + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getDefaultBranch}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef GetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.GetDefaultBranchResponse} [response] GetDefaultBranchResponse + */ + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.GetDefaultBranchCallback} callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getDefaultBranch = function getDefaultBranch(request, callback) { + return this.rpcCall(getDefaultBranch, $root.google.cloud.retail.v2.GetDefaultBranchRequest, $root.google.cloud.retail.v2.GetDefaultBranchResponse, request, callback); + }, "name", { value: "GetDefaultBranch" }); + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getCompletionConfig}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef GetCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.GetCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getCompletionConfig = function getCompletionConfig(request, callback) { + return this.rpcCall(getCompletionConfig, $root.google.cloud.retail.v2.GetCompletionConfigRequest, $root.google.cloud.retail.v2.CompletionConfig, request, callback); + }, "name", { value: "GetCompletionConfig" }); + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateCompletionConfig}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef UpdateCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.UpdateCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCompletionConfig = function updateCompletionConfig(request, callback) { + return this.rpcCall(updateCompletionConfig, $root.google.cloud.retail.v2.UpdateCompletionConfigRequest, $root.google.cloud.retail.v2.CompletionConfig, request, callback); + }, "name", { value: "UpdateCompletionConfig" }); + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|getAttributesConfig}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef GetAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.GetAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getAttributesConfig = function getAttributesConfig(request, callback) { + return this.rpcCall(getAttributesConfig, $root.google.cloud.retail.v2.GetAttributesConfigRequest, $root.google.cloud.retail.v2.AttributesConfig, request, callback); + }, "name", { value: "GetAttributesConfig" }); + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|updateAttributesConfig}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef UpdateAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.UpdateAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateAttributesConfig = function updateAttributesConfig(request, callback) { + return this.rpcCall(updateAttributesConfig, $root.google.cloud.retail.v2.UpdateAttributesConfigRequest, $root.google.cloud.retail.v2.AttributesConfig, request, callback); + }, "name", { value: "UpdateAttributesConfig" }); + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|addCatalogAttribute}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef AddCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.AddCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.addCatalogAttribute = function addCatalogAttribute(request, callback) { + return this.rpcCall(addCatalogAttribute, $root.google.cloud.retail.v2.AddCatalogAttributeRequest, $root.google.cloud.retail.v2.AttributesConfig, request, callback); + }, "name", { value: "AddCatalogAttribute" }); + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|removeCatalogAttribute}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef RemoveCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.RemoveCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.removeCatalogAttribute = function removeCatalogAttribute(request, callback) { + return this.rpcCall(removeCatalogAttribute, $root.google.cloud.retail.v2.RemoveCatalogAttributeRequest, $root.google.cloud.retail.v2.AttributesConfig, request, callback); + }, "name", { value: "RemoveCatalogAttribute" }); + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CatalogService|replaceCatalogAttribute}. + * @memberof google.cloud.retail.v2.CatalogService + * @typedef ReplaceCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2.CatalogService.ReplaceCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.replaceCatalogAttribute = function replaceCatalogAttribute(request, callback) { + return this.rpcCall(replaceCatalogAttribute, $root.google.cloud.retail.v2.ReplaceCatalogAttributeRequest, $root.google.cloud.retail.v2.AttributesConfig, request, callback); + }, "name", { value: "ReplaceCatalogAttribute" }); + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2.CatalogService + * @instance + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CatalogService; + })(); + + v2.ListCatalogsRequest = (function() { + + /** + * Properties of a ListCatalogsRequest. + * @memberof google.cloud.retail.v2 + * @interface IListCatalogsRequest + * @property {string|null} [parent] ListCatalogsRequest parent + * @property {number|null} [pageSize] ListCatalogsRequest pageSize + * @property {string|null} [pageToken] ListCatalogsRequest pageToken + */ + + /** + * Constructs a new ListCatalogsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListCatalogsRequest. + * @implements IListCatalogsRequest + * @constructor + * @param {google.cloud.retail.v2.IListCatalogsRequest=} [properties] Properties to set + */ + function ListCatalogsRequest(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]]; + } + + /** + * ListCatalogsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.parent = ""; + + /** + * ListCatalogsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageSize = 0; + + /** + * ListCatalogsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2.IListCatalogsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListCatalogsRequest} ListCatalogsRequest instance + */ + ListCatalogsRequest.create = function create(properties) { + return new ListCatalogsRequest(properties); + }; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.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.cloud.retail.v2.ListCatalogsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListCatalogsRequest} ListCatalogsRequest + */ + ListCatalogsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListCatalogsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ListCatalogsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListCatalogsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2.ListCatalogsRequest} message ListCatalogsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListCatalogsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListCatalogsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListCatalogsRequest"; + }; + + return ListCatalogsRequest; + })(); + + v2.ListCatalogsResponse = (function() { + + /** + * Properties of a ListCatalogsResponse. + * @memberof google.cloud.retail.v2 + * @interface IListCatalogsResponse + * @property {Array.|null} [catalogs] ListCatalogsResponse catalogs + * @property {string|null} [nextPageToken] ListCatalogsResponse nextPageToken + */ + + /** + * Constructs a new ListCatalogsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListCatalogsResponse. + * @implements IListCatalogsResponse + * @constructor + * @param {google.cloud.retail.v2.IListCatalogsResponse=} [properties] Properties to set + */ + function ListCatalogsResponse(properties) { + this.catalogs = []; + 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]]; + } + + /** + * ListCatalogsResponse catalogs. + * @member {Array.} catalogs + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.catalogs = $util.emptyArray; + + /** + * ListCatalogsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2.IListCatalogsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListCatalogsResponse} ListCatalogsResponse instance + */ + ListCatalogsResponse.create = function create(properties) { + return new ListCatalogsResponse(properties); + }; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalogs != null && message.catalogs.length) + for (var i = 0; i < message.catalogs.length; ++i) + $root.google.cloud.retail.v2.Catalog.encode(message.catalogs[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 ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListCatalogsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.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.cloud.retail.v2.ListCatalogsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.catalogs && message.catalogs.length)) + message.catalogs = []; + message.catalogs.push($root.google.cloud.retail.v2.Catalog.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalogs != null && message.hasOwnProperty("catalogs")) { + if (!Array.isArray(message.catalogs)) + return "catalogs: array expected"; + for (var i = 0; i < message.catalogs.length; ++i) { + var error = $root.google.cloud.retail.v2.Catalog.verify(message.catalogs[i]); + if (error) + return "catalogs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListCatalogsResponse} ListCatalogsResponse + */ + ListCatalogsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListCatalogsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ListCatalogsResponse(); + if (object.catalogs) { + if (!Array.isArray(object.catalogs)) + throw TypeError(".google.cloud.retail.v2.ListCatalogsResponse.catalogs: array expected"); + message.catalogs = []; + for (var i = 0; i < object.catalogs.length; ++i) { + if (typeof object.catalogs[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ListCatalogsResponse.catalogs: object expected"); + message.catalogs[i] = $root.google.cloud.retail.v2.Catalog.fromObject(object.catalogs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2.ListCatalogsResponse} message ListCatalogsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.catalogs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.catalogs && message.catalogs.length) { + object.catalogs = []; + for (var j = 0; j < message.catalogs.length; ++j) + object.catalogs[j] = $root.google.cloud.retail.v2.Catalog.toObject(message.catalogs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListCatalogsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListCatalogsResponse"; + }; + + return ListCatalogsResponse; + })(); + + v2.UpdateCatalogRequest = (function() { + + /** + * Properties of an UpdateCatalogRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateCatalogRequest + * @property {google.cloud.retail.v2.ICatalog|null} [catalog] UpdateCatalogRequest catalog + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCatalogRequest updateMask + */ + + /** + * Constructs a new UpdateCatalogRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateCatalogRequest. + * @implements IUpdateCatalogRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateCatalogRequest=} [properties] Properties to set + */ + function UpdateCatalogRequest(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]]; + } + + /** + * UpdateCatalogRequest catalog. + * @member {google.cloud.retail.v2.ICatalog|null|undefined} catalog + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.catalog = null; + + /** + * UpdateCatalogRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCatalogRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateCatalogRequest} UpdateCatalogRequest instance + */ + UpdateCatalogRequest.create = function create(properties) { + return new UpdateCatalogRequest(properties); + }; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateCatalogRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + $root.google.cloud.retail.v2.Catalog.encode(message.catalog, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateCatalogRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.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.cloud.retail.v2.UpdateCatalogRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = $root.google.cloud.retail.v2.Catalog.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCatalogRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCatalogRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) { + var error = $root.google.cloud.retail.v2.Catalog.verify(message.catalog); + if (error) + return "catalog." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateCatalogRequest} UpdateCatalogRequest + */ + UpdateCatalogRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateCatalogRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateCatalogRequest(); + if (object.catalog != null) { + if (typeof object.catalog !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateCatalogRequest.catalog: object expected"); + message.catalog = $root.google.cloud.retail.v2.Catalog.fromObject(object.catalog); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateCatalogRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2.UpdateCatalogRequest} message UpdateCatalogRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCatalogRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = null; + object.updateMask = null; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = $root.google.cloud.retail.v2.Catalog.toObject(message.catalog, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCatalogRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateCatalogRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCatalogRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateCatalogRequest"; + }; + + return UpdateCatalogRequest; + })(); + + v2.SetDefaultBranchRequest = (function() { + + /** + * Properties of a SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2 + * @interface ISetDefaultBranchRequest + * @property {string|null} [catalog] SetDefaultBranchRequest catalog + * @property {string|null} [branchId] SetDefaultBranchRequest branchId + * @property {string|null} [note] SetDefaultBranchRequest note + * @property {boolean|null} [force] SetDefaultBranchRequest force + */ + + /** + * Constructs a new SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SetDefaultBranchRequest. + * @implements ISetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest=} [properties] Properties to set + */ + function SetDefaultBranchRequest(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]]; + } + + /** + * SetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.catalog = ""; + + /** + * SetDefaultBranchRequest branchId. + * @member {string} branchId + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.branchId = ""; + + /** + * SetDefaultBranchRequest note. + * @member {string} note + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.note = ""; + + /** + * SetDefaultBranchRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.force = false; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SetDefaultBranchRequest} SetDefaultBranchRequest instance + */ + SetDefaultBranchRequest.create = function create(properties) { + return new SetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2.SetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.branchId != null && Object.hasOwnProperty.call(message, "branchId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branchId); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.force); + return writer; + }; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.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.cloud.retail.v2.SetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.branchId = reader.string(); + break; + } + case 3: { + message.note = reader.string(); + break; + } + case 4: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.branchId != null && message.hasOwnProperty("branchId")) + if (!$util.isString(message.branchId)) + return "branchId: string expected"; + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SetDefaultBranchRequest} SetDefaultBranchRequest + */ + SetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2.SetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.branchId != null) + message.branchId = String(object.branchId); + if (object.note != null) + message.note = String(object.note); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.SetDefaultBranchRequest} message SetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = ""; + object.branchId = ""; + object.note = ""; + object.force = false; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.branchId != null && message.hasOwnProperty("branchId")) + object.branchId = message.branchId; + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + SetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SetDefaultBranchRequest"; + }; + + return SetDefaultBranchRequest; + })(); + + v2.GetDefaultBranchRequest = (function() { + + /** + * Properties of a GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetDefaultBranchRequest + * @property {string|null} [catalog] GetDefaultBranchRequest catalog + */ + + /** + * Constructs a new GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetDefaultBranchRequest. + * @implements IGetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest=} [properties] Properties to set + */ + function GetDefaultBranchRequest(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]]; + } + + /** + * GetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @instance + */ + GetDefaultBranchRequest.prototype.catalog = ""; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetDefaultBranchRequest} GetDefaultBranchRequest instance + */ + GetDefaultBranchRequest.create = function create(properties) { + return new GetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.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.cloud.retail.v2.GetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetDefaultBranchRequest} GetDefaultBranchRequest + */ + GetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2.GetDefaultBranchRequest} message GetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.catalog = ""; + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + return object; + }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetDefaultBranchRequest"; + }; + + return GetDefaultBranchRequest; + })(); + + v2.GetDefaultBranchResponse = (function() { + + /** + * Properties of a GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2 + * @interface IGetDefaultBranchResponse + * @property {string|null} [branch] GetDefaultBranchResponse branch + * @property {google.protobuf.ITimestamp|null} [setTime] GetDefaultBranchResponse setTime + * @property {string|null} [note] GetDefaultBranchResponse note + */ + + /** + * Constructs a new GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetDefaultBranchResponse. + * @implements IGetDefaultBranchResponse + * @constructor + * @param {google.cloud.retail.v2.IGetDefaultBranchResponse=} [properties] Properties to set + */ + function GetDefaultBranchResponse(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]]; + } + + /** + * GetDefaultBranchResponse branch. + * @member {string} branch + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.branch = ""; + + /** + * GetDefaultBranchResponse setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.setTime = null; + + /** + * GetDefaultBranchResponse note. + * @member {string} note + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.note = ""; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetDefaultBranchResponse} GetDefaultBranchResponse instance + */ + GetDefaultBranchResponse.create = function create(properties) { + return new GetDefaultBranchResponse(properties); + }; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.branch); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetDefaultBranchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.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.cloud.retail.v2.GetDefaultBranchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.branch = reader.string(); + break; + } + case 2: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.note = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchResponse message. + * @function verify + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetDefaultBranchResponse} GetDefaultBranchResponse + */ + GetDefaultBranchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetDefaultBranchResponse) + return object; + var message = new $root.google.cloud.retail.v2.GetDefaultBranchResponse(); + if (object.branch != null) + message.branch = String(object.branch); + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2.GetDefaultBranchResponse.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.note != null) + message.note = String(object.note); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2.GetDefaultBranchResponse} message GetDefaultBranchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.branch = ""; + object.setTime = null; + object.note = ""; + } + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + return object; + }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetDefaultBranchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetDefaultBranchResponse"; + }; + + return GetDefaultBranchResponse; + })(); + + v2.GetCompletionConfigRequest = (function() { + + /** + * Properties of a GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetCompletionConfigRequest + * @property {string|null} [name] GetCompletionConfigRequest name + */ + + /** + * Constructs a new GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetCompletionConfigRequest. + * @implements IGetCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest=} [properties] Properties to set + */ + function GetCompletionConfigRequest(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]]; + } + + /** + * GetCompletionConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @instance + */ + GetCompletionConfigRequest.prototype.name = ""; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetCompletionConfigRequest} GetCompletionConfigRequest instance + */ + GetCompletionConfigRequest.create = function create(properties) { + return new GetCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.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.cloud.retail.v2.GetCompletionConfigRequest(); + 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 GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetCompletionConfigRequest} GetCompletionConfigRequest + */ + GetCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetCompletionConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.GetCompletionConfigRequest} message GetCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetCompletionConfigRequest"; + }; + + return GetCompletionConfigRequest; + })(); + + v2.UpdateCompletionConfigRequest = (function() { + + /** + * Properties of an UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateCompletionConfigRequest + * @property {google.cloud.retail.v2.ICompletionConfig|null} [completionConfig] UpdateCompletionConfigRequest completionConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCompletionConfigRequest updateMask + */ + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateCompletionConfigRequest. + * @implements IUpdateCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest=} [properties] Properties to set + */ + function UpdateCompletionConfigRequest(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]]; + } + + /** + * UpdateCompletionConfigRequest completionConfig. + * @member {google.cloud.retail.v2.ICompletionConfig|null|undefined} completionConfig + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.completionConfig = null; + + /** + * UpdateCompletionConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest instance + */ + UpdateCompletionConfigRequest.create = function create(properties) { + return new UpdateCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionConfig != null && Object.hasOwnProperty.call(message, "completionConfig")) + $root.google.cloud.retail.v2.CompletionConfig.encode(message.completionConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.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.cloud.retail.v2.UpdateCompletionConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionConfig = $root.google.cloud.retail.v2.CompletionConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCompletionConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) { + var error = $root.google.cloud.retail.v2.CompletionConfig.verify(message.completionConfig); + if (error) + return "completionConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + */ + UpdateCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateCompletionConfigRequest(); + if (object.completionConfig != null) { + if (typeof object.completionConfig !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateCompletionConfigRequest.completionConfig: object expected"); + message.completionConfig = $root.google.cloud.retail.v2.CompletionConfig.fromObject(object.completionConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateCompletionConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2.UpdateCompletionConfigRequest} message UpdateCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCompletionConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionConfig = null; + object.updateMask = null; + } + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) + object.completionConfig = $root.google.cloud.retail.v2.CompletionConfig.toObject(message.completionConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateCompletionConfigRequest"; + }; + + return UpdateCompletionConfigRequest; + })(); + + v2.GetAttributesConfigRequest = (function() { + + /** + * Properties of a GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetAttributesConfigRequest + * @property {string|null} [name] GetAttributesConfigRequest name + */ + + /** + * Constructs a new GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetAttributesConfigRequest. + * @implements IGetAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest=} [properties] Properties to set + */ + function GetAttributesConfigRequest(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]]; + } + + /** + * GetAttributesConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @instance + */ + GetAttributesConfigRequest.prototype.name = ""; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetAttributesConfigRequest} GetAttributesConfigRequest instance + */ + GetAttributesConfigRequest.create = function create(properties) { + return new GetAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.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.cloud.retail.v2.GetAttributesConfigRequest(); + 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 GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetAttributesConfigRequest} GetAttributesConfigRequest + */ + GetAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetAttributesConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.GetAttributesConfigRequest} message GetAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetAttributesConfigRequest"; + }; + + return GetAttributesConfigRequest; + })(); + + v2.UpdateAttributesConfigRequest = (function() { + + /** + * Properties of an UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateAttributesConfigRequest + * @property {google.cloud.retail.v2.IAttributesConfig|null} [attributesConfig] UpdateAttributesConfigRequest attributesConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateAttributesConfigRequest updateMask + */ + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateAttributesConfigRequest. + * @implements IUpdateAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest=} [properties] Properties to set + */ + function UpdateAttributesConfigRequest(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]]; + } + + /** + * UpdateAttributesConfigRequest attributesConfig. + * @member {google.cloud.retail.v2.IAttributesConfig|null|undefined} attributesConfig + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.attributesConfig = null; + + /** + * UpdateAttributesConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest instance + */ + UpdateAttributesConfigRequest.create = function create(properties) { + return new UpdateAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + $root.google.cloud.retail.v2.AttributesConfig.encode(message.attributesConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.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.cloud.retail.v2.UpdateAttributesConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = $root.google.cloud.retail.v2.AttributesConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateAttributesConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) { + var error = $root.google.cloud.retail.v2.AttributesConfig.verify(message.attributesConfig); + if (error) + return "attributesConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + */ + UpdateAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateAttributesConfigRequest(); + if (object.attributesConfig != null) { + if (typeof object.attributesConfig !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateAttributesConfigRequest.attributesConfig: object expected"); + message.attributesConfig = $root.google.cloud.retail.v2.AttributesConfig.fromObject(object.attributesConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateAttributesConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2.UpdateAttributesConfigRequest} message UpdateAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateAttributesConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = $root.google.cloud.retail.v2.AttributesConfig.toObject(message.attributesConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateAttributesConfigRequest"; + }; + + return UpdateAttributesConfigRequest; + })(); + + v2.AddCatalogAttributeRequest = (function() { + + /** + * Properties of an AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @interface IAddCatalogAttributeRequest + * @property {string|null} [attributesConfig] AddCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2.ICatalogAttribute|null} [catalogAttribute] AddCatalogAttributeRequest catalogAttribute + */ + + /** + * Constructs a new AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddCatalogAttributeRequest. + * @implements IAddCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest=} [properties] Properties to set + */ + function AddCatalogAttributeRequest(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]]; + } + + /** + * AddCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * AddCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddCatalogAttributeRequest} AddCatalogAttributeRequest instance + */ + AddCatalogAttributeRequest.create = function create(properties) { + return new AddCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.AddCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.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.cloud.retail.v2.AddCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + return null; + }; + + /** + * Creates an AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddCatalogAttributeRequest} AddCatalogAttributeRequest + */ + AddCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2.AddCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2.AddCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.fromObject(object.catalogAttribute); + } + return message; + }; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.AddCatalogAttributeRequest} message AddCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.toObject(message.catalogAttribute, options); + return object; + }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + AddCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddCatalogAttributeRequest"; + }; + + return AddCatalogAttributeRequest; + })(); + + v2.RemoveCatalogAttributeRequest = (function() { + + /** + * Properties of a RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @interface IRemoveCatalogAttributeRequest + * @property {string|null} [attributesConfig] RemoveCatalogAttributeRequest attributesConfig + * @property {string|null} [key] RemoveCatalogAttributeRequest key + */ + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveCatalogAttributeRequest. + * @implements IRemoveCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest=} [properties] Properties to set + */ + function RemoveCatalogAttributeRequest(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]]; + } + + /** + * RemoveCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * RemoveCatalogAttributeRequest key. + * @member {string} key + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.key = ""; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest instance + */ + RemoveCatalogAttributeRequest.create = function create(properties) { + return new RemoveCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.key); + return writer; + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.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.cloud.retail.v2.RemoveCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.key = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + return null; + }; + + /** + * Creates a RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + */ + RemoveCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2.RemoveCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.key != null) + message.key = String(object.key); + return message; + }; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.RemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.key = ""; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + return object; + }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveCatalogAttributeRequest"; + }; + + return RemoveCatalogAttributeRequest; + })(); + + v2.ReplaceCatalogAttributeRequest = (function() { + + /** + * Properties of a ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @interface IReplaceCatalogAttributeRequest + * @property {string|null} [attributesConfig] ReplaceCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2.ICatalogAttribute|null} [catalogAttribute] ReplaceCatalogAttributeRequest catalogAttribute + * @property {google.protobuf.IFieldMask|null} [updateMask] ReplaceCatalogAttributeRequest updateMask + */ + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ReplaceCatalogAttributeRequest. + * @implements IReplaceCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest=} [properties] Properties to set + */ + function ReplaceCatalogAttributeRequest(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]]; + } + + /** + * ReplaceCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * ReplaceCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * ReplaceCatalogAttributeRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.updateMask = null; + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest instance + */ + ReplaceCatalogAttributeRequest.create = function create(properties) { + return new ReplaceCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.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.cloud.retail.v2.ReplaceCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + case 3: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplaceCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplaceCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates a ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + */ + ReplaceCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ReplaceCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2.ReplaceCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2.ReplaceCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.fromObject(object.catalogAttribute); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.ReplaceCatalogAttributeRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2.ReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplaceCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2.CatalogAttribute.toObject(message.catalogAttribute, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + ReplaceCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ReplaceCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplaceCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ReplaceCatalogAttributeRequest"; + }; + + return ReplaceCatalogAttributeRequest; + })(); + + v2.CompletionService = (function() { + + /** + * Constructs a new CompletionService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompletionService + * @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 CompletionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CompletionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CompletionService; + + /** + * Creates new CompletionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.CompletionService + * @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 {CompletionService} RPC service. Useful where requests and/or responses are streamed. + */ + CompletionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.CompletionService|completeQuery}. + * @memberof google.cloud.retail.v2.CompletionService + * @typedef CompleteQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.CompleteQueryResponse} [response] CompleteQueryResponse + */ + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2.CompletionService + * @instance + * @param {google.cloud.retail.v2.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @param {google.cloud.retail.v2.CompletionService.CompleteQueryCallback} callback Node-style callback called with the error, if any, and CompleteQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.completeQuery = function completeQuery(request, callback) { + return this.rpcCall(completeQuery, $root.google.cloud.retail.v2.CompleteQueryRequest, $root.google.cloud.retail.v2.CompleteQueryResponse, request, callback); + }, "name", { value: "CompleteQuery" }); + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2.CompletionService + * @instance + * @param {google.cloud.retail.v2.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.CompletionService|importCompletionData}. + * @memberof google.cloud.retail.v2.CompletionService + * @typedef ImportCompletionDataCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2.CompletionService + * @instance + * @param {google.cloud.retail.v2.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @param {google.cloud.retail.v2.CompletionService.ImportCompletionDataCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.importCompletionData = function importCompletionData(request, callback) { + return this.rpcCall(importCompletionData, $root.google.cloud.retail.v2.ImportCompletionDataRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportCompletionData" }); + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2.CompletionService + * @instance + * @param {google.cloud.retail.v2.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CompletionService; + })(); + + v2.CompleteQueryRequest = (function() { + + /** + * Properties of a CompleteQueryRequest. + * @memberof google.cloud.retail.v2 + * @interface ICompleteQueryRequest + * @property {string|null} [catalog] CompleteQueryRequest catalog + * @property {string|null} [query] CompleteQueryRequest query + * @property {string|null} [visitorId] CompleteQueryRequest visitorId + * @property {Array.|null} [languageCodes] CompleteQueryRequest languageCodes + * @property {string|null} [deviceType] CompleteQueryRequest deviceType + * @property {string|null} [dataset] CompleteQueryRequest dataset + * @property {number|null} [maxSuggestions] CompleteQueryRequest maxSuggestions + */ + + /** + * Constructs a new CompleteQueryRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompleteQueryRequest. + * @implements ICompleteQueryRequest + * @constructor + * @param {google.cloud.retail.v2.ICompleteQueryRequest=} [properties] Properties to set + */ + function CompleteQueryRequest(properties) { + this.languageCodes = []; + 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]]; + } + + /** + * CompleteQueryRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.catalog = ""; + + /** + * CompleteQueryRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.query = ""; + + /** + * CompleteQueryRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.visitorId = ""; + + /** + * CompleteQueryRequest languageCodes. + * @member {Array.} languageCodes + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.languageCodes = $util.emptyArray; + + /** + * CompleteQueryRequest deviceType. + * @member {string} deviceType + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.deviceType = ""; + + /** + * CompleteQueryRequest dataset. + * @member {string} dataset + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.dataset = ""; + + /** + * CompleteQueryRequest maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.maxSuggestions = 0; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2.ICompleteQueryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompleteQueryRequest} CompleteQueryRequest instance + */ + CompleteQueryRequest.create = function create(properties) { + return new CompleteQueryRequest(properties); + }; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.query); + if (message.languageCodes != null && message.languageCodes.length) + for (var i = 0; i < message.languageCodes.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.languageCodes[i]); + if (message.deviceType != null && Object.hasOwnProperty.call(message, "deviceType")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.deviceType); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.maxSuggestions); + if (message.dataset != null && Object.hasOwnProperty.call(message, "dataset")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.dataset); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.visitorId); + return writer; + }; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.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.cloud.retail.v2.CompleteQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.query = reader.string(); + break; + } + case 7: { + message.visitorId = reader.string(); + break; + } + case 3: { + if (!(message.languageCodes && message.languageCodes.length)) + message.languageCodes = []; + message.languageCodes.push(reader.string()); + break; + } + case 4: { + message.deviceType = reader.string(); + break; + } + case 6: { + message.dataset = reader.string(); + break; + } + case 5: { + message.maxSuggestions = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryRequest message. + * @function verify + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.languageCodes != null && message.hasOwnProperty("languageCodes")) { + if (!Array.isArray(message.languageCodes)) + return "languageCodes: array expected"; + for (var i = 0; i < message.languageCodes.length; ++i) + if (!$util.isString(message.languageCodes[i])) + return "languageCodes: string[] expected"; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + if (!$util.isString(message.deviceType)) + return "deviceType: string expected"; + if (message.dataset != null && message.hasOwnProperty("dataset")) + if (!$util.isString(message.dataset)) + return "dataset: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + return null; + }; + + /** + * Creates a CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompleteQueryRequest} CompleteQueryRequest + */ + CompleteQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompleteQueryRequest) + return object; + var message = new $root.google.cloud.retail.v2.CompleteQueryRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.languageCodes) { + if (!Array.isArray(object.languageCodes)) + throw TypeError(".google.cloud.retail.v2.CompleteQueryRequest.languageCodes: array expected"); + message.languageCodes = []; + for (var i = 0; i < object.languageCodes.length; ++i) + message.languageCodes[i] = String(object.languageCodes[i]); + } + if (object.deviceType != null) + message.deviceType = String(object.deviceType); + if (object.dataset != null) + message.dataset = String(object.dataset); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + return message; + }; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2.CompleteQueryRequest} message CompleteQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languageCodes = []; + if (options.defaults) { + object.catalog = ""; + object.query = ""; + object.deviceType = ""; + object.maxSuggestions = 0; + object.dataset = ""; + object.visitorId = ""; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.languageCodes && message.languageCodes.length) { + object.languageCodes = []; + for (var j = 0; j < message.languageCodes.length; ++j) + object.languageCodes[j] = message.languageCodes[j]; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + object.deviceType = message.deviceType; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.dataset != null && message.hasOwnProperty("dataset")) + object.dataset = message.dataset; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + return object; + }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompleteQueryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompleteQueryRequest"; + }; + + return CompleteQueryRequest; + })(); + + v2.CompleteQueryResponse = (function() { + + /** + * Properties of a CompleteQueryResponse. + * @memberof google.cloud.retail.v2 + * @interface ICompleteQueryResponse + * @property {Array.|null} [completionResults] CompleteQueryResponse completionResults + * @property {string|null} [attributionToken] CompleteQueryResponse attributionToken + * @property {Array.|null} [recentSearchResults] CompleteQueryResponse recentSearchResults + */ + + /** + * Constructs a new CompleteQueryResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CompleteQueryResponse. + * @implements ICompleteQueryResponse + * @constructor + * @param {google.cloud.retail.v2.ICompleteQueryResponse=} [properties] Properties to set + */ + function CompleteQueryResponse(properties) { + this.completionResults = []; + this.recentSearchResults = []; + 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]]; + } + + /** + * CompleteQueryResponse completionResults. + * @member {Array.} completionResults + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.completionResults = $util.emptyArray; + + /** + * CompleteQueryResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.attributionToken = ""; + + /** + * CompleteQueryResponse recentSearchResults. + * @member {Array.} recentSearchResults + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.recentSearchResults = $util.emptyArray; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2.ICompleteQueryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompleteQueryResponse} CompleteQueryResponse instance + */ + CompleteQueryResponse.create = function create(properties) { + return new CompleteQueryResponse(properties); + }; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionResults != null && message.completionResults.length) + for (var i = 0; i < message.completionResults.length; ++i) + $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.encode(message.completionResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.recentSearchResults != null && message.recentSearchResults.length) + for (var i = 0; i < message.recentSearchResults.length; ++i) + $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.encode(message.recentSearchResults[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.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.cloud.retail.v2.CompleteQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.completionResults && message.completionResults.length)) + message.completionResults = []; + message.completionResults.push($root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.recentSearchResults && message.recentSearchResults.length)) + message.recentSearchResults = []; + message.recentSearchResults.push($root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryResponse message. + * @function verify + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionResults != null && message.hasOwnProperty("completionResults")) { + if (!Array.isArray(message.completionResults)) + return "completionResults: array expected"; + for (var i = 0; i < message.completionResults.length; ++i) { + var error = $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.verify(message.completionResults[i]); + if (error) + return "completionResults." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.recentSearchResults != null && message.hasOwnProperty("recentSearchResults")) { + if (!Array.isArray(message.recentSearchResults)) + return "recentSearchResults: array expected"; + for (var i = 0; i < message.recentSearchResults.length; ++i) { + var error = $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.verify(message.recentSearchResults[i]); + if (error) + return "recentSearchResults." + error; + } + } + return null; + }; + + /** + * Creates a CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompleteQueryResponse} CompleteQueryResponse + */ + CompleteQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompleteQueryResponse) + return object; + var message = new $root.google.cloud.retail.v2.CompleteQueryResponse(); + if (object.completionResults) { + if (!Array.isArray(object.completionResults)) + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.completionResults: array expected"); + message.completionResults = []; + for (var i = 0; i < object.completionResults.length; ++i) { + if (typeof object.completionResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.completionResults: object expected"); + message.completionResults[i] = $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.fromObject(object.completionResults[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.recentSearchResults) { + if (!Array.isArray(object.recentSearchResults)) + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.recentSearchResults: array expected"); + message.recentSearchResults = []; + for (var i = 0; i < object.recentSearchResults.length; ++i) { + if (typeof object.recentSearchResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.recentSearchResults: object expected"); + message.recentSearchResults[i] = $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.fromObject(object.recentSearchResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse} message CompleteQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.completionResults = []; + object.recentSearchResults = []; + } + if (options.defaults) + object.attributionToken = ""; + if (message.completionResults && message.completionResults.length) { + object.completionResults = []; + for (var j = 0; j < message.completionResults.length; ++j) + object.completionResults[j] = $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.toObject(message.completionResults[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.recentSearchResults && message.recentSearchResults.length) { + object.recentSearchResults = []; + for (var j = 0; j < message.recentSearchResults.length; ++j) + object.recentSearchResults[j] = $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.toObject(message.recentSearchResults[j], options); + } + return object; + }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompleteQueryResponse"; + }; + + CompleteQueryResponse.CompletionResult = (function() { + + /** + * Properties of a CompletionResult. + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @interface ICompletionResult + * @property {string|null} [suggestion] CompletionResult suggestion + * @property {Object.|null} [attributes] CompletionResult attributes + */ + + /** + * Constructs a new CompletionResult. + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @classdesc Represents a CompletionResult. + * @implements ICompletionResult + * @constructor + * @param {google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + */ + function CompletionResult(properties) { + this.attributes = {}; + 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]]; + } + + /** + * CompletionResult suggestion. + * @member {string} suggestion + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.suggestion = ""; + + /** + * CompletionResult attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.attributes = $util.emptyObject; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompleteQueryResponse.CompletionResult} CompletionResult instance + */ + CompletionResult.create = function create(properties) { + return new CompletionResult(properties); + }; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.suggestion != null && Object.hasOwnProperty.call(message, "suggestion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.suggestion); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.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.cloud.retail.v2.CompleteQueryResponse.CompletionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.suggestion = reader.string(); + break; + } + case 2: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionResult message. + * @function verify + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + if (!$util.isString(message.suggestion)) + return "suggestion: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + return null; + }; + + /** + * Creates a CompletionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompleteQueryResponse.CompletionResult} CompletionResult + */ + CompletionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult) + return object; + var message = new $root.google.cloud.retail.v2.CompleteQueryResponse.CompletionResult(); + if (object.suggestion != null) + message.suggestion = String(object.suggestion); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.CompletionResult} message CompletionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) + object.suggestion = ""; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + object.suggestion = message.suggestion; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + return object; + }; + + /** + * Converts this CompletionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @instance + * @returns {Object.} JSON object + */ + CompletionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompleteQueryResponse.CompletionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompleteQueryResponse.CompletionResult"; + }; + + return CompletionResult; + })(); + + CompleteQueryResponse.RecentSearchResult = (function() { + + /** + * Properties of a RecentSearchResult. + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @interface IRecentSearchResult + * @property {string|null} [recentSearch] RecentSearchResult recentSearch + */ + + /** + * Constructs a new RecentSearchResult. + * @memberof google.cloud.retail.v2.CompleteQueryResponse + * @classdesc Represents a RecentSearchResult. + * @implements IRecentSearchResult + * @constructor + * @param {google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + */ + function RecentSearchResult(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]]; + } + + /** + * RecentSearchResult recentSearch. + * @member {string} recentSearch + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @instance + */ + RecentSearchResult.prototype.recentSearch = ""; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult} RecentSearchResult instance + */ + RecentSearchResult.create = function create(properties) { + return new RecentSearchResult(properties); + }; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recentSearch != null && Object.hasOwnProperty.call(message, "recentSearch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.recentSearch); + return writer; + }; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.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.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recentSearch = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentSearchResult message. + * @function verify + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentSearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + if (!$util.isString(message.recentSearch)) + return "recentSearch: string expected"; + return null; + }; + + /** + * Creates a RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + */ + RecentSearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult) + return object; + var message = new $root.google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult(); + if (object.recentSearch != null) + message.recentSearch = String(object.recentSearch); + return message; + }; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult} message RecentSearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentSearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.recentSearch = ""; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + object.recentSearch = message.recentSearch; + return object; + }; + + /** + * Converts this RecentSearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @instance + * @returns {Object.} JSON object + */ + RecentSearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecentSearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecentSearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CompleteQueryResponse.RecentSearchResult"; + }; + + return RecentSearchResult; + })(); + + return CompleteQueryResponse; + })(); + + v2.Control = (function() { + + /** + * Properties of a Control. + * @memberof google.cloud.retail.v2 + * @interface IControl + * @property {google.cloud.retail.v2.IRule|null} [rule] Control rule + * @property {string|null} [name] Control name + * @property {string|null} [displayName] Control displayName + * @property {Array.|null} [associatedServingConfigIds] Control associatedServingConfigIds + * @property {Array.|null} [solutionTypes] Control solutionTypes + * @property {Array.|null} [searchSolutionUseCase] Control searchSolutionUseCase + */ + + /** + * Constructs a new Control. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a Control. + * @implements IControl + * @constructor + * @param {google.cloud.retail.v2.IControl=} [properties] Properties to set + */ + function Control(properties) { + this.associatedServingConfigIds = []; + this.solutionTypes = []; + this.searchSolutionUseCase = []; + 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]]; + } + + /** + * Control rule. + * @member {google.cloud.retail.v2.IRule|null|undefined} rule + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.rule = null; + + /** + * Control name. + * @member {string} name + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.name = ""; + + /** + * Control displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.displayName = ""; + + /** + * Control associatedServingConfigIds. + * @member {Array.} associatedServingConfigIds + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.associatedServingConfigIds = $util.emptyArray; + + /** + * Control solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.solutionTypes = $util.emptyArray; + + /** + * Control searchSolutionUseCase. + * @member {Array.} searchSolutionUseCase + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Control.prototype.searchSolutionUseCase = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Control control. + * @member {"rule"|undefined} control + * @memberof google.cloud.retail.v2.Control + * @instance + */ + Object.defineProperty(Control.prototype, "control", { + get: $util.oneOfGetter($oneOfFields = ["rule"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Control instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.Control + * @static + * @param {google.cloud.retail.v2.IControl=} [properties] Properties to set + * @returns {google.cloud.retail.v2.Control} Control instance + */ + Control.create = function create(properties) { + return new Control(properties); + }; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2.Control.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.Control + * @static + * @param {google.cloud.retail.v2.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.rule != null && Object.hasOwnProperty.call(message, "rule")) + $root.google.cloud.retail.v2.Rule.encode(message.rule, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.associatedServingConfigIds != null && message.associatedServingConfigIds.length) + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.associatedServingConfigIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 6, wireType 2 =*/50).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + if (message.searchSolutionUseCase != null && message.searchSolutionUseCase.length) { + writer.uint32(/* id 7, wireType 2 =*/58).fork(); + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + writer.int32(message.searchSolutionUseCase[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2.Control.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.Control + * @static + * @param {google.cloud.retail.v2.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Control message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.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.cloud.retail.v2.Control(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: { + message.rule = $root.google.cloud.retail.v2.Rule.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 5: { + if (!(message.associatedServingConfigIds && message.associatedServingConfigIds.length)) + message.associatedServingConfigIds = []; + message.associatedServingConfigIds.push(reader.string()); + break; + } + case 6: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + case 7: { + if (!(message.searchSolutionUseCase && message.searchSolutionUseCase.length)) + message.searchSolutionUseCase = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.searchSolutionUseCase.push(reader.int32()); + } else + message.searchSolutionUseCase.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Control message. + * @function verify + * @memberof google.cloud.retail.v2.Control + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Control.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.rule != null && message.hasOwnProperty("rule")) { + properties.control = 1; + { + var error = $root.google.cloud.retail.v2.Rule.verify(message.rule); + if (error) + return "rule." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.associatedServingConfigIds != null && message.hasOwnProperty("associatedServingConfigIds")) { + if (!Array.isArray(message.associatedServingConfigIds)) + return "associatedServingConfigIds: array expected"; + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + if (!$util.isString(message.associatedServingConfigIds[i])) + return "associatedServingConfigIds: string[] expected"; + } + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + if (message.searchSolutionUseCase != null && message.hasOwnProperty("searchSolutionUseCase")) { + if (!Array.isArray(message.searchSolutionUseCase)) + return "searchSolutionUseCase: array expected"; + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + switch (message.searchSolutionUseCase[i]) { + default: + return "searchSolutionUseCase: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a Control message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.Control + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.Control} Control + */ + Control.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.Control) + return object; + var message = new $root.google.cloud.retail.v2.Control(); + if (object.rule != null) { + if (typeof object.rule !== "object") + throw TypeError(".google.cloud.retail.v2.Control.rule: object expected"); + message.rule = $root.google.cloud.retail.v2.Rule.fromObject(object.rule); + } + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.associatedServingConfigIds) { + if (!Array.isArray(object.associatedServingConfigIds)) + throw TypeError(".google.cloud.retail.v2.Control.associatedServingConfigIds: array expected"); + message.associatedServingConfigIds = []; + for (var i = 0; i < object.associatedServingConfigIds.length; ++i) + message.associatedServingConfigIds[i] = String(object.associatedServingConfigIds[i]); + } + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2.Control.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + if (object.searchSolutionUseCase) { + if (!Array.isArray(object.searchSolutionUseCase)) + throw TypeError(".google.cloud.retail.v2.Control.searchSolutionUseCase: array expected"); + message.searchSolutionUseCase = []; + for (var i = 0; i < object.searchSolutionUseCase.length; ++i) + switch (object.searchSolutionUseCase[i]) { + default: + if (typeof object.searchSolutionUseCase[i] === "number") { + message.searchSolutionUseCase[i] = object.searchSolutionUseCase[i]; + break; + } + case "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": + case 0: + message.searchSolutionUseCase[i] = 0; + break; + case "SEARCH_SOLUTION_USE_CASE_SEARCH": + case 1: + message.searchSolutionUseCase[i] = 1; + break; + case "SEARCH_SOLUTION_USE_CASE_BROWSE": + case 2: + message.searchSolutionUseCase[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.Control + * @static + * @param {google.cloud.retail.v2.Control} message Control + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Control.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.associatedServingConfigIds = []; + object.solutionTypes = []; + object.searchSolutionUseCase = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.rule != null && message.hasOwnProperty("rule")) { + object.rule = $root.google.cloud.retail.v2.Rule.toObject(message.rule, options); + if (options.oneofs) + object.control = "rule"; + } + if (message.associatedServingConfigIds && message.associatedServingConfigIds.length) { + object.associatedServingConfigIds = []; + for (var j = 0; j < message.associatedServingConfigIds.length; ++j) + object.associatedServingConfigIds[j] = message.associatedServingConfigIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + if (message.searchSolutionUseCase && message.searchSolutionUseCase.length) { + object.searchSolutionUseCase = []; + for (var j = 0; j < message.searchSolutionUseCase.length; ++j) + object.searchSolutionUseCase[j] = options.enums === String ? $root.google.cloud.retail.v2.SearchSolutionUseCase[message.searchSolutionUseCase[j]] === undefined ? message.searchSolutionUseCase[j] : $root.google.cloud.retail.v2.SearchSolutionUseCase[message.searchSolutionUseCase[j]] : message.searchSolutionUseCase[j]; + } + return object; + }; + + /** + * Converts this Control to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.Control + * @instance + * @returns {Object.} JSON object + */ + Control.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Control + * @function getTypeUrl + * @memberof google.cloud.retail.v2.Control + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Control.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.Control"; + }; + + return Control; + })(); + + v2.ControlService = (function() { + + /** + * Constructs a new ControlService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ControlService + * @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 ControlService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ControlService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ControlService; + + /** + * Creates new ControlService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.ControlService + * @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 {ControlService} RPC service. Useful where requests and/or responses are streamed. + */ + ControlService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|createControl}. + * @memberof google.cloud.retail.v2.ControlService + * @typedef CreateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Control} [response] Control + */ + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.ICreateControlRequest} request CreateControlRequest message or plain object + * @param {google.cloud.retail.v2.ControlService.CreateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.createControl = function createControl(request, callback) { + return this.rpcCall(createControl, $root.google.cloud.retail.v2.CreateControlRequest, $root.google.cloud.retail.v2.Control, request, callback); + }, "name", { value: "CreateControl" }); + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.ICreateControlRequest} request CreateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|deleteControl}. + * @memberof google.cloud.retail.v2.ControlService + * @typedef DeleteControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @param {google.cloud.retail.v2.ControlService.DeleteControlCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.deleteControl = function deleteControl(request, callback) { + return this.rpcCall(deleteControl, $root.google.cloud.retail.v2.DeleteControlRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteControl" }); + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|updateControl}. + * @memberof google.cloud.retail.v2.ControlService + * @typedef UpdateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Control} [response] Control + */ + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @param {google.cloud.retail.v2.ControlService.UpdateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.updateControl = function updateControl(request, callback) { + return this.rpcCall(updateControl, $root.google.cloud.retail.v2.UpdateControlRequest, $root.google.cloud.retail.v2.Control, request, callback); + }, "name", { value: "UpdateControl" }); + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|getControl}. + * @memberof google.cloud.retail.v2.ControlService + * @typedef GetControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Control} [response] Control + */ + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IGetControlRequest} request GetControlRequest message or plain object + * @param {google.cloud.retail.v2.ControlService.GetControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.getControl = function getControl(request, callback) { + return this.rpcCall(getControl, $root.google.cloud.retail.v2.GetControlRequest, $root.google.cloud.retail.v2.Control, request, callback); + }, "name", { value: "GetControl" }); + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IGetControlRequest} request GetControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ControlService|listControls}. + * @memberof google.cloud.retail.v2.ControlService + * @typedef ListControlsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ListControlsResponse} [response] ListControlsResponse + */ + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IListControlsRequest} request ListControlsRequest message or plain object + * @param {google.cloud.retail.v2.ControlService.ListControlsCallback} callback Node-style callback called with the error, if any, and ListControlsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.listControls = function listControls(request, callback) { + return this.rpcCall(listControls, $root.google.cloud.retail.v2.ListControlsRequest, $root.google.cloud.retail.v2.ListControlsResponse, request, callback); + }, "name", { value: "ListControls" }); + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2.ControlService + * @instance + * @param {google.cloud.retail.v2.IListControlsRequest} request ListControlsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ControlService; + })(); + + v2.CreateControlRequest = (function() { + + /** + * Properties of a CreateControlRequest. + * @memberof google.cloud.retail.v2 + * @interface ICreateControlRequest + * @property {string|null} [parent] CreateControlRequest parent + * @property {google.cloud.retail.v2.IControl|null} [control] CreateControlRequest control + * @property {string|null} [controlId] CreateControlRequest controlId + */ + + /** + * Constructs a new CreateControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CreateControlRequest. + * @implements ICreateControlRequest + * @constructor + * @param {google.cloud.retail.v2.ICreateControlRequest=} [properties] Properties to set + */ + function CreateControlRequest(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]]; + } + + /** + * CreateControlRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.parent = ""; + + /** + * CreateControlRequest control. + * @member {google.cloud.retail.v2.IControl|null|undefined} control + * @memberof google.cloud.retail.v2.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.control = null; + + /** + * CreateControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.controlId = ""; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {google.cloud.retail.v2.ICreateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CreateControlRequest} CreateControlRequest instance + */ + CreateControlRequest.create = function create(properties) { + return new CreateControlRequest(properties); + }; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {google.cloud.retail.v2.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2.Control.encode(message.control, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {google.cloud.retail.v2.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.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.cloud.retail.v2.CreateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.control = $root.google.cloud.retail.v2.Control.decode(reader, reader.uint32()); + break; + } + case 3: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CreateControlRequest} CreateControlRequest + */ + CreateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CreateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.CreateControlRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2.CreateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2.Control.fromObject(object.control); + } + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {google.cloud.retail.v2.CreateControlRequest} message CreateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.control = null; + object.controlId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2.Control.toObject(message.control, options); + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this CreateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CreateControlRequest + * @instance + * @returns {Object.} JSON object + */ + CreateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CreateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CreateControlRequest"; + }; + + return CreateControlRequest; + })(); + + v2.UpdateControlRequest = (function() { + + /** + * Properties of an UpdateControlRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateControlRequest + * @property {google.cloud.retail.v2.IControl|null} [control] UpdateControlRequest control + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateControlRequest updateMask + */ + + /** + * Constructs a new UpdateControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateControlRequest. + * @implements IUpdateControlRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateControlRequest=} [properties] Properties to set + */ + function UpdateControlRequest(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]]; + } + + /** + * UpdateControlRequest control. + * @member {google.cloud.retail.v2.IControl|null|undefined} control + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.control = null; + + /** + * UpdateControlRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2.IUpdateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateControlRequest} UpdateControlRequest instance + */ + UpdateControlRequest.create = function create(properties) { + return new UpdateControlRequest(properties); + }; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2.Control.encode(message.control, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.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.cloud.retail.v2.UpdateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.control = $root.google.cloud.retail.v2.Control.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateControlRequest} UpdateControlRequest + */ + UpdateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateControlRequest(); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2.Control.fromObject(object.control); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateControlRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2.UpdateControlRequest} message UpdateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.control = null; + object.updateMask = null; + } + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2.Control.toObject(message.control, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateControlRequest"; + }; + + return UpdateControlRequest; + })(); + + v2.DeleteControlRequest = (function() { + + /** + * Properties of a DeleteControlRequest. + * @memberof google.cloud.retail.v2 + * @interface IDeleteControlRequest + * @property {string|null} [name] DeleteControlRequest name + */ + + /** + * Constructs a new DeleteControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a DeleteControlRequest. + * @implements IDeleteControlRequest + * @constructor + * @param {google.cloud.retail.v2.IDeleteControlRequest=} [properties] Properties to set + */ + function DeleteControlRequest(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]]; + } + + /** + * DeleteControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @instance + */ + DeleteControlRequest.prototype.name = ""; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2.IDeleteControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.DeleteControlRequest} DeleteControlRequest instance + */ + DeleteControlRequest.create = function create(properties) { + return new DeleteControlRequest(properties); + }; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.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 DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.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.cloud.retail.v2.DeleteControlRequest(); + 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 DeleteControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteControlRequest.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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.DeleteControlRequest} DeleteControlRequest + */ + DeleteControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.DeleteControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.DeleteControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2.DeleteControlRequest} message DeleteControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteControlRequest.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 DeleteControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.DeleteControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.DeleteControlRequest"; + }; + + return DeleteControlRequest; + })(); + + v2.GetControlRequest = (function() { + + /** + * Properties of a GetControlRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetControlRequest + * @property {string|null} [name] GetControlRequest name + */ + + /** + * Constructs a new GetControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetControlRequest. + * @implements IGetControlRequest + * @constructor + * @param {google.cloud.retail.v2.IGetControlRequest=} [properties] Properties to set + */ + function GetControlRequest(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]]; + } + + /** + * GetControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.GetControlRequest + * @instance + */ + GetControlRequest.prototype.name = ""; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {google.cloud.retail.v2.IGetControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetControlRequest} GetControlRequest instance + */ + GetControlRequest.create = function create(properties) { + return new GetControlRequest(properties); + }; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2.GetControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {google.cloud.retail.v2.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.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 GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {google.cloud.retail.v2.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.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.cloud.retail.v2.GetControlRequest(); + 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 GetControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetControlRequest.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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetControlRequest} GetControlRequest + */ + GetControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {google.cloud.retail.v2.GetControlRequest} message GetControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetControlRequest.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 GetControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetControlRequest + * @instance + * @returns {Object.} JSON object + */ + GetControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetControlRequest"; + }; + + return GetControlRequest; + })(); + + v2.ListControlsRequest = (function() { + + /** + * Properties of a ListControlsRequest. + * @memberof google.cloud.retail.v2 + * @interface IListControlsRequest + * @property {string|null} [parent] ListControlsRequest parent + * @property {number|null} [pageSize] ListControlsRequest pageSize + * @property {string|null} [pageToken] ListControlsRequest pageToken + * @property {string|null} [filter] ListControlsRequest filter + */ + + /** + * Constructs a new ListControlsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListControlsRequest. + * @implements IListControlsRequest + * @constructor + * @param {google.cloud.retail.v2.IListControlsRequest=} [properties] Properties to set + */ + function ListControlsRequest(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]]; + } + + /** + * ListControlsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.parent = ""; + + /** + * ListControlsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageSize = 0; + + /** + * ListControlsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageToken = ""; + + /** + * ListControlsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.filter = ""; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {google.cloud.retail.v2.IListControlsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListControlsRequest} ListControlsRequest instance + */ + ListControlsRequest.create = function create(properties) { + return new ListControlsRequest(properties); + }; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListControlsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {google.cloud.retail.v2.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + return writer; + }; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListControlsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {google.cloud.retail.v2.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.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.cloud.retail.v2.ListControlsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListControlsRequest} ListControlsRequest + */ + ListControlsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListControlsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ListControlsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {google.cloud.retail.v2.ListControlsRequest} message ListControlsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this ListControlsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListControlsRequest + * @instance + * @returns {Object.} JSON object + */ + ListControlsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListControlsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListControlsRequest"; + }; + + return ListControlsRequest; + })(); + + v2.ListControlsResponse = (function() { + + /** + * Properties of a ListControlsResponse. + * @memberof google.cloud.retail.v2 + * @interface IListControlsResponse + * @property {Array.|null} [controls] ListControlsResponse controls + * @property {string|null} [nextPageToken] ListControlsResponse nextPageToken + */ + + /** + * Constructs a new ListControlsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListControlsResponse. + * @implements IListControlsResponse + * @constructor + * @param {google.cloud.retail.v2.IListControlsResponse=} [properties] Properties to set + */ + function ListControlsResponse(properties) { + this.controls = []; + 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]]; + } + + /** + * ListControlsResponse controls. + * @member {Array.} controls + * @memberof google.cloud.retail.v2.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.controls = $util.emptyArray; + + /** + * ListControlsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {google.cloud.retail.v2.IListControlsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListControlsResponse} ListControlsResponse instance + */ + ListControlsResponse.create = function create(properties) { + return new ListControlsResponse(properties); + }; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListControlsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {google.cloud.retail.v2.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.controls != null && message.controls.length) + for (var i = 0; i < message.controls.length; ++i) + $root.google.cloud.retail.v2.Control.encode(message.controls[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 ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListControlsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {google.cloud.retail.v2.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.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.cloud.retail.v2.ListControlsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.controls && message.controls.length)) + message.controls = []; + message.controls.push($root.google.cloud.retail.v2.Control.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.controls != null && message.hasOwnProperty("controls")) { + if (!Array.isArray(message.controls)) + return "controls: array expected"; + for (var i = 0; i < message.controls.length; ++i) { + var error = $root.google.cloud.retail.v2.Control.verify(message.controls[i]); + if (error) + return "controls." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListControlsResponse} ListControlsResponse + */ + ListControlsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListControlsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ListControlsResponse(); + if (object.controls) { + if (!Array.isArray(object.controls)) + throw TypeError(".google.cloud.retail.v2.ListControlsResponse.controls: array expected"); + message.controls = []; + for (var i = 0; i < object.controls.length; ++i) { + if (typeof object.controls[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ListControlsResponse.controls: object expected"); + message.controls[i] = $root.google.cloud.retail.v2.Control.fromObject(object.controls[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {google.cloud.retail.v2.ListControlsResponse} message ListControlsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.controls = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.controls && message.controls.length) { + object.controls = []; + for (var j = 0; j < message.controls.length; ++j) + object.controls[j] = $root.google.cloud.retail.v2.Control.toObject(message.controls[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListControlsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListControlsResponse + * @instance + * @returns {Object.} JSON object + */ + ListControlsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListControlsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListControlsResponse"; + }; + + return ListControlsResponse; + })(); + + v2.PredictionService = (function() { + + /** + * Constructs a new PredictionService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PredictionService + * @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 PredictionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (PredictionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = PredictionService; + + /** + * Creates new PredictionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.PredictionService + * @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 {PredictionService} RPC service. Useful where requests and/or responses are streamed. + */ + PredictionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.PredictionService|predict}. + * @memberof google.cloud.retail.v2.PredictionService + * @typedef PredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.PredictResponse} [response] PredictResponse + */ + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2.PredictionService + * @instance + * @param {google.cloud.retail.v2.IPredictRequest} request PredictRequest message or plain object + * @param {google.cloud.retail.v2.PredictionService.PredictCallback} callback Node-style callback called with the error, if any, and PredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.predict = function predict(request, callback) { + return this.rpcCall(predict, $root.google.cloud.retail.v2.PredictRequest, $root.google.cloud.retail.v2.PredictResponse, request, callback); + }, "name", { value: "Predict" }); + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2.PredictionService + * @instance + * @param {google.cloud.retail.v2.IPredictRequest} request PredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return PredictionService; + })(); + + v2.PredictRequest = (function() { + + /** + * Properties of a PredictRequest. + * @memberof google.cloud.retail.v2 + * @interface IPredictRequest + * @property {string|null} [placement] PredictRequest placement + * @property {google.cloud.retail.v2.IUserEvent|null} [userEvent] PredictRequest userEvent + * @property {number|null} [pageSize] PredictRequest pageSize + * @property {string|null} [pageToken] PredictRequest pageToken + * @property {string|null} [filter] PredictRequest filter + * @property {boolean|null} [validateOnly] PredictRequest validateOnly + * @property {Object.|null} [params] PredictRequest params + * @property {Object.|null} [labels] PredictRequest labels + */ + + /** + * Constructs a new PredictRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PredictRequest. + * @implements IPredictRequest + * @constructor + * @param {google.cloud.retail.v2.IPredictRequest=} [properties] Properties to set + */ + function PredictRequest(properties) { + this.params = {}; + 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]]; + } + + /** + * PredictRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.placement = ""; + + /** + * PredictRequest userEvent. + * @member {google.cloud.retail.v2.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.userEvent = null; + + /** + * PredictRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.pageSize = 0; + + /** + * PredictRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.pageToken = ""; + + /** + * PredictRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.filter = ""; + + /** + * PredictRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.validateOnly = false; + + /** + * PredictRequest params. + * @member {Object.} params + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.params = $util.emptyObject; + + /** + * PredictRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + */ + PredictRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {google.cloud.retail.v2.IPredictRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PredictRequest} PredictRequest instance + */ + PredictRequest.create = function create(properties) { + return new PredictRequest(properties); + }; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2.PredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {google.cloud.retail.v2.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.filter); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.validateOnly); + if (message.params != null && Object.hasOwnProperty.call(message, "params")) + for (var keys = Object.keys(message.params), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.Value.encode(message.params[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + 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 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {google.cloud.retail.v2.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.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.cloud.retail.v2.PredictRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2.UserEvent.decode(reader, reader.uint32()); + break; + } + case 3: { + message.pageSize = reader.int32(); + break; + } + case 4: { + message.pageToken = reader.string(); + break; + } + case 5: { + message.filter = reader.string(); + break; + } + case 6: { + message.validateOnly = reader.bool(); + break; + } + case 7: { + if (message.params === $util.emptyObject) + message.params = {}; + 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.params[key] = value; + break; + } + case 8: { + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictRequest message. + * @function verify + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.params != null && message.hasOwnProperty("params")) { + if (!$util.isObject(message.params)) + return "params: object expected"; + var key = Object.keys(message.params); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.params[key[i]]); + if (error) + return "params." + error; + } + } + 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"; + } + return null; + }; + + /** + * Creates a PredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PredictRequest} PredictRequest + */ + PredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PredictRequest) + return object; + var message = new $root.google.cloud.retail.v2.PredictRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2.PredictRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2.UserEvent.fromObject(object.userEvent); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.params) { + if (typeof object.params !== "object") + throw TypeError(".google.cloud.retail.v2.PredictRequest.params: object expected"); + message.params = {}; + for (var keys = Object.keys(object.params), i = 0; i < keys.length; ++i) { + if (typeof object.params[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.PredictRequest.params: object expected"); + message.params[keys[i]] = $root.google.protobuf.Value.fromObject(object.params[keys[i]]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2.PredictRequest.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]]); + } + return message; + }; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {google.cloud.retail.v2.PredictRequest} message PredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.params = {}; + object.labels = {}; + } + if (options.defaults) { + object.placement = ""; + object.userEvent = null; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.validateOnly = false; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2.UserEvent.toObject(message.userEvent, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + var keys2; + if (message.params && (keys2 = Object.keys(message.params)).length) { + object.params = {}; + for (var j = 0; j < keys2.length; ++j) + object.params[keys2[j]] = $root.google.protobuf.Value.toObject(message.params[keys2[j]], options); + } + 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]]; + } + return object; + }; + + /** + * Converts this PredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PredictRequest + * @instance + * @returns {Object.} JSON object + */ + PredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PredictRequest"; + }; + + return PredictRequest; + })(); + + v2.PredictResponse = (function() { + + /** + * Properties of a PredictResponse. + * @memberof google.cloud.retail.v2 + * @interface IPredictResponse + * @property {Array.|null} [results] PredictResponse results + * @property {string|null} [attributionToken] PredictResponse attributionToken + * @property {Array.|null} [missingIds] PredictResponse missingIds + * @property {boolean|null} [validateOnly] PredictResponse validateOnly + */ + + /** + * Constructs a new PredictResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PredictResponse. + * @implements IPredictResponse + * @constructor + * @param {google.cloud.retail.v2.IPredictResponse=} [properties] Properties to set + */ + function PredictResponse(properties) { + this.results = []; + this.missingIds = []; + 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]]; + } + + /** + * PredictResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2.PredictResponse + * @instance + */ + PredictResponse.prototype.results = $util.emptyArray; + + /** + * PredictResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2.PredictResponse + * @instance + */ + PredictResponse.prototype.attributionToken = ""; + + /** + * PredictResponse missingIds. + * @member {Array.} missingIds + * @memberof google.cloud.retail.v2.PredictResponse + * @instance + */ + PredictResponse.prototype.missingIds = $util.emptyArray; + + /** + * PredictResponse validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2.PredictResponse + * @instance + */ + PredictResponse.prototype.validateOnly = false; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {google.cloud.retail.v2.IPredictResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PredictResponse} PredictResponse instance + */ + PredictResponse.create = function create(properties) { + return new PredictResponse(properties); + }; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {google.cloud.retail.v2.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2.PredictResponse.PredictionResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.missingIds != null && message.missingIds.length) + for (var i = 0; i < message.missingIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.missingIds[i]); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {google.cloud.retail.v2.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.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.cloud.retail.v2.PredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2.PredictResponse.PredictionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.missingIds && message.missingIds.length)) + message.missingIds = []; + message.missingIds.push(reader.string()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictResponse message. + * @function verify + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2.PredictResponse.PredictionResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.missingIds != null && message.hasOwnProperty("missingIds")) { + if (!Array.isArray(message.missingIds)) + return "missingIds: array expected"; + for (var i = 0; i < message.missingIds.length; ++i) + if (!$util.isString(message.missingIds[i])) + return "missingIds: string[] expected"; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a PredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PredictResponse} PredictResponse + */ + PredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PredictResponse) + return object; + var message = new $root.google.cloud.retail.v2.PredictResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2.PredictResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2.PredictResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2.PredictResponse.PredictionResult.fromObject(object.results[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.missingIds) { + if (!Array.isArray(object.missingIds)) + throw TypeError(".google.cloud.retail.v2.PredictResponse.missingIds: array expected"); + message.missingIds = []; + for (var i = 0; i < object.missingIds.length; ++i) + message.missingIds[i] = String(object.missingIds[i]); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {google.cloud.retail.v2.PredictResponse} message PredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.missingIds = []; + } + if (options.defaults) { + object.attributionToken = ""; + object.validateOnly = false; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2.PredictResponse.PredictionResult.toObject(message.results[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.missingIds && message.missingIds.length) { + object.missingIds = []; + for (var j = 0; j < message.missingIds.length; ++j) + object.missingIds[j] = message.missingIds[j]; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this PredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PredictResponse + * @instance + * @returns {Object.} JSON object + */ + PredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PredictResponse"; + }; + + PredictResponse.PredictionResult = (function() { + + /** + * Properties of a PredictionResult. + * @memberof google.cloud.retail.v2.PredictResponse + * @interface IPredictionResult + * @property {string|null} [id] PredictionResult id + * @property {Object.|null} [metadata] PredictionResult metadata + */ + + /** + * Constructs a new PredictionResult. + * @memberof google.cloud.retail.v2.PredictResponse + * @classdesc Represents a PredictionResult. + * @implements IPredictionResult + * @constructor + * @param {google.cloud.retail.v2.PredictResponse.IPredictionResult=} [properties] Properties to set + */ + function PredictionResult(properties) { + this.metadata = {}; + 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]]; + } + + /** + * PredictionResult id. + * @member {string} id + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.id = ""; + + /** + * PredictionResult metadata. + * @member {Object.} metadata + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.metadata = $util.emptyObject; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2.PredictResponse.IPredictionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PredictResponse.PredictionResult} PredictionResult instance + */ + PredictionResult.create = function create(properties) { + return new PredictionResult(properties); + }; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.PredictionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + for (var keys = Object.keys(message.metadata), 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.protobuf.Value.encode(message.metadata[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PredictResponse.PredictionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.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.cloud.retail.v2.PredictResponse.PredictionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + if (message.metadata === $util.emptyObject) + message.metadata = {}; + 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.metadata[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictionResult message. + * @function verify + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.metadata != null && message.hasOwnProperty("metadata")) { + if (!$util.isObject(message.metadata)) + return "metadata: object expected"; + var key = Object.keys(message.metadata); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.metadata[key[i]]); + if (error) + return "metadata." + error; + } + } + return null; + }; + + /** + * Creates a PredictionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PredictResponse.PredictionResult} PredictionResult + */ + PredictionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PredictResponse.PredictionResult) + return object; + var message = new $root.google.cloud.retail.v2.PredictResponse.PredictionResult(); + if (object.id != null) + message.id = String(object.id); + if (object.metadata) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.retail.v2.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata = {}; + for (var keys = Object.keys(object.metadata), i = 0; i < keys.length; ++i) { + if (typeof object.metadata[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata[keys[i]] = $root.google.protobuf.Value.fromObject(object.metadata[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2.PredictResponse.PredictionResult} message PredictionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.metadata = {}; + if (options.defaults) + object.id = ""; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + var keys2; + if (message.metadata && (keys2 = Object.keys(message.metadata)).length) { + object.metadata = {}; + for (var j = 0; j < keys2.length; ++j) + object.metadata[keys2[j]] = $root.google.protobuf.Value.toObject(message.metadata[keys2[j]], options); + } + return object; + }; + + /** + * Converts this PredictionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @instance + * @returns {Object.} JSON object + */ + PredictionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PredictResponse.PredictionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PredictResponse.PredictionResult"; + }; + + return PredictionResult; + })(); + + return PredictResponse; + })(); + + v2.ProductService = (function() { + + /** + * Constructs a new ProductService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ProductService + * @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 ProductService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ProductService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ProductService; + + /** + * Creates new ProductService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.ProductService + * @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 {ProductService} RPC service. Useful where requests and/or responses are streamed. + */ + ProductService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|createProduct}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef CreateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Product} [response] Product + */ + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.ICreateProductRequest} request CreateProductRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.CreateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.createProduct = function createProduct(request, callback) { + return this.rpcCall(createProduct, $root.google.cloud.retail.v2.CreateProductRequest, $root.google.cloud.retail.v2.Product, request, callback); + }, "name", { value: "CreateProduct" }); + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.ICreateProductRequest} request CreateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|getProduct}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef GetProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Product} [response] Product + */ + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IGetProductRequest} request GetProductRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.GetProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.getProduct = function getProduct(request, callback) { + return this.rpcCall(getProduct, $root.google.cloud.retail.v2.GetProductRequest, $root.google.cloud.retail.v2.Product, request, callback); + }, "name", { value: "GetProduct" }); + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IGetProductRequest} request GetProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|listProducts}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef ListProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ListProductsResponse} [response] ListProductsResponse + */ + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IListProductsRequest} request ListProductsRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.ListProductsCallback} callback Node-style callback called with the error, if any, and ListProductsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.listProducts = function listProducts(request, callback) { + return this.rpcCall(listProducts, $root.google.cloud.retail.v2.ListProductsRequest, $root.google.cloud.retail.v2.ListProductsResponse, request, callback); + }, "name", { value: "ListProducts" }); + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IListProductsRequest} request ListProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|updateProduct}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef UpdateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.Product} [response] Product + */ + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.UpdateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.updateProduct = function updateProduct(request, callback) { + return this.rpcCall(updateProduct, $root.google.cloud.retail.v2.UpdateProductRequest, $root.google.cloud.retail.v2.Product, request, callback); + }, "name", { value: "UpdateProduct" }); + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|deleteProduct}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef DeleteProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.DeleteProductCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.deleteProduct = function deleteProduct(request, callback) { + return this.rpcCall(deleteProduct, $root.google.cloud.retail.v2.DeleteProductRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteProduct" }); + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|importProducts}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef ImportProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IImportProductsRequest} request ImportProductsRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.ImportProductsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.importProducts = function importProducts(request, callback) { + return this.rpcCall(importProducts, $root.google.cloud.retail.v2.ImportProductsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportProducts" }); + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IImportProductsRequest} request ImportProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|setInventory}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef SetInventoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.SetInventoryCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.setInventory = function setInventory(request, callback) { + return this.rpcCall(setInventory, $root.google.cloud.retail.v2.SetInventoryRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "SetInventory" }); + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|addFulfillmentPlaces}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef AddFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.AddFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addFulfillmentPlaces = function addFulfillmentPlaces(request, callback) { + return this.rpcCall(addFulfillmentPlaces, $root.google.cloud.retail.v2.AddFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddFulfillmentPlaces" }); + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|removeFulfillmentPlaces}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef RemoveFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.RemoveFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeFulfillmentPlaces = function removeFulfillmentPlaces(request, callback) { + return this.rpcCall(removeFulfillmentPlaces, $root.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveFulfillmentPlaces" }); + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|addLocalInventories}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef AddLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.AddLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addLocalInventories = function addLocalInventories(request, callback) { + return this.rpcCall(addLocalInventories, $root.google.cloud.retail.v2.AddLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddLocalInventories" }); + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ProductService|removeLocalInventories}. + * @memberof google.cloud.retail.v2.ProductService + * @typedef RemoveLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2.ProductService.RemoveLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeLocalInventories = function removeLocalInventories(request, callback) { + return this.rpcCall(removeLocalInventories, $root.google.cloud.retail.v2.RemoveLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveLocalInventories" }); + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2.ProductService + * @instance + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ProductService; + })(); + + v2.CreateProductRequest = (function() { + + /** + * Properties of a CreateProductRequest. + * @memberof google.cloud.retail.v2 + * @interface ICreateProductRequest + * @property {string|null} [parent] CreateProductRequest parent + * @property {google.cloud.retail.v2.IProduct|null} [product] CreateProductRequest product + * @property {string|null} [productId] CreateProductRequest productId + */ + + /** + * Constructs a new CreateProductRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CreateProductRequest. + * @implements ICreateProductRequest + * @constructor + * @param {google.cloud.retail.v2.ICreateProductRequest=} [properties] Properties to set + */ + function CreateProductRequest(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]]; + } + + /** + * CreateProductRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.parent = ""; + + /** + * CreateProductRequest product. + * @member {google.cloud.retail.v2.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.product = null; + + /** + * CreateProductRequest productId. + * @member {string} productId + * @memberof google.cloud.retail.v2.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.productId = ""; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {google.cloud.retail.v2.ICreateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CreateProductRequest} CreateProductRequest instance + */ + CreateProductRequest.create = function create(properties) { + return new CreateProductRequest(properties); + }; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {google.cloud.retail.v2.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.productId != null && Object.hasOwnProperty.call(message, "productId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.productId); + return writer; + }; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {google.cloud.retail.v2.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.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.cloud.retail.v2.CreateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.productId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.productId != null && message.hasOwnProperty("productId")) + if (!$util.isString(message.productId)) + return "productId: string expected"; + return null; + }; + + /** + * Creates a CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CreateProductRequest} CreateProductRequest + */ + CreateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CreateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2.CreateProductRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2.CreateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2.Product.fromObject(object.product); + } + if (object.productId != null) + message.productId = String(object.productId); + return message; + }; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {google.cloud.retail.v2.CreateProductRequest} message CreateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.product = null; + object.productId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2.Product.toObject(message.product, options); + if (message.productId != null && message.hasOwnProperty("productId")) + object.productId = message.productId; + return object; + }; + + /** + * Converts this CreateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CreateProductRequest + * @instance + * @returns {Object.} JSON object + */ + CreateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CreateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CreateProductRequest"; + }; + + return CreateProductRequest; + })(); + + v2.GetProductRequest = (function() { + + /** + * Properties of a GetProductRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetProductRequest + * @property {string|null} [name] GetProductRequest name + */ + + /** + * Constructs a new GetProductRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetProductRequest. + * @implements IGetProductRequest + * @constructor + * @param {google.cloud.retail.v2.IGetProductRequest=} [properties] Properties to set + */ + function GetProductRequest(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]]; + } + + /** + * GetProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.GetProductRequest + * @instance + */ + GetProductRequest.prototype.name = ""; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {google.cloud.retail.v2.IGetProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetProductRequest} GetProductRequest instance + */ + GetProductRequest.create = function create(properties) { + return new GetProductRequest(properties); + }; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2.GetProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {google.cloud.retail.v2.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.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 GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {google.cloud.retail.v2.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.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.cloud.retail.v2.GetProductRequest(); + 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 GetProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetProductRequest.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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetProductRequest} GetProductRequest + */ + GetProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetProductRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {google.cloud.retail.v2.GetProductRequest} message GetProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetProductRequest.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 GetProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetProductRequest + * @instance + * @returns {Object.} JSON object + */ + GetProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetProductRequest"; + }; + + return GetProductRequest; + })(); + + v2.UpdateProductRequest = (function() { + + /** + * Properties of an UpdateProductRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateProductRequest + * @property {google.cloud.retail.v2.IProduct|null} [product] UpdateProductRequest product + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateProductRequest updateMask + * @property {boolean|null} [allowMissing] UpdateProductRequest allowMissing + */ + + /** + * Constructs a new UpdateProductRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateProductRequest. + * @implements IUpdateProductRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateProductRequest=} [properties] Properties to set + */ + function UpdateProductRequest(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]]; + } + + /** + * UpdateProductRequest product. + * @member {google.cloud.retail.v2.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.product = null; + + /** + * UpdateProductRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.updateMask = null; + + /** + * UpdateProductRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.allowMissing = false; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2.IUpdateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateProductRequest} UpdateProductRequest instance + */ + UpdateProductRequest.create = function create(properties) { + return new UpdateProductRequest(properties); + }; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.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.cloud.retail.v2.UpdateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateProductRequest} UpdateProductRequest + */ + UpdateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateProductRequest(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2.Product.fromObject(object.product); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateProductRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2.UpdateProductRequest} message UpdateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.updateMask = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2.Product.toObject(message.product, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this UpdateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateProductRequest"; + }; + + return UpdateProductRequest; + })(); + + v2.DeleteProductRequest = (function() { + + /** + * Properties of a DeleteProductRequest. + * @memberof google.cloud.retail.v2 + * @interface IDeleteProductRequest + * @property {string|null} [name] DeleteProductRequest name + */ + + /** + * Constructs a new DeleteProductRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a DeleteProductRequest. + * @implements IDeleteProductRequest + * @constructor + * @param {google.cloud.retail.v2.IDeleteProductRequest=} [properties] Properties to set + */ + function DeleteProductRequest(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]]; + } + + /** + * DeleteProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @instance + */ + DeleteProductRequest.prototype.name = ""; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2.IDeleteProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.DeleteProductRequest} DeleteProductRequest instance + */ + DeleteProductRequest.create = function create(properties) { + return new DeleteProductRequest(properties); + }; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.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 DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.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.cloud.retail.v2.DeleteProductRequest(); + 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 DeleteProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteProductRequest.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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.DeleteProductRequest} DeleteProductRequest + */ + DeleteProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.DeleteProductRequest) + return object; + var message = new $root.google.cloud.retail.v2.DeleteProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2.DeleteProductRequest} message DeleteProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteProductRequest.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 DeleteProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.DeleteProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.DeleteProductRequest"; + }; + + return DeleteProductRequest; + })(); + + v2.ListProductsRequest = (function() { + + /** + * Properties of a ListProductsRequest. + * @memberof google.cloud.retail.v2 + * @interface IListProductsRequest + * @property {string|null} [parent] ListProductsRequest parent + * @property {number|null} [pageSize] ListProductsRequest pageSize + * @property {string|null} [pageToken] ListProductsRequest pageToken + * @property {string|null} [filter] ListProductsRequest filter + * @property {google.protobuf.IFieldMask|null} [readMask] ListProductsRequest readMask + */ + + /** + * Constructs a new ListProductsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListProductsRequest. + * @implements IListProductsRequest + * @constructor + * @param {google.cloud.retail.v2.IListProductsRequest=} [properties] Properties to set + */ + function ListProductsRequest(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]]; + } + + /** + * ListProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.parent = ""; + + /** + * ListProductsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageSize = 0; + + /** + * ListProductsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageToken = ""; + + /** + * ListProductsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.filter = ""; + + /** + * ListProductsRequest readMask. + * @member {google.protobuf.IFieldMask|null|undefined} readMask + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.readMask = null; + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {google.cloud.retail.v2.IListProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListProductsRequest} ListProductsRequest instance + */ + ListProductsRequest.create = function create(properties) { + return new ListProductsRequest(properties); + }; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {google.cloud.retail.v2.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + if (message.readMask != null && Object.hasOwnProperty.call(message, "readMask")) + $root.google.protobuf.FieldMask.encode(message.readMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {google.cloud.retail.v2.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.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.cloud.retail.v2.ListProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + case 5: { + message.readMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.readMask != null && message.hasOwnProperty("readMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.readMask); + if (error) + return "readMask." + error; + } + return null; + }; + + /** + * Creates a ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListProductsRequest} ListProductsRequest + */ + ListProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ListProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.readMask != null) { + if (typeof object.readMask !== "object") + throw TypeError(".google.cloud.retail.v2.ListProductsRequest.readMask: object expected"); + message.readMask = $root.google.protobuf.FieldMask.fromObject(object.readMask); + } + return message; + }; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {google.cloud.retail.v2.ListProductsRequest} message ListProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.readMask = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.readMask != null && message.hasOwnProperty("readMask")) + object.readMask = $root.google.protobuf.FieldMask.toObject(message.readMask, options); + return object; + }; + + /** + * Converts this ListProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ListProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListProductsRequest"; + }; + + return ListProductsRequest; + })(); + + v2.ListProductsResponse = (function() { + + /** + * Properties of a ListProductsResponse. + * @memberof google.cloud.retail.v2 + * @interface IListProductsResponse + * @property {Array.|null} [products] ListProductsResponse products + * @property {string|null} [nextPageToken] ListProductsResponse nextPageToken + */ + + /** + * Constructs a new ListProductsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListProductsResponse. + * @implements IListProductsResponse + * @constructor + * @param {google.cloud.retail.v2.IListProductsResponse=} [properties] Properties to set + */ + function ListProductsResponse(properties) { + this.products = []; + 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]]; + } + + /** + * ListProductsResponse products. + * @member {Array.} products + * @memberof google.cloud.retail.v2.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.products = $util.emptyArray; + + /** + * ListProductsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {google.cloud.retail.v2.IListProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListProductsResponse} ListProductsResponse instance + */ + ListProductsResponse.create = function create(properties) { + return new ListProductsResponse(properties); + }; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {google.cloud.retail.v2.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2.Product.encode(message.products[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 ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {google.cloud.retail.v2.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.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.cloud.retail.v2.ListProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2.Product.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListProductsResponse} ListProductsResponse + */ + ListProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ListProductsResponse(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2.ListProductsResponse.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ListProductsResponse.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2.Product.fromObject(object.products[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {google.cloud.retail.v2.ListProductsResponse} message ListProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2.Product.toObject(message.products[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ListProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListProductsResponse"; + }; + + return ListProductsResponse; + })(); + + v2.SetInventoryRequest = (function() { + + /** + * Properties of a SetInventoryRequest. + * @memberof google.cloud.retail.v2 + * @interface ISetInventoryRequest + * @property {google.cloud.retail.v2.IProduct|null} [inventory] SetInventoryRequest inventory + * @property {google.protobuf.IFieldMask|null} [setMask] SetInventoryRequest setMask + * @property {google.protobuf.ITimestamp|null} [setTime] SetInventoryRequest setTime + * @property {boolean|null} [allowMissing] SetInventoryRequest allowMissing + */ + + /** + * Constructs a new SetInventoryRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SetInventoryRequest. + * @implements ISetInventoryRequest + * @constructor + * @param {google.cloud.retail.v2.ISetInventoryRequest=} [properties] Properties to set + */ + function SetInventoryRequest(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]]; + } + + /** + * SetInventoryRequest inventory. + * @member {google.cloud.retail.v2.IProduct|null|undefined} inventory + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.inventory = null; + + /** + * SetInventoryRequest setMask. + * @member {google.protobuf.IFieldMask|null|undefined} setMask + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setMask = null; + + /** + * SetInventoryRequest setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setTime = null; + + /** + * SetInventoryRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.allowMissing = false; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2.ISetInventoryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SetInventoryRequest} SetInventoryRequest instance + */ + SetInventoryRequest.create = function create(properties) { + return new SetInventoryRequest(properties); + }; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inventory != null && Object.hasOwnProperty.call(message, "inventory")) + $root.google.cloud.retail.v2.Product.encode(message.inventory, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.setMask != null && Object.hasOwnProperty.call(message, "setMask")) + $root.google.protobuf.FieldMask.encode(message.setMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.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.cloud.retail.v2.SetInventoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inventory = $root.google.cloud.retail.v2.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.setMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryRequest message. + * @function verify + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inventory != null && message.hasOwnProperty("inventory")) { + var error = $root.google.cloud.retail.v2.Product.verify(message.inventory); + if (error) + return "inventory." + error; + } + if (message.setMask != null && message.hasOwnProperty("setMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.setMask); + if (error) + return "setMask." + error; + } + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SetInventoryRequest} SetInventoryRequest + */ + SetInventoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SetInventoryRequest) + return object; + var message = new $root.google.cloud.retail.v2.SetInventoryRequest(); + if (object.inventory != null) { + if (typeof object.inventory !== "object") + throw TypeError(".google.cloud.retail.v2.SetInventoryRequest.inventory: object expected"); + message.inventory = $root.google.cloud.retail.v2.Product.fromObject(object.inventory); + } + if (object.setMask != null) { + if (typeof object.setMask !== "object") + throw TypeError(".google.cloud.retail.v2.SetInventoryRequest.setMask: object expected"); + message.setMask = $root.google.protobuf.FieldMask.fromObject(object.setMask); + } + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2.SetInventoryRequest.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2.SetInventoryRequest} message SetInventoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.inventory = null; + object.setMask = null; + object.setTime = null; + object.allowMissing = false; + } + if (message.inventory != null && message.hasOwnProperty("inventory")) + object.inventory = $root.google.cloud.retail.v2.Product.toObject(message.inventory, options); + if (message.setMask != null && message.hasOwnProperty("setMask")) + object.setMask = $root.google.protobuf.FieldMask.toObject(message.setMask, options); + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this SetInventoryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @instance + * @returns {Object.} JSON object + */ + SetInventoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SetInventoryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SetInventoryRequest"; + }; + + return SetInventoryRequest; + })(); + + v2.SetInventoryMetadata = (function() { + + /** + * Properties of a SetInventoryMetadata. + * @memberof google.cloud.retail.v2 + * @interface ISetInventoryMetadata + */ + + /** + * Constructs a new SetInventoryMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SetInventoryMetadata. + * @implements ISetInventoryMetadata + * @constructor + * @param {google.cloud.retail.v2.ISetInventoryMetadata=} [properties] Properties to set + */ + function SetInventoryMetadata(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 SetInventoryMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2.ISetInventoryMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SetInventoryMetadata} SetInventoryMetadata instance + */ + SetInventoryMetadata.create = function create(properties) { + return new SetInventoryMetadata(properties); + }; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.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.cloud.retail.v2.SetInventoryMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SetInventoryMetadata} SetInventoryMetadata + */ + SetInventoryMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SetInventoryMetadata) + return object; + return new $root.google.cloud.retail.v2.SetInventoryMetadata(); + }; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2.SetInventoryMetadata} message SetInventoryMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @instance + * @returns {Object.} JSON object + */ + SetInventoryMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SetInventoryMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SetInventoryMetadata"; + }; + + return SetInventoryMetadata; + })(); + + v2.SetInventoryResponse = (function() { + + /** + * Properties of a SetInventoryResponse. + * @memberof google.cloud.retail.v2 + * @interface ISetInventoryResponse + */ + + /** + * Constructs a new SetInventoryResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SetInventoryResponse. + * @implements ISetInventoryResponse + * @constructor + * @param {google.cloud.retail.v2.ISetInventoryResponse=} [properties] Properties to set + */ + function SetInventoryResponse(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 SetInventoryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2.ISetInventoryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SetInventoryResponse} SetInventoryResponse instance + */ + SetInventoryResponse.create = function create(properties) { + return new SetInventoryResponse(properties); + }; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2.SetInventoryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SetInventoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.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.cloud.retail.v2.SetInventoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryResponse message. + * @function verify + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SetInventoryResponse} SetInventoryResponse + */ + SetInventoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SetInventoryResponse) + return object; + return new $root.google.cloud.retail.v2.SetInventoryResponse(); + }; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2.SetInventoryResponse} message SetInventoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @instance + * @returns {Object.} JSON object + */ + SetInventoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SetInventoryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SetInventoryResponse"; + }; + + return SetInventoryResponse; + })(); + + v2.AddFulfillmentPlacesRequest = (function() { + + /** + * Properties of an AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2 + * @interface IAddFulfillmentPlacesRequest + * @property {string|null} [product] AddFulfillmentPlacesRequest product + * @property {string|null} [type] AddFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] AddFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [addTime] AddFulfillmentPlacesRequest addTime + * @property {boolean|null} [allowMissing] AddFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddFulfillmentPlacesRequest. + * @implements IAddFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest=} [properties] Properties to set + */ + function AddFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * AddFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.product = ""; + + /** + * AddFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.type = ""; + + /** + * AddFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * AddFulfillmentPlacesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.addTime = null; + + /** + * AddFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest instance + */ + AddFulfillmentPlacesRequest.create = function create(properties) { + return new AddFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.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.cloud.retail.v2.AddFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + */ + AddFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2.AddFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2.AddFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2.AddFulfillmentPlacesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.AddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddFulfillmentPlacesRequest"; + }; + + return AddFulfillmentPlacesRequest; + })(); + + v2.AddFulfillmentPlacesMetadata = (function() { + + /** + * Properties of an AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2 + * @interface IAddFulfillmentPlacesMetadata + */ + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddFulfillmentPlacesMetadata. + * @implements IAddFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function AddFulfillmentPlacesMetadata(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 AddFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata instance + */ + AddFulfillmentPlacesMetadata.create = function create(properties) { + return new AddFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.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.cloud.retail.v2.AddFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + */ + AddFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2.AddFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.AddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddFulfillmentPlacesMetadata"; + }; + + return AddFulfillmentPlacesMetadata; + })(); + + v2.AddFulfillmentPlacesResponse = (function() { + + /** + * Properties of an AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2 + * @interface IAddFulfillmentPlacesResponse + */ + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddFulfillmentPlacesResponse. + * @implements IAddFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesResponse=} [properties] Properties to set + */ + function AddFulfillmentPlacesResponse(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 AddFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse instance + */ + AddFulfillmentPlacesResponse.create = function create(properties) { + return new AddFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.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.cloud.retail.v2.AddFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + */ + AddFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2.AddFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.AddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddFulfillmentPlacesResponse"; + }; + + return AddFulfillmentPlacesResponse; + })(); + + v2.AddLocalInventoriesRequest = (function() { + + /** + * Properties of an AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2 + * @interface IAddLocalInventoriesRequest + * @property {string|null} [product] AddLocalInventoriesRequest product + * @property {Array.|null} [localInventories] AddLocalInventoriesRequest localInventories + * @property {google.protobuf.IFieldMask|null} [addMask] AddLocalInventoriesRequest addMask + * @property {google.protobuf.ITimestamp|null} [addTime] AddLocalInventoriesRequest addTime + * @property {boolean|null} [allowMissing] AddLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddLocalInventoriesRequest. + * @implements IAddLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest=} [properties] Properties to set + */ + function AddLocalInventoriesRequest(properties) { + this.localInventories = []; + 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]]; + } + + /** + * AddLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.product = ""; + + /** + * AddLocalInventoriesRequest localInventories. + * @member {Array.} localInventories + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.localInventories = $util.emptyArray; + + /** + * AddLocalInventoriesRequest addMask. + * @member {google.protobuf.IFieldMask|null|undefined} addMask + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addMask = null; + + /** + * AddLocalInventoriesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addTime = null; + + /** + * AddLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddLocalInventoriesRequest} AddLocalInventoriesRequest instance + */ + AddLocalInventoriesRequest.create = function create(properties) { + return new AddLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.localInventories != null && message.localInventories.length) + for (var i = 0; i < message.localInventories.length; ++i) + $root.google.cloud.retail.v2.LocalInventory.encode(message.localInventories[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.addMask != null && Object.hasOwnProperty.call(message, "addMask")) + $root.google.protobuf.FieldMask.encode(message.addMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.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.cloud.retail.v2.AddLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.localInventories && message.localInventories.length)) + message.localInventories = []; + message.localInventories.push($root.google.cloud.retail.v2.LocalInventory.decode(reader, reader.uint32())); + break; + } + case 4: { + message.addMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.localInventories != null && message.hasOwnProperty("localInventories")) { + if (!Array.isArray(message.localInventories)) + return "localInventories: array expected"; + for (var i = 0; i < message.localInventories.length; ++i) { + var error = $root.google.cloud.retail.v2.LocalInventory.verify(message.localInventories[i]); + if (error) + return "localInventories." + error; + } + } + if (message.addMask != null && message.hasOwnProperty("addMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.addMask); + if (error) + return "addMask." + error; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddLocalInventoriesRequest} AddLocalInventoriesRequest + */ + AddLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2.AddLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.localInventories) { + if (!Array.isArray(object.localInventories)) + throw TypeError(".google.cloud.retail.v2.AddLocalInventoriesRequest.localInventories: array expected"); + message.localInventories = []; + for (var i = 0; i < object.localInventories.length; ++i) { + if (typeof object.localInventories[i] !== "object") + throw TypeError(".google.cloud.retail.v2.AddLocalInventoriesRequest.localInventories: object expected"); + message.localInventories[i] = $root.google.cloud.retail.v2.LocalInventory.fromObject(object.localInventories[i]); + } + } + if (object.addMask != null) { + if (typeof object.addMask !== "object") + throw TypeError(".google.cloud.retail.v2.AddLocalInventoriesRequest.addMask: object expected"); + message.addMask = $root.google.protobuf.FieldMask.fromObject(object.addMask); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2.AddLocalInventoriesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.AddLocalInventoriesRequest} message AddLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.localInventories = []; + if (options.defaults) { + object.product = ""; + object.addMask = null; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.localInventories && message.localInventories.length) { + object.localInventories = []; + for (var j = 0; j < message.localInventories.length; ++j) + object.localInventories[j] = $root.google.cloud.retail.v2.LocalInventory.toObject(message.localInventories[j], options); + } + if (message.addMask != null && message.hasOwnProperty("addMask")) + object.addMask = $root.google.protobuf.FieldMask.toObject(message.addMask, options); + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddLocalInventoriesRequest"; + }; + + return AddLocalInventoriesRequest; + })(); + + v2.AddLocalInventoriesMetadata = (function() { + + /** + * Properties of an AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2 + * @interface IAddLocalInventoriesMetadata + */ + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddLocalInventoriesMetadata. + * @implements IAddLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2.IAddLocalInventoriesMetadata=} [properties] Properties to set + */ + function AddLocalInventoriesMetadata(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 AddLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata instance + */ + AddLocalInventoriesMetadata.create = function create(properties) { + return new AddLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.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.cloud.retail.v2.AddLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + */ + AddLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2.AddLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.AddLocalInventoriesMetadata} message AddLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddLocalInventoriesMetadata"; + }; + + return AddLocalInventoriesMetadata; + })(); + + v2.AddLocalInventoriesResponse = (function() { + + /** + * Properties of an AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2 + * @interface IAddLocalInventoriesResponse + */ + + /** + * Constructs a new AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddLocalInventoriesResponse. + * @implements IAddLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2.IAddLocalInventoriesResponse=} [properties] Properties to set + */ + function AddLocalInventoriesResponse(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 AddLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddLocalInventoriesResponse} AddLocalInventoriesResponse instance + */ + AddLocalInventoriesResponse.create = function create(properties) { + return new AddLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.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.cloud.retail.v2.AddLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddLocalInventoriesResponse} AddLocalInventoriesResponse + */ + AddLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2.AddLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.AddLocalInventoriesResponse} message AddLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddLocalInventoriesResponse"; + }; + + return AddLocalInventoriesResponse; + })(); + + v2.RemoveLocalInventoriesRequest = (function() { + + /** + * Properties of a RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2 + * @interface IRemoveLocalInventoriesRequest + * @property {string|null} [product] RemoveLocalInventoriesRequest product + * @property {Array.|null} [placeIds] RemoveLocalInventoriesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveLocalInventoriesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveLocalInventoriesRequest. + * @implements IRemoveLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest=} [properties] Properties to set + */ + function RemoveLocalInventoriesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.product = ""; + + /** + * RemoveLocalInventoriesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveLocalInventoriesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.removeTime = null; + + /** + * RemoveLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest instance + */ + RemoveLocalInventoriesRequest.create = function create(properties) { + return new RemoveLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.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.cloud.retail.v2.RemoveLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 5: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + */ + RemoveLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2.RemoveLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2.RemoveLocalInventoriesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2.RemoveLocalInventoriesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2.RemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.allowMissing = false; + object.removeTime = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + return object; + }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveLocalInventoriesRequest"; + }; + + return RemoveLocalInventoriesRequest; + })(); + + v2.RemoveLocalInventoriesMetadata = (function() { + + /** + * Properties of a RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2 + * @interface IRemoveLocalInventoriesMetadata + */ + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveLocalInventoriesMetadata. + * @implements IRemoveLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + */ + function RemoveLocalInventoriesMetadata(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 RemoveLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata instance + */ + RemoveLocalInventoriesMetadata.create = function create(properties) { + return new RemoveLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.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.cloud.retail.v2.RemoveLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + */ + RemoveLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2.RemoveLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2.RemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveLocalInventoriesMetadata"; + }; + + return RemoveLocalInventoriesMetadata; + })(); + + v2.RemoveLocalInventoriesResponse = (function() { + + /** + * Properties of a RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2 + * @interface IRemoveLocalInventoriesResponse + */ + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveLocalInventoriesResponse. + * @implements IRemoveLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesResponse=} [properties] Properties to set + */ + function RemoveLocalInventoriesResponse(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 RemoveLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse instance + */ + RemoveLocalInventoriesResponse.create = function create(properties) { + return new RemoveLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.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.cloud.retail.v2.RemoveLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + */ + RemoveLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2.RemoveLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2.RemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveLocalInventoriesResponse"; + }; + + return RemoveLocalInventoriesResponse; + })(); + + v2.RemoveFulfillmentPlacesRequest = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2 + * @interface IRemoveFulfillmentPlacesRequest + * @property {string|null} [product] RemoveFulfillmentPlacesRequest product + * @property {string|null} [type] RemoveFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] RemoveFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveFulfillmentPlacesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveFulfillmentPlacesRequest. + * @implements IRemoveFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.product = ""; + + /** + * RemoveFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.type = ""; + + /** + * RemoveFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveFulfillmentPlacesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.removeTime = null; + + /** + * RemoveFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest instance + */ + RemoveFulfillmentPlacesRequest.create = function create(properties) { + return new RemoveFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.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.cloud.retail.v2.RemoveFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + */ + RemoveFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2.RemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.removeTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveFulfillmentPlacesRequest"; + }; + + return RemoveFulfillmentPlacesRequest; + })(); + + v2.RemoveFulfillmentPlacesMetadata = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2 + * @interface IRemoveFulfillmentPlacesMetadata + */ + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveFulfillmentPlacesMetadata. + * @implements IRemoveFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesMetadata(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 RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata instance + */ + RemoveFulfillmentPlacesMetadata.create = function create(properties) { + return new RemoveFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.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.cloud.retail.v2.RemoveFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + */ + RemoveFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata"; + }; + + return RemoveFulfillmentPlacesMetadata; + })(); + + v2.RemoveFulfillmentPlacesResponse = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2 + * @interface IRemoveFulfillmentPlacesResponse + */ + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveFulfillmentPlacesResponse. + * @implements IRemoveFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesResponse(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 RemoveFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse instance + */ + RemoveFulfillmentPlacesResponse.create = function create(properties) { + return new RemoveFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.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.cloud.retail.v2.RemoveFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + */ + RemoveFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2.RemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveFulfillmentPlacesResponse"; + }; + + return RemoveFulfillmentPlacesResponse; + })(); + + v2.PurgeMetadata = (function() { + + /** + * Properties of a PurgeMetadata. + * @memberof google.cloud.retail.v2 + * @interface IPurgeMetadata + */ + + /** + * Constructs a new PurgeMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PurgeMetadata. + * @implements IPurgeMetadata + * @constructor + * @param {google.cloud.retail.v2.IPurgeMetadata=} [properties] Properties to set + */ + function PurgeMetadata(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 PurgeMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {google.cloud.retail.v2.IPurgeMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PurgeMetadata} PurgeMetadata instance + */ + PurgeMetadata.create = function create(properties) { + return new PurgeMetadata(properties); + }; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2.PurgeMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {google.cloud.retail.v2.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {google.cloud.retail.v2.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.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.cloud.retail.v2.PurgeMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PurgeMetadata} PurgeMetadata + */ + PurgeMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PurgeMetadata) + return object; + return new $root.google.cloud.retail.v2.PurgeMetadata(); + }; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {google.cloud.retail.v2.PurgeMetadata} message PurgeMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this PurgeMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PurgeMetadata + * @instance + * @returns {Object.} JSON object + */ + PurgeMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PurgeMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PurgeMetadata"; + }; + + return PurgeMetadata; + })(); + + v2.PurgeUserEventsRequest = (function() { + + /** + * Properties of a PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @interface IPurgeUserEventsRequest + * @property {string|null} [parent] PurgeUserEventsRequest parent + * @property {string|null} [filter] PurgeUserEventsRequest filter + * @property {boolean|null} [force] PurgeUserEventsRequest force + */ + + /** + * Constructs a new PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PurgeUserEventsRequest. + * @implements IPurgeUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest=} [properties] Properties to set + */ + function PurgeUserEventsRequest(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]]; + } + + /** + * PurgeUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.parent = ""; + + /** + * PurgeUserEventsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.filter = ""; + + /** + * PurgeUserEventsRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.force = false; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PurgeUserEventsRequest} PurgeUserEventsRequest instance + */ + PurgeUserEventsRequest.create = function create(properties) { + return new PurgeUserEventsRequest(properties); + }; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.force); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.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.cloud.retail.v2.PurgeUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.filter = reader.string(); + break; + } + case 3: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PurgeUserEventsRequest} PurgeUserEventsRequest + */ + PurgeUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PurgeUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2.PurgeUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2.PurgeUserEventsRequest} message PurgeUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.force = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PurgeUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PurgeUserEventsRequest"; + }; + + return PurgeUserEventsRequest; + })(); + + v2.PurgeUserEventsResponse = (function() { + + /** + * Properties of a PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @interface IPurgeUserEventsResponse + * @property {number|Long|null} [purgedEventsCount] PurgeUserEventsResponse purgedEventsCount + */ + + /** + * Constructs a new PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a PurgeUserEventsResponse. + * @implements IPurgeUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2.IPurgeUserEventsResponse=} [properties] Properties to set + */ + function PurgeUserEventsResponse(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]]; + } + + /** + * PurgeUserEventsResponse purgedEventsCount. + * @member {number|Long} purgedEventsCount + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @instance + */ + PurgeUserEventsResponse.prototype.purgedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.PurgeUserEventsResponse} PurgeUserEventsResponse instance + */ + PurgeUserEventsResponse.create = function create(properties) { + return new PurgeUserEventsResponse(properties); + }; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.purgedEventsCount != null && Object.hasOwnProperty.call(message, "purgedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.purgedEventsCount); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.PurgeUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.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.cloud.retail.v2.PurgeUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.purgedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (!$util.isInteger(message.purgedEventsCount) && !(message.purgedEventsCount && $util.isInteger(message.purgedEventsCount.low) && $util.isInteger(message.purgedEventsCount.high))) + return "purgedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.PurgeUserEventsResponse} PurgeUserEventsResponse + */ + PurgeUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.PurgeUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2.PurgeUserEventsResponse(); + if (object.purgedEventsCount != null) + if ($util.Long) + (message.purgedEventsCount = $util.Long.fromValue(object.purgedEventsCount)).unsigned = false; + else if (typeof object.purgedEventsCount === "string") + message.purgedEventsCount = parseInt(object.purgedEventsCount, 10); + else if (typeof object.purgedEventsCount === "number") + message.purgedEventsCount = object.purgedEventsCount; + else if (typeof object.purgedEventsCount === "object") + message.purgedEventsCount = new $util.LongBits(object.purgedEventsCount.low >>> 0, object.purgedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2.PurgeUserEventsResponse} message PurgeUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsResponse.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.purgedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.purgedEventsCount = options.longs === String ? "0" : 0; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (typeof message.purgedEventsCount === "number") + object.purgedEventsCount = options.longs === String ? String(message.purgedEventsCount) : message.purgedEventsCount; + else + object.purgedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.purgedEventsCount) : options.longs === Number ? new $util.LongBits(message.purgedEventsCount.low >>> 0, message.purgedEventsCount.high >>> 0).toNumber() : message.purgedEventsCount; + return object; + }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.PurgeUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.PurgeUserEventsResponse"; + }; + + return PurgeUserEventsResponse; + })(); + + v2.SearchService = (function() { + + /** + * Constructs a new SearchService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SearchService + * @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 SearchService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (SearchService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = SearchService; + + /** + * Creates new SearchService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.SearchService + * @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 {SearchService} RPC service. Useful where requests and/or responses are streamed. + */ + SearchService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.SearchService|search}. + * @memberof google.cloud.retail.v2.SearchService + * @typedef SearchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.SearchResponse} [response] SearchResponse + */ + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2.SearchService + * @instance + * @param {google.cloud.retail.v2.ISearchRequest} request SearchRequest message or plain object + * @param {google.cloud.retail.v2.SearchService.SearchCallback} callback Node-style callback called with the error, if any, and SearchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SearchService.prototype.search = function search(request, callback) { + return this.rpcCall(search, $root.google.cloud.retail.v2.SearchRequest, $root.google.cloud.retail.v2.SearchResponse, request, callback); + }, "name", { value: "Search" }); + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2.SearchService + * @instance + * @param {google.cloud.retail.v2.ISearchRequest} request SearchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return SearchService; + })(); + + v2.SearchRequest = (function() { + + /** + * Properties of a SearchRequest. + * @memberof google.cloud.retail.v2 + * @interface ISearchRequest + * @property {string|null} [placement] SearchRequest placement + * @property {string|null} [branch] SearchRequest branch + * @property {string|null} [query] SearchRequest query + * @property {string|null} [visitorId] SearchRequest visitorId + * @property {google.cloud.retail.v2.IUserInfo|null} [userInfo] SearchRequest userInfo + * @property {number|null} [pageSize] SearchRequest pageSize + * @property {string|null} [pageToken] SearchRequest pageToken + * @property {number|null} [offset] SearchRequest offset + * @property {string|null} [filter] SearchRequest filter + * @property {string|null} [canonicalFilter] SearchRequest canonicalFilter + * @property {string|null} [orderBy] SearchRequest orderBy + * @property {Array.|null} [facetSpecs] SearchRequest facetSpecs + * @property {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] SearchRequest dynamicFacetSpec + * @property {google.cloud.retail.v2.SearchRequest.IBoostSpec|null} [boostSpec] SearchRequest boostSpec + * @property {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec|null} [queryExpansionSpec] SearchRequest queryExpansionSpec + * @property {Array.|null} [variantRollupKeys] SearchRequest variantRollupKeys + * @property {Array.|null} [pageCategories] SearchRequest pageCategories + * @property {google.cloud.retail.v2.SearchRequest.SearchMode|null} [searchMode] SearchRequest searchMode + * @property {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] SearchRequest personalizationSpec + * @property {Object.|null} [labels] SearchRequest labels + * @property {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null} [spellCorrectionSpec] SearchRequest spellCorrectionSpec + */ + + /** + * Constructs a new SearchRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SearchRequest. + * @implements ISearchRequest + * @constructor + * @param {google.cloud.retail.v2.ISearchRequest=} [properties] Properties to set + */ + function SearchRequest(properties) { + this.facetSpecs = []; + this.variantRollupKeys = []; + this.pageCategories = []; + 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]]; + } + + /** + * SearchRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.placement = ""; + + /** + * SearchRequest branch. + * @member {string} branch + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.branch = ""; + + /** + * SearchRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.query = ""; + + /** + * SearchRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.visitorId = ""; + + /** + * SearchRequest userInfo. + * @member {google.cloud.retail.v2.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.userInfo = null; + + /** + * SearchRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.pageSize = 0; + + /** + * SearchRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.pageToken = ""; + + /** + * SearchRequest offset. + * @member {number} offset + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.offset = 0; + + /** + * SearchRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.filter = ""; + + /** + * SearchRequest canonicalFilter. + * @member {string} canonicalFilter + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.canonicalFilter = ""; + + /** + * SearchRequest orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.orderBy = ""; + + /** + * SearchRequest facetSpecs. + * @member {Array.} facetSpecs + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.facetSpecs = $util.emptyArray; + + /** + * SearchRequest dynamicFacetSpec. + * @member {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.dynamicFacetSpec = null; + + /** + * SearchRequest boostSpec. + * @member {google.cloud.retail.v2.SearchRequest.IBoostSpec|null|undefined} boostSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.boostSpec = null; + + /** + * SearchRequest queryExpansionSpec. + * @member {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec|null|undefined} queryExpansionSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.queryExpansionSpec = null; + + /** + * SearchRequest variantRollupKeys. + * @member {Array.} variantRollupKeys + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.variantRollupKeys = $util.emptyArray; + + /** + * SearchRequest pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.pageCategories = $util.emptyArray; + + /** + * SearchRequest searchMode. + * @member {google.cloud.retail.v2.SearchRequest.SearchMode} searchMode + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.searchMode = 0; + + /** + * SearchRequest personalizationSpec. + * @member {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null|undefined} personalizationSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.personalizationSpec = null; + + /** + * SearchRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.labels = $util.emptyObject; + + /** + * SearchRequest spellCorrectionSpec. + * @member {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec|null|undefined} spellCorrectionSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + SearchRequest.prototype.spellCorrectionSpec = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * SearchRequest _spellCorrectionSpec. + * @member {"spellCorrectionSpec"|undefined} _spellCorrectionSpec + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + */ + Object.defineProperty(SearchRequest.prototype, "_spellCorrectionSpec", { + get: $util.oneOfGetter($oneOfFields = ["spellCorrectionSpec"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new SearchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {google.cloud.retail.v2.ISearchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest} SearchRequest instance + */ + SearchRequest.create = function create(properties) { + return new SearchRequest(properties); + }; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {google.cloud.retail.v2.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branch); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.query); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.visitorId); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2.UserInfo.encode(message.userInfo, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.pageToken); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.offset); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.orderBy); + if (message.facetSpecs != null && message.facetSpecs.length) + for (var i = 0; i < message.facetSpecs.length; ++i) + $root.google.cloud.retail.v2.SearchRequest.FacetSpec.encode(message.facetSpecs[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.boostSpec != null && Object.hasOwnProperty.call(message, "boostSpec")) + $root.google.cloud.retail.v2.SearchRequest.BoostSpec.encode(message.boostSpec, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + if (message.queryExpansionSpec != null && Object.hasOwnProperty.call(message, "queryExpansionSpec")) + $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.encode(message.queryExpansionSpec, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.variantRollupKeys != null && message.variantRollupKeys.length) + for (var i = 0; i < message.variantRollupKeys.length; ++i) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.variantRollupKeys[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 23, wireType 2 =*/186).string(message.pageCategories[i]); + if (message.canonicalFilter != null && Object.hasOwnProperty.call(message, "canonicalFilter")) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.canonicalFilter); + if (message.searchMode != null && Object.hasOwnProperty.call(message, "searchMode")) + writer.uint32(/* id 31, wireType 0 =*/248).int32(message.searchMode); + if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) + $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 32, wireType 2 =*/258).fork()).ldelim(); + 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 34, wireType 2 =*/274).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.spellCorrectionSpec != null && Object.hasOwnProperty.call(message, "spellCorrectionSpec")) + $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.encode(message.spellCorrectionSpec, writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {google.cloud.retail.v2.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.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.cloud.retail.v2.SearchRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.branch = reader.string(); + break; + } + case 3: { + message.query = reader.string(); + break; + } + case 4: { + message.visitorId = reader.string(); + break; + } + case 5: { + message.userInfo = $root.google.cloud.retail.v2.UserInfo.decode(reader, reader.uint32()); + break; + } + case 7: { + message.pageSize = reader.int32(); + break; + } + case 8: { + message.pageToken = reader.string(); + break; + } + case 9: { + message.offset = reader.int32(); + break; + } + case 10: { + message.filter = reader.string(); + break; + } + case 28: { + message.canonicalFilter = reader.string(); + break; + } + case 11: { + message.orderBy = reader.string(); + break; + } + case 12: { + if (!(message.facetSpecs && message.facetSpecs.length)) + message.facetSpecs = []; + message.facetSpecs.push($root.google.cloud.retail.v2.SearchRequest.FacetSpec.decode(reader, reader.uint32())); + break; + } + case 21: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 13: { + message.boostSpec = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.decode(reader, reader.uint32()); + break; + } + case 14: { + message.queryExpansionSpec = $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.decode(reader, reader.uint32()); + break; + } + case 17: { + if (!(message.variantRollupKeys && message.variantRollupKeys.length)) + message.variantRollupKeys = []; + message.variantRollupKeys.push(reader.string()); + break; + } + case 23: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 31: { + message.searchMode = reader.int32(); + break; + } + case 32: { + message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); + break; + } + case 34: { + 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 35: { + message.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchRequest message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + 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"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + if (!$util.isString(message.canonicalFilter)) + return "canonicalFilter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.facetSpecs != null && message.hasOwnProperty("facetSpecs")) { + if (!Array.isArray(message.facetSpecs)) + return "facetSpecs: array expected"; + for (var i = 0; i < message.facetSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.verify(message.facetSpecs[i]); + if (error) + return "facetSpecs." + error; + } + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.verify(message.boostSpec); + if (error) + return "boostSpec." + error; + } + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.verify(message.queryExpansionSpec); + if (error) + return "queryExpansionSpec." + error; + } + if (message.variantRollupKeys != null && message.hasOwnProperty("variantRollupKeys")) { + if (!Array.isArray(message.variantRollupKeys)) + return "variantRollupKeys: array expected"; + for (var i = 0; i < message.variantRollupKeys.length; ++i) + if (!$util.isString(message.variantRollupKeys[i])) + return "variantRollupKeys: string[] expected"; + } + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + switch (message.searchMode) { + default: + return "searchMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify(message.personalizationSpec); + if (error) + return "personalizationSpec." + error; + } + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + properties._spellCorrectionSpec = 1; + { + var error = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify(message.spellCorrectionSpec); + if (error) + return "spellCorrectionSpec." + error; + } + } + return null; + }; + + /** + * Creates a SearchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest} SearchRequest + */ + SearchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.branch != null) + message.branch = String(object.branch); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2.UserInfo.fromObject(object.userInfo); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.filter != null) + message.filter = String(object.filter); + if (object.canonicalFilter != null) + message.canonicalFilter = String(object.canonicalFilter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.facetSpecs) { + if (!Array.isArray(object.facetSpecs)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.facetSpecs: array expected"); + message.facetSpecs = []; + for (var i = 0; i < object.facetSpecs.length; ++i) { + if (typeof object.facetSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.facetSpecs: object expected"); + message.facetSpecs[i] = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.fromObject(object.facetSpecs[i]); + } + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostSpec != null) { + if (typeof object.boostSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.boostSpec: object expected"); + message.boostSpec = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.fromObject(object.boostSpec); + } + if (object.queryExpansionSpec != null) { + if (typeof object.queryExpansionSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.queryExpansionSpec: object expected"); + message.queryExpansionSpec = $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.fromObject(object.queryExpansionSpec); + } + if (object.variantRollupKeys) { + if (!Array.isArray(object.variantRollupKeys)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.variantRollupKeys: array expected"); + message.variantRollupKeys = []; + for (var i = 0; i < object.variantRollupKeys.length; ++i) + message.variantRollupKeys[i] = String(object.variantRollupKeys[i]); + } + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + switch (object.searchMode) { + default: + if (typeof object.searchMode === "number") { + message.searchMode = object.searchMode; + break; + } + break; + case "SEARCH_MODE_UNSPECIFIED": + case 0: + message.searchMode = 0; + break; + case "PRODUCT_SEARCH_ONLY": + case 1: + message.searchMode = 1; + break; + case "FACETED_SEARCH_ONLY": + case 2: + message.searchMode = 2; + break; + } + if (object.personalizationSpec != null) { + if (typeof object.personalizationSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.personalizationSpec: object expected"); + message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.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.spellCorrectionSpec != null) { + if (typeof object.spellCorrectionSpec !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.spellCorrectionSpec: object expected"); + message.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.fromObject(object.spellCorrectionSpec); + } + return message; + }; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {google.cloud.retail.v2.SearchRequest} message SearchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetSpecs = []; + object.variantRollupKeys = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.placement = ""; + object.branch = ""; + object.query = ""; + object.visitorId = ""; + object.userInfo = null; + object.pageSize = 0; + object.pageToken = ""; + object.offset = 0; + object.filter = ""; + object.orderBy = ""; + object.boostSpec = null; + object.queryExpansionSpec = null; + object.dynamicFacetSpec = null; + object.canonicalFilter = ""; + object.searchMode = options.enums === String ? "SEARCH_MODE_UNSPECIFIED" : 0; + object.personalizationSpec = null; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2.UserInfo.toObject(message.userInfo, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.facetSpecs && message.facetSpecs.length) { + object.facetSpecs = []; + for (var j = 0; j < message.facetSpecs.length; ++j) + object.facetSpecs[j] = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.toObject(message.facetSpecs[j], options); + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) + object.boostSpec = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.toObject(message.boostSpec, options); + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) + object.queryExpansionSpec = $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.toObject(message.queryExpansionSpec, options); + if (message.variantRollupKeys && message.variantRollupKeys.length) { + object.variantRollupKeys = []; + for (var j = 0; j < message.variantRollupKeys.length; ++j) + object.variantRollupKeys[j] = message.variantRollupKeys[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + object.canonicalFilter = message.canonicalFilter; + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + object.searchMode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.SearchMode[message.searchMode] === undefined ? message.searchMode : $root.google.cloud.retail.v2.SearchRequest.SearchMode[message.searchMode] : message.searchMode; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) + object.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + object.spellCorrectionSpec = $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.toObject(message.spellCorrectionSpec, options); + if (options.oneofs) + object._spellCorrectionSpec = "spellCorrectionSpec"; + } + return object; + }; + + /** + * Converts this SearchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest + * @instance + * @returns {Object.} JSON object + */ + SearchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest"; + }; + + SearchRequest.FacetSpec = (function() { + + /** + * Properties of a FacetSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface IFacetSpec + * @property {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey|null} [facetKey] FacetSpec facetKey + * @property {number|null} [limit] FacetSpec limit + * @property {Array.|null} [excludedFilterKeys] FacetSpec excludedFilterKeys + * @property {boolean|null} [enableDynamicPosition] FacetSpec enableDynamicPosition + */ + + /** + * Constructs a new FacetSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a FacetSpec. + * @implements IFacetSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.IFacetSpec=} [properties] Properties to set + */ + function FacetSpec(properties) { + this.excludedFilterKeys = []; + 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]]; + } + + /** + * FacetSpec facetKey. + * @member {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey|null|undefined} facetKey + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.facetKey = null; + + /** + * FacetSpec limit. + * @member {number} limit + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.limit = 0; + + /** + * FacetSpec excludedFilterKeys. + * @member {Array.} excludedFilterKeys + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.excludedFilterKeys = $util.emptyArray; + + /** + * FacetSpec enableDynamicPosition. + * @member {boolean} enableDynamicPosition + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.enableDynamicPosition = false; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec} FacetSpec instance + */ + FacetSpec.create = function create(properties) { + return new FacetSpec(properties); + }; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.facetKey != null && Object.hasOwnProperty.call(message, "facetKey")) + $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.encode(message.facetKey, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.limit); + if (message.excludedFilterKeys != null && message.excludedFilterKeys.length) + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.excludedFilterKeys[i]); + if (message.enableDynamicPosition != null && Object.hasOwnProperty.call(message, "enableDynamicPosition")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.enableDynamicPosition); + return writer; + }; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.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.cloud.retail.v2.SearchRequest.FacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.facetKey = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.decode(reader, reader.uint32()); + break; + } + case 2: { + message.limit = reader.int32(); + break; + } + case 3: { + if (!(message.excludedFilterKeys && message.excludedFilterKeys.length)) + message.excludedFilterKeys = []; + message.excludedFilterKeys.push(reader.string()); + break; + } + case 4: { + message.enableDynamicPosition = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.facetKey != null && message.hasOwnProperty("facetKey")) { + var error = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.verify(message.facetKey); + if (error) + return "facetKey." + error; + } + if (message.limit != null && message.hasOwnProperty("limit")) + if (!$util.isInteger(message.limit)) + return "limit: integer expected"; + if (message.excludedFilterKeys != null && message.hasOwnProperty("excludedFilterKeys")) { + if (!Array.isArray(message.excludedFilterKeys)) + return "excludedFilterKeys: array expected"; + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + if (!$util.isString(message.excludedFilterKeys[i])) + return "excludedFilterKeys: string[] expected"; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + if (typeof message.enableDynamicPosition !== "boolean") + return "enableDynamicPosition: boolean expected"; + return null; + }; + + /** + * Creates a FacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec} FacetSpec + */ + FacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.FacetSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.FacetSpec(); + if (object.facetKey != null) { + if (typeof object.facetKey !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.facetKey: object expected"); + message.facetKey = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.fromObject(object.facetKey); + } + if (object.limit != null) + message.limit = object.limit | 0; + if (object.excludedFilterKeys) { + if (!Array.isArray(object.excludedFilterKeys)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.excludedFilterKeys: array expected"); + message.excludedFilterKeys = []; + for (var i = 0; i < object.excludedFilterKeys.length; ++i) + message.excludedFilterKeys[i] = String(object.excludedFilterKeys[i]); + } + if (object.enableDynamicPosition != null) + message.enableDynamicPosition = Boolean(object.enableDynamicPosition); + return message; + }; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec} message FacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.excludedFilterKeys = []; + if (options.defaults) { + object.facetKey = null; + object.limit = 0; + object.enableDynamicPosition = false; + } + if (message.facetKey != null && message.hasOwnProperty("facetKey")) + object.facetKey = $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.toObject(message.facetKey, options); + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = message.limit; + if (message.excludedFilterKeys && message.excludedFilterKeys.length) { + object.excludedFilterKeys = []; + for (var j = 0; j < message.excludedFilterKeys.length; ++j) + object.excludedFilterKeys[j] = message.excludedFilterKeys[j]; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + object.enableDynamicPosition = message.enableDynamicPosition; + return object; + }; + + /** + * Converts this FacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @instance + * @returns {Object.} JSON object + */ + FacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.FacetSpec"; + }; + + FacetSpec.FacetKey = (function() { + + /** + * Properties of a FacetKey. + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @interface IFacetKey + * @property {string|null} [key] FacetKey key + * @property {Array.|null} [intervals] FacetKey intervals + * @property {Array.|null} [restrictedValues] FacetKey restrictedValues + * @property {Array.|null} [prefixes] FacetKey prefixes + * @property {Array.|null} [contains] FacetKey contains + * @property {boolean|null} [caseInsensitive] FacetKey caseInsensitive + * @property {string|null} [orderBy] FacetKey orderBy + * @property {string|null} [query] FacetKey query + * @property {boolean|null} [returnMinMax] FacetKey returnMinMax + */ + + /** + * Constructs a new FacetKey. + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec + * @classdesc Represents a FacetKey. + * @implements IFacetKey + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + */ + function FacetKey(properties) { + this.intervals = []; + this.restrictedValues = []; + this.prefixes = []; + this.contains = []; + 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]]; + } + + /** + * FacetKey key. + * @member {string} key + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.key = ""; + + /** + * FacetKey intervals. + * @member {Array.} intervals + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.intervals = $util.emptyArray; + + /** + * FacetKey restrictedValues. + * @member {Array.} restrictedValues + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.restrictedValues = $util.emptyArray; + + /** + * FacetKey prefixes. + * @member {Array.} prefixes + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.prefixes = $util.emptyArray; + + /** + * FacetKey contains. + * @member {Array.} contains + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.contains = $util.emptyArray; + + /** + * FacetKey caseInsensitive. + * @member {boolean} caseInsensitive + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.caseInsensitive = false; + + /** + * FacetKey orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.orderBy = ""; + + /** + * FacetKey query. + * @member {string} query + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.query = ""; + + /** + * FacetKey returnMinMax. + * @member {boolean} returnMinMax + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.returnMinMax = false; + + /** + * Creates a new FacetKey instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey} FacetKey instance + */ + FacetKey.create = function create(properties) { + return new FacetKey(properties); + }; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.intervals != null && message.intervals.length) + for (var i = 0; i < message.intervals.length; ++i) + $root.google.cloud.retail.v2.Interval.encode(message.intervals[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.restrictedValues != null && message.restrictedValues.length) + for (var i = 0; i < message.restrictedValues.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.restrictedValues[i]); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.orderBy); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.query); + if (message.prefixes != null && message.prefixes.length) + for (var i = 0; i < message.prefixes.length; ++i) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.prefixes[i]); + if (message.contains != null && message.contains.length) + for (var i = 0; i < message.contains.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.contains[i]); + if (message.caseInsensitive != null && Object.hasOwnProperty.call(message, "caseInsensitive")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.caseInsensitive); + if (message.returnMinMax != null && Object.hasOwnProperty.call(message, "returnMinMax")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.returnMinMax); + return writer; + }; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.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.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.intervals && message.intervals.length)) + message.intervals = []; + message.intervals.push($root.google.cloud.retail.v2.Interval.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.restrictedValues && message.restrictedValues.length)) + message.restrictedValues = []; + message.restrictedValues.push(reader.string()); + break; + } + case 8: { + if (!(message.prefixes && message.prefixes.length)) + message.prefixes = []; + message.prefixes.push(reader.string()); + break; + } + case 9: { + if (!(message.contains && message.contains.length)) + message.contains = []; + message.contains.push(reader.string()); + break; + } + case 10: { + message.caseInsensitive = reader.bool(); + break; + } + case 4: { + message.orderBy = reader.string(); + break; + } + case 5: { + message.query = reader.string(); + break; + } + case 11: { + message.returnMinMax = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetKey message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.intervals != null && message.hasOwnProperty("intervals")) { + if (!Array.isArray(message.intervals)) + return "intervals: array expected"; + for (var i = 0; i < message.intervals.length; ++i) { + var error = $root.google.cloud.retail.v2.Interval.verify(message.intervals[i]); + if (error) + return "intervals." + error; + } + } + if (message.restrictedValues != null && message.hasOwnProperty("restrictedValues")) { + if (!Array.isArray(message.restrictedValues)) + return "restrictedValues: array expected"; + for (var i = 0; i < message.restrictedValues.length; ++i) + if (!$util.isString(message.restrictedValues[i])) + return "restrictedValues: string[] expected"; + } + if (message.prefixes != null && message.hasOwnProperty("prefixes")) { + if (!Array.isArray(message.prefixes)) + return "prefixes: array expected"; + for (var i = 0; i < message.prefixes.length; ++i) + if (!$util.isString(message.prefixes[i])) + return "prefixes: string[] expected"; + } + if (message.contains != null && message.hasOwnProperty("contains")) { + if (!Array.isArray(message.contains)) + return "contains: array expected"; + for (var i = 0; i < message.contains.length; ++i) + if (!$util.isString(message.contains[i])) + return "contains: string[] expected"; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + if (typeof message.caseInsensitive !== "boolean") + return "caseInsensitive: boolean expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + if (typeof message.returnMinMax !== "boolean") + return "returnMinMax: boolean expected"; + return null; + }; + + /** + * Creates a FacetKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey} FacetKey + */ + FacetKey.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey(); + if (object.key != null) + message.key = String(object.key); + if (object.intervals) { + if (!Array.isArray(object.intervals)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals: array expected"); + message.intervals = []; + for (var i = 0; i < object.intervals.length; ++i) { + if (typeof object.intervals[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.intervals: object expected"); + message.intervals[i] = $root.google.cloud.retail.v2.Interval.fromObject(object.intervals[i]); + } + } + if (object.restrictedValues) { + if (!Array.isArray(object.restrictedValues)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.restrictedValues: array expected"); + message.restrictedValues = []; + for (var i = 0; i < object.restrictedValues.length; ++i) + message.restrictedValues[i] = String(object.restrictedValues[i]); + } + if (object.prefixes) { + if (!Array.isArray(object.prefixes)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.prefixes: array expected"); + message.prefixes = []; + for (var i = 0; i < object.prefixes.length; ++i) + message.prefixes[i] = String(object.prefixes[i]); + } + if (object.contains) { + if (!Array.isArray(object.contains)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.contains: array expected"); + message.contains = []; + for (var i = 0; i < object.contains.length; ++i) + message.contains[i] = String(object.contains[i]); + } + if (object.caseInsensitive != null) + message.caseInsensitive = Boolean(object.caseInsensitive); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.query != null) + message.query = String(object.query); + if (object.returnMinMax != null) + message.returnMinMax = Boolean(object.returnMinMax); + return message; + }; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey} message FacetKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.intervals = []; + object.restrictedValues = []; + object.prefixes = []; + object.contains = []; + } + if (options.defaults) { + object.key = ""; + object.orderBy = ""; + object.query = ""; + object.caseInsensitive = false; + object.returnMinMax = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.intervals && message.intervals.length) { + object.intervals = []; + for (var j = 0; j < message.intervals.length; ++j) + object.intervals[j] = $root.google.cloud.retail.v2.Interval.toObject(message.intervals[j], options); + } + if (message.restrictedValues && message.restrictedValues.length) { + object.restrictedValues = []; + for (var j = 0; j < message.restrictedValues.length; ++j) + object.restrictedValues[j] = message.restrictedValues[j]; + } + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.prefixes && message.prefixes.length) { + object.prefixes = []; + for (var j = 0; j < message.prefixes.length; ++j) + object.prefixes[j] = message.prefixes[j]; + } + if (message.contains && message.contains.length) { + object.contains = []; + for (var j = 0; j < message.contains.length; ++j) + object.contains[j] = message.contains[j]; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + object.caseInsensitive = message.caseInsensitive; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + object.returnMinMax = message.returnMinMax; + return object; + }; + + /** + * Converts this FacetKey to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @instance + * @returns {Object.} JSON object + */ + FacetKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetKey + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey"; + }; + + return FacetKey; + })(); + + return FacetSpec; + })(); + + SearchRequest.DynamicFacetSpec = (function() { + + /** + * Properties of a DynamicFacetSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface IDynamicFacetSpec + * @property {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode|null} [mode] DynamicFacetSpec mode + */ + + /** + * Constructs a new DynamicFacetSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a DynamicFacetSpec. + * @implements IDynamicFacetSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + */ + function DynamicFacetSpec(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]]; + } + + /** + * DynamicFacetSpec mode. + * @member {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode} mode + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @instance + */ + DynamicFacetSpec.prototype.mode = 0; + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} DynamicFacetSpec instance + */ + DynamicFacetSpec.create = function create(properties) { + return new DynamicFacetSpec(properties); + }; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.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.cloud.retail.v2.SearchRequest.DynamicFacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DynamicFacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DynamicFacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + */ + DynamicFacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec(); + 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 "DISABLED": + case 1: + message.mode = 1; + break; + case "ENABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} message DynamicFacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DynamicFacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @instance + * @returns {Object.} JSON object + */ + DynamicFacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DynamicFacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.DynamicFacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DynamicFacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.DynamicFacetSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} ENABLED=2 ENABLED value + */ + DynamicFacetSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[2] = "ENABLED"] = 2; + return values; + })(); + + return DynamicFacetSpec; + })(); + + SearchRequest.BoostSpec = (function() { + + /** + * Properties of a BoostSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface IBoostSpec + * @property {Array.|null} [conditionBoostSpecs] BoostSpec conditionBoostSpecs + * @property {boolean|null} [skipBoostSpecValidation] BoostSpec skipBoostSpecValidation + */ + + /** + * Constructs a new BoostSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a BoostSpec. + * @implements IBoostSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.IBoostSpec=} [properties] Properties to set + */ + function BoostSpec(properties) { + this.conditionBoostSpecs = []; + 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]]; + } + + /** + * BoostSpec conditionBoostSpecs. + * @member {Array.} conditionBoostSpecs + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.conditionBoostSpecs = $util.emptyArray; + + /** + * BoostSpec skipBoostSpecValidation. + * @member {boolean|null|undefined} skipBoostSpecValidation + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.skipBoostSpecValidation = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BoostSpec _skipBoostSpecValidation. + * @member {"skipBoostSpecValidation"|undefined} _skipBoostSpecValidation + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @instance + */ + Object.defineProperty(BoostSpec.prototype, "_skipBoostSpecValidation", { + get: $util.oneOfGetter($oneOfFields = ["skipBoostSpecValidation"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec} BoostSpec instance + */ + BoostSpec.create = function create(properties) { + return new BoostSpec(properties); + }; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.conditionBoostSpecs != null && message.conditionBoostSpecs.length) + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.conditionBoostSpecs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.skipBoostSpecValidation != null && Object.hasOwnProperty.call(message, "skipBoostSpecValidation")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.skipBoostSpecValidation); + return writer; + }; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.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.cloud.retail.v2.SearchRequest.BoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.conditionBoostSpecs && message.conditionBoostSpecs.length)) + message.conditionBoostSpecs = []; + message.conditionBoostSpecs.push($root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + case 2: { + message.skipBoostSpecValidation = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.conditionBoostSpecs != null && message.hasOwnProperty("conditionBoostSpecs")) { + if (!Array.isArray(message.conditionBoostSpecs)) + return "conditionBoostSpecs: array expected"; + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.conditionBoostSpecs[i]); + if (error) + return "conditionBoostSpecs." + error; + } + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + properties._skipBoostSpecValidation = 1; + if (typeof message.skipBoostSpecValidation !== "boolean") + return "skipBoostSpecValidation: boolean expected"; + } + return null; + }; + + /** + * Creates a BoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec} BoostSpec + */ + BoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.BoostSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.BoostSpec(); + if (object.conditionBoostSpecs) { + if (!Array.isArray(object.conditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2.SearchRequest.BoostSpec.conditionBoostSpecs: array expected"); + message.conditionBoostSpecs = []; + for (var i = 0; i < object.conditionBoostSpecs.length; ++i) { + if (typeof object.conditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchRequest.BoostSpec.conditionBoostSpecs: object expected"); + message.conditionBoostSpecs[i] = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.conditionBoostSpecs[i]); + } + } + if (object.skipBoostSpecValidation != null) + message.skipBoostSpecValidation = Boolean(object.skipBoostSpecValidation); + return message; + }; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} message BoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.conditionBoostSpecs = []; + if (message.conditionBoostSpecs && message.conditionBoostSpecs.length) { + object.conditionBoostSpecs = []; + for (var j = 0; j < message.conditionBoostSpecs.length; ++j) + object.conditionBoostSpecs[j] = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.conditionBoostSpecs[j], options); + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + object.skipBoostSpecValidation = message.skipBoostSpecValidation; + if (options.oneofs) + object._skipBoostSpecValidation = "skipBoostSpecValidation"; + } + return object; + }; + + /** + * Converts this BoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @instance + * @returns {Object.} JSON object + */ + BoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.BoostSpec"; + }; + + BoostSpec.ConditionBoostSpec = (function() { + + /** + * Properties of a ConditionBoostSpec. + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @interface IConditionBoostSpec + * @property {string|null} [condition] ConditionBoostSpec condition + * @property {number|null} [boost] ConditionBoostSpec boost + */ + + /** + * Constructs a new ConditionBoostSpec. + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec + * @classdesc Represents a ConditionBoostSpec. + * @implements IConditionBoostSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + */ + function ConditionBoostSpec(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]]; + } + + /** + * ConditionBoostSpec condition. + * @member {string} condition + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.condition = ""; + + /** + * ConditionBoostSpec boost. + * @member {number} boost + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.boost = 0; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec instance + */ + ConditionBoostSpec.create = function create(properties) { + return new ConditionBoostSpec(properties); + }; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.condition); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.boost); + return writer; + }; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.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.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.string(); + break; + } + case 2: { + message.boost = reader.float(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ConditionBoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ConditionBoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + if (!$util.isString(message.condition)) + return "condition: string expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + return null; + }; + + /** + * Creates a ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + */ + ConditionBoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec(); + if (object.condition != null) + message.condition = String(object.condition); + if (object.boost != null) + message.boost = Number(object.boost); + return message; + }; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec} message ConditionBoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ConditionBoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = ""; + object.boost = 0; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = message.condition; + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + return object; + }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + * @returns {Object.} JSON object + */ + ConditionBoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ConditionBoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ConditionBoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec"; + }; + + return ConditionBoostSpec; + })(); + + return BoostSpec; + })(); + + SearchRequest.QueryExpansionSpec = (function() { + + /** + * Properties of a QueryExpansionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface IQueryExpansionSpec + * @property {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition|null} [condition] QueryExpansionSpec condition + * @property {boolean|null} [pinUnexpandedResults] QueryExpansionSpec pinUnexpandedResults + */ + + /** + * Constructs a new QueryExpansionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a QueryExpansionSpec. + * @implements IQueryExpansionSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + */ + function QueryExpansionSpec(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]]; + } + + /** + * QueryExpansionSpec condition. + * @member {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition} condition + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.condition = 0; + + /** + * QueryExpansionSpec pinUnexpandedResults. + * @member {boolean} pinUnexpandedResults + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.pinUnexpandedResults = false; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} QueryExpansionSpec instance + */ + QueryExpansionSpec.create = function create(properties) { + return new QueryExpansionSpec(properties); + }; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.condition); + if (message.pinUnexpandedResults != null && Object.hasOwnProperty.call(message, "pinUnexpandedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.pinUnexpandedResults); + return writer; + }; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.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.cloud.retail.v2.SearchRequest.QueryExpansionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.int32(); + break; + } + case 2: { + message.pinUnexpandedResults = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + switch (message.condition) { + default: + return "condition: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + if (typeof message.pinUnexpandedResults !== "boolean") + return "pinUnexpandedResults: boolean expected"; + return null; + }; + + /** + * Creates a QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + */ + QueryExpansionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec(); + switch (object.condition) { + default: + if (typeof object.condition === "number") { + message.condition = object.condition; + break; + } + break; + case "CONDITION_UNSPECIFIED": + case 0: + message.condition = 0; + break; + case "DISABLED": + case 1: + message.condition = 1; + break; + case "AUTO": + case 3: + message.condition = 3; + break; + } + if (object.pinUnexpandedResults != null) + message.pinUnexpandedResults = Boolean(object.pinUnexpandedResults); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} message QueryExpansionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = options.enums === String ? "CONDITION_UNSPECIFIED" : 0; + object.pinUnexpandedResults = false; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition[message.condition] === undefined ? message.condition : $root.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition[message.condition] : message.condition; + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + object.pinUnexpandedResults = message.pinUnexpandedResults; + return object; + }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.QueryExpansionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.QueryExpansionSpec"; + }; + + /** + * Condition enum. + * @name google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition + * @enum {number} + * @property {number} CONDITION_UNSPECIFIED=0 CONDITION_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} AUTO=3 AUTO value + */ + QueryExpansionSpec.Condition = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CONDITION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[3] = "AUTO"] = 3; + return values; + })(); + + return QueryExpansionSpec; + })(); + + SearchRequest.PersonalizationSpec = (function() { + + /** + * Properties of a PersonalizationSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface IPersonalizationSpec + * @property {google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode|null} [mode] PersonalizationSpec mode + */ + + /** + * Constructs a new PersonalizationSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a PersonalizationSpec. + * @implements IPersonalizationSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + */ + function PersonalizationSpec(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]]; + } + + /** + * PersonalizationSpec mode. + * @member {google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode} mode + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @instance + */ + PersonalizationSpec.prototype.mode = 0; + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} PersonalizationSpec instance + */ + PersonalizationSpec.create = function create(properties) { + return new PersonalizationSpec(properties); + }; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.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.cloud.retail.v2.SearchRequest.PersonalizationSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PersonalizationSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PersonalizationSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} PersonalizationSpec + */ + PersonalizationSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec(); + 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 "AUTO": + case 1: + message.mode = 1; + break; + case "DISABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} message PersonalizationSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PersonalizationSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this PersonalizationSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @instance + * @returns {Object.} JSON object + */ + PersonalizationSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PersonalizationSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.PersonalizationSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PersonalizationSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.PersonalizationSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} AUTO=1 AUTO value + * @property {number} DISABLED=2 DISABLED value + */ + PersonalizationSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "AUTO"] = 1; + values[valuesById[2] = "DISABLED"] = 2; + return values; + })(); + + return PersonalizationSpec; + })(); + + SearchRequest.SpellCorrectionSpec = (function() { + + /** + * Properties of a SpellCorrectionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @interface ISpellCorrectionSpec + * @property {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode|null} [mode] SpellCorrectionSpec mode + */ + + /** + * Constructs a new SpellCorrectionSpec. + * @memberof google.cloud.retail.v2.SearchRequest + * @classdesc Represents a SpellCorrectionSpec. + * @implements ISpellCorrectionSpec + * @constructor + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + */ + function SpellCorrectionSpec(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]]; + } + + /** + * SpellCorrectionSpec mode. + * @member {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode} mode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @instance + */ + SpellCorrectionSpec.prototype.mode = 0; + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec instance + */ + SpellCorrectionSpec.create = function create(properties) { + return new SpellCorrectionSpec(properties); + }; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.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.cloud.retail.v2.SearchRequest.SpellCorrectionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpellCorrectionSpec message. + * @function verify + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpellCorrectionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + */ + SpellCorrectionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec) + return object; + var message = new $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec(); + 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 "SUGGESTION_ONLY": + case 1: + message.mode = 1; + break; + case "AUTO": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} message SpellCorrectionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpellCorrectionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @instance + * @returns {Object.} JSON object + */ + SpellCorrectionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpellCorrectionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} SUGGESTION_ONLY=1 SUGGESTION_ONLY value + * @property {number} AUTO=2 AUTO value + */ + SpellCorrectionSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SUGGESTION_ONLY"] = 1; + values[valuesById[2] = "AUTO"] = 2; + return values; + })(); + + return SpellCorrectionSpec; + })(); + + /** + * SearchMode enum. + * @name google.cloud.retail.v2.SearchRequest.SearchMode + * @enum {number} + * @property {number} SEARCH_MODE_UNSPECIFIED=0 SEARCH_MODE_UNSPECIFIED value + * @property {number} PRODUCT_SEARCH_ONLY=1 PRODUCT_SEARCH_ONLY value + * @property {number} FACETED_SEARCH_ONLY=2 FACETED_SEARCH_ONLY value + */ + SearchRequest.SearchMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_SEARCH_ONLY"] = 1; + values[valuesById[2] = "FACETED_SEARCH_ONLY"] = 2; + return values; + })(); + + return SearchRequest; + })(); + + v2.SearchResponse = (function() { + + /** + * Properties of a SearchResponse. + * @memberof google.cloud.retail.v2 + * @interface ISearchResponse + * @property {Array.|null} [results] SearchResponse results + * @property {Array.|null} [facets] SearchResponse facets + * @property {number|null} [totalSize] SearchResponse totalSize + * @property {string|null} [correctedQuery] SearchResponse correctedQuery + * @property {string|null} [attributionToken] SearchResponse attributionToken + * @property {string|null} [nextPageToken] SearchResponse nextPageToken + * @property {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo|null} [queryExpansionInfo] SearchResponse queryExpansionInfo + * @property {string|null} [redirectUri] SearchResponse redirectUri + * @property {Array.|null} [appliedControls] SearchResponse appliedControls + * @property {Array.|null} [invalidConditionBoostSpecs] SearchResponse invalidConditionBoostSpecs + */ + + /** + * Constructs a new SearchResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a SearchResponse. + * @implements ISearchResponse + * @constructor + * @param {google.cloud.retail.v2.ISearchResponse=} [properties] Properties to set + */ + function SearchResponse(properties) { + this.results = []; + this.facets = []; + this.appliedControls = []; + this.invalidConditionBoostSpecs = []; + 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]]; + } + + /** + * SearchResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.results = $util.emptyArray; + + /** + * SearchResponse facets. + * @member {Array.} facets + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.facets = $util.emptyArray; + + /** + * SearchResponse totalSize. + * @member {number} totalSize + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.totalSize = 0; + + /** + * SearchResponse correctedQuery. + * @member {string} correctedQuery + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.correctedQuery = ""; + + /** + * SearchResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.attributionToken = ""; + + /** + * SearchResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.nextPageToken = ""; + + /** + * SearchResponse queryExpansionInfo. + * @member {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo|null|undefined} queryExpansionInfo + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.queryExpansionInfo = null; + + /** + * SearchResponse redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.redirectUri = ""; + + /** + * SearchResponse appliedControls. + * @member {Array.} appliedControls + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.appliedControls = $util.emptyArray; + + /** + * SearchResponse invalidConditionBoostSpecs. + * @member {Array.} invalidConditionBoostSpecs + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + */ + SearchResponse.prototype.invalidConditionBoostSpecs = $util.emptyArray; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {google.cloud.retail.v2.ISearchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchResponse} SearchResponse instance + */ + SearchResponse.create = function create(properties) { + return new SearchResponse(properties); + }; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {google.cloud.retail.v2.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2.SearchResponse.SearchResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.facets != null && message.facets.length) + for (var i = 0; i < message.facets.length; ++i) + $root.google.cloud.retail.v2.SearchResponse.Facet.encode(message.facets[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.totalSize != null && Object.hasOwnProperty.call(message, "totalSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.totalSize); + if (message.correctedQuery != null && Object.hasOwnProperty.call(message, "correctedQuery")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.correctedQuery); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.nextPageToken); + if (message.queryExpansionInfo != null && Object.hasOwnProperty.call(message, "queryExpansionInfo")) + $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.encode(message.queryExpansionInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectUri); + if (message.appliedControls != null && message.appliedControls.length) + for (var i = 0; i < message.appliedControls.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.appliedControls[i]); + if (message.invalidConditionBoostSpecs != null && message.invalidConditionBoostSpecs.length) + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.invalidConditionBoostSpecs[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {google.cloud.retail.v2.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.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.cloud.retail.v2.SearchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2.SearchResponse.SearchResult.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.facets && message.facets.length)) + message.facets = []; + message.facets.push($root.google.cloud.retail.v2.SearchResponse.Facet.decode(reader, reader.uint32())); + break; + } + case 3: { + message.totalSize = reader.int32(); + break; + } + case 4: { + message.correctedQuery = reader.string(); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + message.nextPageToken = reader.string(); + break; + } + case 7: { + message.queryExpansionInfo = $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.decode(reader, reader.uint32()); + break; + } + case 10: { + message.redirectUri = reader.string(); + break; + } + case 12: { + if (!(message.appliedControls && message.appliedControls.length)) + message.appliedControls = []; + message.appliedControls.push(reader.string()); + break; + } + case 14: { + if (!(message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length)) + message.invalidConditionBoostSpecs = []; + message.invalidConditionBoostSpecs.push($root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResponse message. + * @function verify + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2.SearchResponse.SearchResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.facets != null && message.hasOwnProperty("facets")) { + if (!Array.isArray(message.facets)) + return "facets: array expected"; + for (var i = 0; i < message.facets.length; ++i) { + var error = $root.google.cloud.retail.v2.SearchResponse.Facet.verify(message.facets[i]); + if (error) + return "facets." + error; + } + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + if (!$util.isInteger(message.totalSize)) + return "totalSize: integer expected"; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + if (!$util.isString(message.correctedQuery)) + return "correctedQuery: string expected"; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) { + var error = $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.verify(message.queryExpansionInfo); + if (error) + return "queryExpansionInfo." + error; + } + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + if (message.appliedControls != null && message.hasOwnProperty("appliedControls")) { + if (!Array.isArray(message.appliedControls)) + return "appliedControls: array expected"; + for (var i = 0; i < message.appliedControls.length; ++i) + if (!$util.isString(message.appliedControls[i])) + return "appliedControls: string[] expected"; + } + if (message.invalidConditionBoostSpecs != null && message.hasOwnProperty("invalidConditionBoostSpecs")) { + if (!Array.isArray(message.invalidConditionBoostSpecs)) + return "invalidConditionBoostSpecs: array expected"; + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.invalidConditionBoostSpecs[i]); + if (error) + return "invalidConditionBoostSpecs." + error; + } + } + return null; + }; + + /** + * Creates a SearchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchResponse} SearchResponse + */ + SearchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchResponse) + return object; + var message = new $root.google.cloud.retail.v2.SearchResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2.SearchResponse.SearchResult.fromObject(object.results[i]); + } + } + if (object.facets) { + if (!Array.isArray(object.facets)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.facets: array expected"); + message.facets = []; + for (var i = 0; i < object.facets.length; ++i) { + if (typeof object.facets[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.facets: object expected"); + message.facets[i] = $root.google.cloud.retail.v2.SearchResponse.Facet.fromObject(object.facets[i]); + } + } + if (object.totalSize != null) + message.totalSize = object.totalSize | 0; + if (object.correctedQuery != null) + message.correctedQuery = String(object.correctedQuery); + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + if (object.queryExpansionInfo != null) { + if (typeof object.queryExpansionInfo !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.queryExpansionInfo: object expected"); + message.queryExpansionInfo = $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.fromObject(object.queryExpansionInfo); + } + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + if (object.appliedControls) { + if (!Array.isArray(object.appliedControls)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.appliedControls: array expected"); + message.appliedControls = []; + for (var i = 0; i < object.appliedControls.length; ++i) + message.appliedControls[i] = String(object.appliedControls[i]); + } + if (object.invalidConditionBoostSpecs) { + if (!Array.isArray(object.invalidConditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.invalidConditionBoostSpecs: array expected"); + message.invalidConditionBoostSpecs = []; + for (var i = 0; i < object.invalidConditionBoostSpecs.length; ++i) { + if (typeof object.invalidConditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.invalidConditionBoostSpecs: object expected"); + message.invalidConditionBoostSpecs[i] = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.invalidConditionBoostSpecs[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {google.cloud.retail.v2.SearchResponse} message SearchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.facets = []; + object.appliedControls = []; + object.invalidConditionBoostSpecs = []; + } + if (options.defaults) { + object.totalSize = 0; + object.correctedQuery = ""; + object.attributionToken = ""; + object.nextPageToken = ""; + object.queryExpansionInfo = null; + object.redirectUri = ""; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2.SearchResponse.SearchResult.toObject(message.results[j], options); + } + if (message.facets && message.facets.length) { + object.facets = []; + for (var j = 0; j < message.facets.length; ++j) + object.facets[j] = $root.google.cloud.retail.v2.SearchResponse.Facet.toObject(message.facets[j], options); + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + object.totalSize = message.totalSize; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + object.correctedQuery = message.correctedQuery; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) + object.queryExpansionInfo = $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.toObject(message.queryExpansionInfo, options); + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + if (message.appliedControls && message.appliedControls.length) { + object.appliedControls = []; + for (var j = 0; j < message.appliedControls.length; ++j) + object.appliedControls[j] = message.appliedControls[j]; + } + if (message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length) { + object.invalidConditionBoostSpecs = []; + for (var j = 0; j < message.invalidConditionBoostSpecs.length; ++j) + object.invalidConditionBoostSpecs[j] = $root.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.invalidConditionBoostSpecs[j], options); + } + return object; + }; + + /** + * Converts this SearchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchResponse + * @instance + * @returns {Object.} JSON object + */ + SearchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchResponse"; + }; + + SearchResponse.SearchResult = (function() { + + /** + * Properties of a SearchResult. + * @memberof google.cloud.retail.v2.SearchResponse + * @interface ISearchResult + * @property {string|null} [id] SearchResult id + * @property {google.cloud.retail.v2.IProduct|null} [product] SearchResult product + * @property {number|null} [matchingVariantCount] SearchResult matchingVariantCount + * @property {Object.|null} [matchingVariantFields] SearchResult matchingVariantFields + * @property {Object.|null} [variantRollupValues] SearchResult variantRollupValues + * @property {Array.|null} [personalLabels] SearchResult personalLabels + */ + + /** + * Constructs a new SearchResult. + * @memberof google.cloud.retail.v2.SearchResponse + * @classdesc Represents a SearchResult. + * @implements ISearchResult + * @constructor + * @param {google.cloud.retail.v2.SearchResponse.ISearchResult=} [properties] Properties to set + */ + function SearchResult(properties) { + this.matchingVariantFields = {}; + this.variantRollupValues = {}; + this.personalLabels = []; + 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]]; + } + + /** + * SearchResult id. + * @member {string} id + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.id = ""; + + /** + * SearchResult product. + * @member {google.cloud.retail.v2.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.product = null; + + /** + * SearchResult matchingVariantCount. + * @member {number} matchingVariantCount + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantCount = 0; + + /** + * SearchResult matchingVariantFields. + * @member {Object.} matchingVariantFields + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantFields = $util.emptyObject; + + /** + * SearchResult variantRollupValues. + * @member {Object.} variantRollupValues + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.variantRollupValues = $util.emptyObject; + + /** + * SearchResult personalLabels. + * @member {Array.} personalLabels + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.personalLabels = $util.emptyArray; + + /** + * Creates a new SearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2.SearchResponse.ISearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchResponse.SearchResult} SearchResult instance + */ + SearchResult.create = function create(properties) { + return new SearchResult(properties); + }; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.SearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.matchingVariantCount != null && Object.hasOwnProperty.call(message, "matchingVariantCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.matchingVariantCount); + if (message.matchingVariantFields != null && Object.hasOwnProperty.call(message, "matchingVariantFields")) + for (var keys = Object.keys(message.matchingVariantFields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.FieldMask.encode(message.matchingVariantFields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.variantRollupValues != null && Object.hasOwnProperty.call(message, "variantRollupValues")) + for (var keys = Object.keys(message.variantRollupValues), 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.protobuf.Value.encode(message.variantRollupValues[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.personalLabels != null && message.personalLabels.length) + for (var i = 0; i < message.personalLabels.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.personalLabels[i]); + return writer; + }; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.SearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.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.cloud.retail.v2.SearchResponse.SearchResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.matchingVariantCount = reader.int32(); + break; + } + case 4: { + if (message.matchingVariantFields === $util.emptyObject) + message.matchingVariantFields = {}; + 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.FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.matchingVariantFields[key] = value; + break; + } + case 5: { + if (message.variantRollupValues === $util.emptyObject) + message.variantRollupValues = {}; + 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.variantRollupValues[key] = value; + break; + } + case 7: { + if (!(message.personalLabels && message.personalLabels.length)) + message.personalLabels = []; + message.personalLabels.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResult message. + * @function verify + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + if (!$util.isInteger(message.matchingVariantCount)) + return "matchingVariantCount: integer expected"; + if (message.matchingVariantFields != null && message.hasOwnProperty("matchingVariantFields")) { + if (!$util.isObject(message.matchingVariantFields)) + return "matchingVariantFields: object expected"; + var key = Object.keys(message.matchingVariantFields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.FieldMask.verify(message.matchingVariantFields[key[i]]); + if (error) + return "matchingVariantFields." + error; + } + } + if (message.variantRollupValues != null && message.hasOwnProperty("variantRollupValues")) { + if (!$util.isObject(message.variantRollupValues)) + return "variantRollupValues: object expected"; + var key = Object.keys(message.variantRollupValues); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.variantRollupValues[key[i]]); + if (error) + return "variantRollupValues." + error; + } + } + if (message.personalLabels != null && message.hasOwnProperty("personalLabels")) { + if (!Array.isArray(message.personalLabels)) + return "personalLabels: array expected"; + for (var i = 0; i < message.personalLabels.length; ++i) + if (!$util.isString(message.personalLabels[i])) + return "personalLabels: string[] expected"; + } + return null; + }; + + /** + * Creates a SearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchResponse.SearchResult} SearchResult + */ + SearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchResponse.SearchResult) + return object; + var message = new $root.google.cloud.retail.v2.SearchResponse.SearchResult(); + if (object.id != null) + message.id = String(object.id); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.product: object expected"); + message.product = $root.google.cloud.retail.v2.Product.fromObject(object.product); + } + if (object.matchingVariantCount != null) + message.matchingVariantCount = object.matchingVariantCount | 0; + if (object.matchingVariantFields) { + if (typeof object.matchingVariantFields !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields = {}; + for (var keys = Object.keys(object.matchingVariantFields), i = 0; i < keys.length; ++i) { + if (typeof object.matchingVariantFields[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields[keys[i]] = $root.google.protobuf.FieldMask.fromObject(object.matchingVariantFields[keys[i]]); + } + } + if (object.variantRollupValues) { + if (typeof object.variantRollupValues !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues = {}; + for (var keys = Object.keys(object.variantRollupValues), i = 0; i < keys.length; ++i) { + if (typeof object.variantRollupValues[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues[keys[i]] = $root.google.protobuf.Value.fromObject(object.variantRollupValues[keys[i]]); + } + } + if (object.personalLabels) { + if (!Array.isArray(object.personalLabels)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.SearchResult.personalLabels: array expected"); + message.personalLabels = []; + for (var i = 0; i < object.personalLabels.length; ++i) + message.personalLabels[i] = String(object.personalLabels[i]); + } + return message; + }; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2.SearchResponse.SearchResult} message SearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.personalLabels = []; + if (options.objects || options.defaults) { + object.matchingVariantFields = {}; + object.variantRollupValues = {}; + } + if (options.defaults) { + object.id = ""; + object.product = null; + object.matchingVariantCount = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2.Product.toObject(message.product, options); + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + object.matchingVariantCount = message.matchingVariantCount; + var keys2; + if (message.matchingVariantFields && (keys2 = Object.keys(message.matchingVariantFields)).length) { + object.matchingVariantFields = {}; + for (var j = 0; j < keys2.length; ++j) + object.matchingVariantFields[keys2[j]] = $root.google.protobuf.FieldMask.toObject(message.matchingVariantFields[keys2[j]], options); + } + if (message.variantRollupValues && (keys2 = Object.keys(message.variantRollupValues)).length) { + object.variantRollupValues = {}; + for (var j = 0; j < keys2.length; ++j) + object.variantRollupValues[keys2[j]] = $root.google.protobuf.Value.toObject(message.variantRollupValues[keys2[j]], options); + } + if (message.personalLabels && message.personalLabels.length) { + object.personalLabels = []; + for (var j = 0; j < message.personalLabels.length; ++j) + object.personalLabels[j] = message.personalLabels[j]; + } + return object; + }; + + /** + * Converts this SearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @instance + * @returns {Object.} JSON object + */ + SearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchResponse.SearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchResponse.SearchResult"; + }; + + return SearchResult; + })(); + + SearchResponse.Facet = (function() { + + /** + * Properties of a Facet. + * @memberof google.cloud.retail.v2.SearchResponse + * @interface IFacet + * @property {string|null} [key] Facet key + * @property {Array.|null} [values] Facet values + * @property {boolean|null} [dynamicFacet] Facet dynamicFacet + */ + + /** + * Constructs a new Facet. + * @memberof google.cloud.retail.v2.SearchResponse + * @classdesc Represents a Facet. + * @implements IFacet + * @constructor + * @param {google.cloud.retail.v2.SearchResponse.IFacet=} [properties] Properties to set + */ + function Facet(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]]; + } + + /** + * Facet key. + * @member {string} key + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @instance + */ + Facet.prototype.key = ""; + + /** + * Facet values. + * @member {Array.} values + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @instance + */ + Facet.prototype.values = $util.emptyArray; + + /** + * Facet dynamicFacet. + * @member {boolean} dynamicFacet + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @instance + */ + Facet.prototype.dynamicFacet = false; + + /** + * Creates a new Facet instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2.SearchResponse.IFacet=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchResponse.Facet} Facet instance + */ + Facet.create = function create(properties) { + return new Facet(properties); + }; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue.encode(message.values[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.dynamicFacet != null && Object.hasOwnProperty.call(message, "dynamicFacet")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.dynamicFacet); + return writer; + }; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.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.cloud.retail.v2.SearchResponse.Facet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue.decode(reader, reader.uint32())); + break; + } + case 3: { + message.dynamicFacet = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Facet message. + * @function verify + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Facet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string 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.cloud.retail.v2.SearchResponse.Facet.FacetValue.verify(message.values[i]); + if (error) + return "values." + error; + } + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + if (typeof message.dynamicFacet !== "boolean") + return "dynamicFacet: boolean expected"; + return null; + }; + + /** + * Creates a Facet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchResponse.Facet} Facet + */ + Facet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchResponse.Facet) + return object; + var message = new $root.google.cloud.retail.v2.SearchResponse.Facet(); + if (object.key != null) + message.key = String(object.key); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.cloud.retail.v2.SearchResponse.Facet.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.Facet.values: object expected"); + message.values[i] = $root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue.fromObject(object.values[i]); + } + } + if (object.dynamicFacet != null) + message.dynamicFacet = Boolean(object.dynamicFacet); + return message; + }; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2.SearchResponse.Facet} message Facet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Facet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (options.defaults) { + object.key = ""; + object.dynamicFacet = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue.toObject(message.values[j], options); + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + object.dynamicFacet = message.dynamicFacet; + return object; + }; + + /** + * Converts this Facet to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @instance + * @returns {Object.} JSON object + */ + Facet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Facet + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Facet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchResponse.Facet"; + }; + + Facet.FacetValue = (function() { + + /** + * Properties of a FacetValue. + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @interface IFacetValue + * @property {string|null} [value] FacetValue value + * @property {google.cloud.retail.v2.IInterval|null} [interval] FacetValue interval + * @property {number|Long|null} [count] FacetValue count + * @property {number|null} [minValue] FacetValue minValue + * @property {number|null} [maxValue] FacetValue maxValue + */ + + /** + * Constructs a new FacetValue. + * @memberof google.cloud.retail.v2.SearchResponse.Facet + * @classdesc Represents a FacetValue. + * @implements IFacetValue + * @constructor + * @param {google.cloud.retail.v2.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + */ + function FacetValue(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]]; + } + + /** + * FacetValue value. + * @member {string|null|undefined} value + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.value = null; + + /** + * FacetValue interval. + * @member {google.cloud.retail.v2.IInterval|null|undefined} interval + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.interval = null; + + /** + * FacetValue count. + * @member {number|Long} count + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.count = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * FacetValue minValue. + * @member {number} minValue + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.minValue = 0; + + /** + * FacetValue maxValue. + * @member {number} maxValue + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.maxValue = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FacetValue facetValue. + * @member {"value"|"interval"|undefined} facetValue + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + */ + Object.defineProperty(FacetValue.prototype, "facetValue", { + get: $util.oneOfGetter($oneOfFields = ["value", "interval"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new FacetValue instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchResponse.Facet.FacetValue} FacetValue instance + */ + FacetValue.create = function create(properties) { + return new FacetValue(properties); + }; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.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); + if (message.interval != null && Object.hasOwnProperty.call(message, "interval")) + $root.google.cloud.retail.v2.Interval.encode(message.interval, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.count); + if (message.minValue != null && Object.hasOwnProperty.call(message, "minValue")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.minValue); + if (message.maxValue != null && Object.hasOwnProperty.call(message, "maxValue")) + writer.uint32(/* id 6, wireType 1 =*/49).double(message.maxValue); + return writer; + }; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.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.cloud.retail.v2.SearchResponse.Facet.FacetValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.interval = $root.google.cloud.retail.v2.Interval.decode(reader, reader.uint32()); + break; + } + case 3: { + message.count = reader.int64(); + break; + } + case 5: { + message.minValue = reader.double(); + break; + } + case 6: { + message.maxValue = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetValue message. + * @function verify + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.value != null && message.hasOwnProperty("value")) { + properties.facetValue = 1; + if (!$util.isString(message.value)) + return "value: string expected"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + if (properties.facetValue === 1) + return "facetValue: multiple values"; + properties.facetValue = 1; + { + var error = $root.google.cloud.retail.v2.Interval.verify(message.interval); + if (error) + return "interval." + error; + } + } + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count) && !(message.count && $util.isInteger(message.count.low) && $util.isInteger(message.count.high))) + return "count: integer|Long expected"; + if (message.minValue != null && message.hasOwnProperty("minValue")) + if (typeof message.minValue !== "number") + return "minValue: number expected"; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + if (typeof message.maxValue !== "number") + return "maxValue: number expected"; + return null; + }; + + /** + * Creates a FacetValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchResponse.Facet.FacetValue} FacetValue + */ + FacetValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue) + return object; + var message = new $root.google.cloud.retail.v2.SearchResponse.Facet.FacetValue(); + if (object.value != null) + message.value = String(object.value); + if (object.interval != null) { + if (typeof object.interval !== "object") + throw TypeError(".google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval: object expected"); + message.interval = $root.google.cloud.retail.v2.Interval.fromObject(object.interval); + } + if (object.count != null) + if ($util.Long) + (message.count = $util.Long.fromValue(object.count)).unsigned = false; + else if (typeof object.count === "string") + message.count = parseInt(object.count, 10); + else if (typeof object.count === "number") + message.count = object.count; + else if (typeof object.count === "object") + message.count = new $util.LongBits(object.count.low >>> 0, object.count.high >>> 0).toNumber(); + if (object.minValue != null) + message.minValue = Number(object.minValue); + if (object.maxValue != null) + message.maxValue = Number(object.maxValue); + return message; + }; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2.SearchResponse.Facet.FacetValue} message FacetValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetValue.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.count = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.count = options.longs === String ? "0" : 0; + object.minValue = 0; + object.maxValue = 0; + } + if (message.value != null && message.hasOwnProperty("value")) { + object.value = message.value; + if (options.oneofs) + object.facetValue = "value"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + object.interval = $root.google.cloud.retail.v2.Interval.toObject(message.interval, options); + if (options.oneofs) + object.facetValue = "interval"; + } + if (message.count != null && message.hasOwnProperty("count")) + if (typeof message.count === "number") + object.count = options.longs === String ? String(message.count) : message.count; + else + object.count = options.longs === String ? $util.Long.prototype.toString.call(message.count) : options.longs === Number ? new $util.LongBits(message.count.low >>> 0, message.count.high >>> 0).toNumber() : message.count; + if (message.minValue != null && message.hasOwnProperty("minValue")) + object.minValue = options.json && !isFinite(message.minValue) ? String(message.minValue) : message.minValue; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + object.maxValue = options.json && !isFinite(message.maxValue) ? String(message.maxValue) : message.maxValue; + return object; + }; + + /** + * Converts this FacetValue to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @instance + * @returns {Object.} JSON object + */ + FacetValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetValue + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchResponse.Facet.FacetValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchResponse.Facet.FacetValue"; + }; + + return FacetValue; + })(); + + return Facet; + })(); + + SearchResponse.QueryExpansionInfo = (function() { + + /** + * Properties of a QueryExpansionInfo. + * @memberof google.cloud.retail.v2.SearchResponse + * @interface IQueryExpansionInfo + * @property {boolean|null} [expandedQuery] QueryExpansionInfo expandedQuery + * @property {number|Long|null} [pinnedResultCount] QueryExpansionInfo pinnedResultCount + */ + + /** + * Constructs a new QueryExpansionInfo. + * @memberof google.cloud.retail.v2.SearchResponse + * @classdesc Represents a QueryExpansionInfo. + * @implements IQueryExpansionInfo + * @constructor + * @param {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + */ + function QueryExpansionInfo(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]]; + } + + /** + * QueryExpansionInfo expandedQuery. + * @member {boolean} expandedQuery + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.expandedQuery = false; + + /** + * QueryExpansionInfo pinnedResultCount. + * @member {number|Long} pinnedResultCount + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.pinnedResultCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2.SearchResponse.QueryExpansionInfo} QueryExpansionInfo instance + */ + QueryExpansionInfo.create = function create(properties) { + return new QueryExpansionInfo(properties); + }; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.expandedQuery != null && Object.hasOwnProperty.call(message, "expandedQuery")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.expandedQuery); + if (message.pinnedResultCount != null && Object.hasOwnProperty.call(message, "pinnedResultCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.pinnedResultCount); + return writer; + }; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.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.cloud.retail.v2.SearchResponse.QueryExpansionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.expandedQuery = reader.bool(); + break; + } + case 2: { + message.pinnedResultCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionInfo message. + * @function verify + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + if (typeof message.expandedQuery !== "boolean") + return "expandedQuery: boolean expected"; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (!$util.isInteger(message.pinnedResultCount) && !(message.pinnedResultCount && $util.isInteger(message.pinnedResultCount.low) && $util.isInteger(message.pinnedResultCount.high))) + return "pinnedResultCount: integer|Long expected"; + return null; + }; + + /** + * Creates a QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + */ + QueryExpansionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo) + return object; + var message = new $root.google.cloud.retail.v2.SearchResponse.QueryExpansionInfo(); + if (object.expandedQuery != null) + message.expandedQuery = Boolean(object.expandedQuery); + if (object.pinnedResultCount != null) + if ($util.Long) + (message.pinnedResultCount = $util.Long.fromValue(object.pinnedResultCount)).unsigned = false; + else if (typeof object.pinnedResultCount === "string") + message.pinnedResultCount = parseInt(object.pinnedResultCount, 10); + else if (typeof object.pinnedResultCount === "number") + message.pinnedResultCount = object.pinnedResultCount; + else if (typeof object.pinnedResultCount === "object") + message.pinnedResultCount = new $util.LongBits(object.pinnedResultCount.low >>> 0, object.pinnedResultCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2.SearchResponse.QueryExpansionInfo} message QueryExpansionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.expandedQuery = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.pinnedResultCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.pinnedResultCount = options.longs === String ? "0" : 0; + } + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + object.expandedQuery = message.expandedQuery; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (typeof message.pinnedResultCount === "number") + object.pinnedResultCount = options.longs === String ? String(message.pinnedResultCount) : message.pinnedResultCount; + else + object.pinnedResultCount = options.longs === String ? $util.Long.prototype.toString.call(message.pinnedResultCount) : options.longs === Number ? new $util.LongBits(message.pinnedResultCount.low >>> 0, message.pinnedResultCount.high >>> 0).toNumber() : message.pinnedResultCount; + return object; + }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2.SearchResponse.QueryExpansionInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.SearchResponse.QueryExpansionInfo"; + }; + + return QueryExpansionInfo; + })(); + + return SearchResponse; + })(); + + v2.ServingConfig = (function() { + + /** + * Properties of a ServingConfig. + * @memberof google.cloud.retail.v2 + * @interface IServingConfig + * @property {string|null} [name] ServingConfig name + * @property {string|null} [displayName] ServingConfig displayName + * @property {string|null} [modelId] ServingConfig modelId + * @property {string|null} [priceRerankingLevel] ServingConfig priceRerankingLevel + * @property {Array.|null} [facetControlIds] ServingConfig facetControlIds + * @property {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] ServingConfig dynamicFacetSpec + * @property {Array.|null} [boostControlIds] ServingConfig boostControlIds + * @property {Array.|null} [filterControlIds] ServingConfig filterControlIds + * @property {Array.|null} [redirectControlIds] ServingConfig redirectControlIds + * @property {Array.|null} [twowaySynonymsControlIds] ServingConfig twowaySynonymsControlIds + * @property {Array.|null} [onewaySynonymsControlIds] ServingConfig onewaySynonymsControlIds + * @property {Array.|null} [doNotAssociateControlIds] ServingConfig doNotAssociateControlIds + * @property {Array.|null} [replacementControlIds] ServingConfig replacementControlIds + * @property {Array.|null} [ignoreControlIds] ServingConfig ignoreControlIds + * @property {string|null} [diversityLevel] ServingConfig diversityLevel + * @property {string|null} [enableCategoryFilterLevel] ServingConfig enableCategoryFilterLevel + * @property {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] ServingConfig personalizationSpec + * @property {Array.|null} [solutionTypes] ServingConfig solutionTypes + */ + + /** + * Constructs a new ServingConfig. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ServingConfig. + * @implements IServingConfig + * @constructor + * @param {google.cloud.retail.v2.IServingConfig=} [properties] Properties to set + */ + function ServingConfig(properties) { + this.facetControlIds = []; + this.boostControlIds = []; + this.filterControlIds = []; + this.redirectControlIds = []; + this.twowaySynonymsControlIds = []; + this.onewaySynonymsControlIds = []; + this.doNotAssociateControlIds = []; + this.replacementControlIds = []; + this.ignoreControlIds = []; + this.solutionTypes = []; + 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]]; + } + + /** + * ServingConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.name = ""; + + /** + * ServingConfig displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.displayName = ""; + + /** + * ServingConfig modelId. + * @member {string} modelId + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.modelId = ""; + + /** + * ServingConfig priceRerankingLevel. + * @member {string} priceRerankingLevel + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.priceRerankingLevel = ""; + + /** + * ServingConfig facetControlIds. + * @member {Array.} facetControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.facetControlIds = $util.emptyArray; + + /** + * ServingConfig dynamicFacetSpec. + * @member {google.cloud.retail.v2.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.dynamicFacetSpec = null; + + /** + * ServingConfig boostControlIds. + * @member {Array.} boostControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.boostControlIds = $util.emptyArray; + + /** + * ServingConfig filterControlIds. + * @member {Array.} filterControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.filterControlIds = $util.emptyArray; + + /** + * ServingConfig redirectControlIds. + * @member {Array.} redirectControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.redirectControlIds = $util.emptyArray; + + /** + * ServingConfig twowaySynonymsControlIds. + * @member {Array.} twowaySynonymsControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.twowaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig onewaySynonymsControlIds. + * @member {Array.} onewaySynonymsControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.onewaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig doNotAssociateControlIds. + * @member {Array.} doNotAssociateControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.doNotAssociateControlIds = $util.emptyArray; + + /** + * ServingConfig replacementControlIds. + * @member {Array.} replacementControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.replacementControlIds = $util.emptyArray; + + /** + * ServingConfig ignoreControlIds. + * @member {Array.} ignoreControlIds + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.ignoreControlIds = $util.emptyArray; + + /** + * ServingConfig diversityLevel. + * @member {string} diversityLevel + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.diversityLevel = ""; + + /** + * ServingConfig enableCategoryFilterLevel. + * @member {string} enableCategoryFilterLevel + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.enableCategoryFilterLevel = ""; + + /** + * ServingConfig personalizationSpec. + * @member {google.cloud.retail.v2.SearchRequest.IPersonalizationSpec|null|undefined} personalizationSpec + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.personalizationSpec = null; + + /** + * ServingConfig solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + */ + ServingConfig.prototype.solutionTypes = $util.emptyArray; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {google.cloud.retail.v2.IServingConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ServingConfig} ServingConfig instance + */ + ServingConfig.create = function create(properties) { + return new ServingConfig(properties); + }; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2.ServingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {google.cloud.retail.v2.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.modelId != null && Object.hasOwnProperty.call(message, "modelId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.modelId); + if (message.priceRerankingLevel != null && Object.hasOwnProperty.call(message, "priceRerankingLevel")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.priceRerankingLevel); + if (message.facetControlIds != null && message.facetControlIds.length) + for (var i = 0; i < message.facetControlIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.facetControlIds[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.boostControlIds != null && message.boostControlIds.length) + for (var i = 0; i < message.boostControlIds.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.boostControlIds[i]); + if (message.diversityLevel != null && Object.hasOwnProperty.call(message, "diversityLevel")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.diversityLevel); + if (message.filterControlIds != null && message.filterControlIds.length) + for (var i = 0; i < message.filterControlIds.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.filterControlIds[i]); + if (message.redirectControlIds != null && message.redirectControlIds.length) + for (var i = 0; i < message.redirectControlIds.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectControlIds[i]); + if (message.onewaySynonymsControlIds != null && message.onewaySynonymsControlIds.length) + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.onewaySynonymsControlIds[i]); + if (message.doNotAssociateControlIds != null && message.doNotAssociateControlIds.length) + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.doNotAssociateControlIds[i]); + if (message.replacementControlIds != null && message.replacementControlIds.length) + for (var i = 0; i < message.replacementControlIds.length; ++i) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.replacementControlIds[i]); + if (message.ignoreControlIds != null && message.ignoreControlIds.length) + for (var i = 0; i < message.ignoreControlIds.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.ignoreControlIds[i]); + if (message.enableCategoryFilterLevel != null && Object.hasOwnProperty.call(message, "enableCategoryFilterLevel")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.enableCategoryFilterLevel); + if (message.twowaySynonymsControlIds != null && message.twowaySynonymsControlIds.length) + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + writer.uint32(/* id 18, wireType 2 =*/146).string(message.twowaySynonymsControlIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 19, wireType 2 =*/154).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) + $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ServingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {google.cloud.retail.v2.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.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.cloud.retail.v2.ServingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 3: { + message.modelId = reader.string(); + break; + } + case 4: { + message.priceRerankingLevel = reader.string(); + break; + } + case 5: { + if (!(message.facetControlIds && message.facetControlIds.length)) + message.facetControlIds = []; + message.facetControlIds.push(reader.string()); + break; + } + case 6: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 7: { + if (!(message.boostControlIds && message.boostControlIds.length)) + message.boostControlIds = []; + message.boostControlIds.push(reader.string()); + break; + } + case 9: { + if (!(message.filterControlIds && message.filterControlIds.length)) + message.filterControlIds = []; + message.filterControlIds.push(reader.string()); + break; + } + case 10: { + if (!(message.redirectControlIds && message.redirectControlIds.length)) + message.redirectControlIds = []; + message.redirectControlIds.push(reader.string()); + break; + } + case 18: { + if (!(message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length)) + message.twowaySynonymsControlIds = []; + message.twowaySynonymsControlIds.push(reader.string()); + break; + } + case 12: { + if (!(message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length)) + message.onewaySynonymsControlIds = []; + message.onewaySynonymsControlIds.push(reader.string()); + break; + } + case 13: { + if (!(message.doNotAssociateControlIds && message.doNotAssociateControlIds.length)) + message.doNotAssociateControlIds = []; + message.doNotAssociateControlIds.push(reader.string()); + break; + } + case 14: { + if (!(message.replacementControlIds && message.replacementControlIds.length)) + message.replacementControlIds = []; + message.replacementControlIds.push(reader.string()); + break; + } + case 15: { + if (!(message.ignoreControlIds && message.ignoreControlIds.length)) + message.ignoreControlIds = []; + message.ignoreControlIds.push(reader.string()); + break; + } + case 8: { + message.diversityLevel = reader.string(); + break; + } + case 16: { + message.enableCategoryFilterLevel = reader.string(); + break; + } + case 21: { + message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); + break; + } + case 19: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServingConfig message. + * @function verify + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServingConfig.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.modelId != null && message.hasOwnProperty("modelId")) + if (!$util.isString(message.modelId)) + return "modelId: string expected"; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + if (!$util.isString(message.priceRerankingLevel)) + return "priceRerankingLevel: string expected"; + if (message.facetControlIds != null && message.hasOwnProperty("facetControlIds")) { + if (!Array.isArray(message.facetControlIds)) + return "facetControlIds: array expected"; + for (var i = 0; i < message.facetControlIds.length; ++i) + if (!$util.isString(message.facetControlIds[i])) + return "facetControlIds: string[] expected"; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostControlIds != null && message.hasOwnProperty("boostControlIds")) { + if (!Array.isArray(message.boostControlIds)) + return "boostControlIds: array expected"; + for (var i = 0; i < message.boostControlIds.length; ++i) + if (!$util.isString(message.boostControlIds[i])) + return "boostControlIds: string[] expected"; + } + if (message.filterControlIds != null && message.hasOwnProperty("filterControlIds")) { + if (!Array.isArray(message.filterControlIds)) + return "filterControlIds: array expected"; + for (var i = 0; i < message.filterControlIds.length; ++i) + if (!$util.isString(message.filterControlIds[i])) + return "filterControlIds: string[] expected"; + } + if (message.redirectControlIds != null && message.hasOwnProperty("redirectControlIds")) { + if (!Array.isArray(message.redirectControlIds)) + return "redirectControlIds: array expected"; + for (var i = 0; i < message.redirectControlIds.length; ++i) + if (!$util.isString(message.redirectControlIds[i])) + return "redirectControlIds: string[] expected"; + } + if (message.twowaySynonymsControlIds != null && message.hasOwnProperty("twowaySynonymsControlIds")) { + if (!Array.isArray(message.twowaySynonymsControlIds)) + return "twowaySynonymsControlIds: array expected"; + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + if (!$util.isString(message.twowaySynonymsControlIds[i])) + return "twowaySynonymsControlIds: string[] expected"; + } + if (message.onewaySynonymsControlIds != null && message.hasOwnProperty("onewaySynonymsControlIds")) { + if (!Array.isArray(message.onewaySynonymsControlIds)) + return "onewaySynonymsControlIds: array expected"; + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + if (!$util.isString(message.onewaySynonymsControlIds[i])) + return "onewaySynonymsControlIds: string[] expected"; + } + if (message.doNotAssociateControlIds != null && message.hasOwnProperty("doNotAssociateControlIds")) { + if (!Array.isArray(message.doNotAssociateControlIds)) + return "doNotAssociateControlIds: array expected"; + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + if (!$util.isString(message.doNotAssociateControlIds[i])) + return "doNotAssociateControlIds: string[] expected"; + } + if (message.replacementControlIds != null && message.hasOwnProperty("replacementControlIds")) { + if (!Array.isArray(message.replacementControlIds)) + return "replacementControlIds: array expected"; + for (var i = 0; i < message.replacementControlIds.length; ++i) + if (!$util.isString(message.replacementControlIds[i])) + return "replacementControlIds: string[] expected"; + } + if (message.ignoreControlIds != null && message.hasOwnProperty("ignoreControlIds")) { + if (!Array.isArray(message.ignoreControlIds)) + return "ignoreControlIds: array expected"; + for (var i = 0; i < message.ignoreControlIds.length; ++i) + if (!$util.isString(message.ignoreControlIds[i])) + return "ignoreControlIds: string[] expected"; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + if (!$util.isString(message.diversityLevel)) + return "diversityLevel: string expected"; + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + if (!$util.isString(message.enableCategoryFilterLevel)) + return "enableCategoryFilterLevel: string expected"; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) { + var error = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.verify(message.personalizationSpec); + if (error) + return "personalizationSpec." + error; + } + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a ServingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ServingConfig} ServingConfig + */ + ServingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ServingConfig) + return object; + var message = new $root.google.cloud.retail.v2.ServingConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.modelId != null) + message.modelId = String(object.modelId); + if (object.priceRerankingLevel != null) + message.priceRerankingLevel = String(object.priceRerankingLevel); + if (object.facetControlIds) { + if (!Array.isArray(object.facetControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.facetControlIds: array expected"); + message.facetControlIds = []; + for (var i = 0; i < object.facetControlIds.length; ++i) + message.facetControlIds[i] = String(object.facetControlIds[i]); + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2.ServingConfig.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostControlIds) { + if (!Array.isArray(object.boostControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.boostControlIds: array expected"); + message.boostControlIds = []; + for (var i = 0; i < object.boostControlIds.length; ++i) + message.boostControlIds[i] = String(object.boostControlIds[i]); + } + if (object.filterControlIds) { + if (!Array.isArray(object.filterControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.filterControlIds: array expected"); + message.filterControlIds = []; + for (var i = 0; i < object.filterControlIds.length; ++i) + message.filterControlIds[i] = String(object.filterControlIds[i]); + } + if (object.redirectControlIds) { + if (!Array.isArray(object.redirectControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.redirectControlIds: array expected"); + message.redirectControlIds = []; + for (var i = 0; i < object.redirectControlIds.length; ++i) + message.redirectControlIds[i] = String(object.redirectControlIds[i]); + } + if (object.twowaySynonymsControlIds) { + if (!Array.isArray(object.twowaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.twowaySynonymsControlIds: array expected"); + message.twowaySynonymsControlIds = []; + for (var i = 0; i < object.twowaySynonymsControlIds.length; ++i) + message.twowaySynonymsControlIds[i] = String(object.twowaySynonymsControlIds[i]); + } + if (object.onewaySynonymsControlIds) { + if (!Array.isArray(object.onewaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.onewaySynonymsControlIds: array expected"); + message.onewaySynonymsControlIds = []; + for (var i = 0; i < object.onewaySynonymsControlIds.length; ++i) + message.onewaySynonymsControlIds[i] = String(object.onewaySynonymsControlIds[i]); + } + if (object.doNotAssociateControlIds) { + if (!Array.isArray(object.doNotAssociateControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.doNotAssociateControlIds: array expected"); + message.doNotAssociateControlIds = []; + for (var i = 0; i < object.doNotAssociateControlIds.length; ++i) + message.doNotAssociateControlIds[i] = String(object.doNotAssociateControlIds[i]); + } + if (object.replacementControlIds) { + if (!Array.isArray(object.replacementControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.replacementControlIds: array expected"); + message.replacementControlIds = []; + for (var i = 0; i < object.replacementControlIds.length; ++i) + message.replacementControlIds[i] = String(object.replacementControlIds[i]); + } + if (object.ignoreControlIds) { + if (!Array.isArray(object.ignoreControlIds)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.ignoreControlIds: array expected"); + message.ignoreControlIds = []; + for (var i = 0; i < object.ignoreControlIds.length; ++i) + message.ignoreControlIds[i] = String(object.ignoreControlIds[i]); + } + if (object.diversityLevel != null) + message.diversityLevel = String(object.diversityLevel); + if (object.enableCategoryFilterLevel != null) + message.enableCategoryFilterLevel = String(object.enableCategoryFilterLevel); + if (object.personalizationSpec != null) { + if (typeof object.personalizationSpec !== "object") + throw TypeError(".google.cloud.retail.v2.ServingConfig.personalizationSpec: object expected"); + message.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); + } + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2.ServingConfig.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {google.cloud.retail.v2.ServingConfig} message ServingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetControlIds = []; + object.boostControlIds = []; + object.filterControlIds = []; + object.redirectControlIds = []; + object.onewaySynonymsControlIds = []; + object.doNotAssociateControlIds = []; + object.replacementControlIds = []; + object.ignoreControlIds = []; + object.twowaySynonymsControlIds = []; + object.solutionTypes = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.modelId = ""; + object.priceRerankingLevel = ""; + object.dynamicFacetSpec = null; + object.diversityLevel = ""; + object.enableCategoryFilterLevel = ""; + object.personalizationSpec = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.modelId != null && message.hasOwnProperty("modelId")) + object.modelId = message.modelId; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + object.priceRerankingLevel = message.priceRerankingLevel; + if (message.facetControlIds && message.facetControlIds.length) { + object.facetControlIds = []; + for (var j = 0; j < message.facetControlIds.length; ++j) + object.facetControlIds[j] = message.facetControlIds[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.boostControlIds && message.boostControlIds.length) { + object.boostControlIds = []; + for (var j = 0; j < message.boostControlIds.length; ++j) + object.boostControlIds[j] = message.boostControlIds[j]; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + object.diversityLevel = message.diversityLevel; + if (message.filterControlIds && message.filterControlIds.length) { + object.filterControlIds = []; + for (var j = 0; j < message.filterControlIds.length; ++j) + object.filterControlIds[j] = message.filterControlIds[j]; + } + if (message.redirectControlIds && message.redirectControlIds.length) { + object.redirectControlIds = []; + for (var j = 0; j < message.redirectControlIds.length; ++j) + object.redirectControlIds[j] = message.redirectControlIds[j]; + } + if (message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length) { + object.onewaySynonymsControlIds = []; + for (var j = 0; j < message.onewaySynonymsControlIds.length; ++j) + object.onewaySynonymsControlIds[j] = message.onewaySynonymsControlIds[j]; + } + if (message.doNotAssociateControlIds && message.doNotAssociateControlIds.length) { + object.doNotAssociateControlIds = []; + for (var j = 0; j < message.doNotAssociateControlIds.length; ++j) + object.doNotAssociateControlIds[j] = message.doNotAssociateControlIds[j]; + } + if (message.replacementControlIds && message.replacementControlIds.length) { + object.replacementControlIds = []; + for (var j = 0; j < message.replacementControlIds.length; ++j) + object.replacementControlIds[j] = message.replacementControlIds[j]; + } + if (message.ignoreControlIds && message.ignoreControlIds.length) { + object.ignoreControlIds = []; + for (var j = 0; j < message.ignoreControlIds.length; ++j) + object.ignoreControlIds[j] = message.ignoreControlIds[j]; + } + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + object.enableCategoryFilterLevel = message.enableCategoryFilterLevel; + if (message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length) { + object.twowaySynonymsControlIds = []; + for (var j = 0; j < message.twowaySynonymsControlIds.length; ++j) + object.twowaySynonymsControlIds[j] = message.twowaySynonymsControlIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) + object.personalizationSpec = $root.google.cloud.retail.v2.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + return object; + }; + + /** + * Converts this ServingConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ServingConfig + * @instance + * @returns {Object.} JSON object + */ + ServingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServingConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ServingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ServingConfig"; + }; + + return ServingConfig; + })(); + + v2.ServingConfigService = (function() { + + /** + * Constructs a new ServingConfigService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ServingConfigService + * @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 ServingConfigService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ServingConfigService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ServingConfigService; + + /** + * Creates new ServingConfigService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.ServingConfigService + * @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 {ServingConfigService} RPC service. Useful where requests and/or responses are streamed. + */ + ServingConfigService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|createServingConfig}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef CreateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ServingConfig} [response] ServingConfig + */ + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.CreateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.createServingConfig = function createServingConfig(request, callback) { + return this.rpcCall(createServingConfig, $root.google.cloud.retail.v2.CreateServingConfigRequest, $root.google.cloud.retail.v2.ServingConfig, request, callback); + }, "name", { value: "CreateServingConfig" }); + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|deleteServingConfig}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef DeleteServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.DeleteServingConfigCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.deleteServingConfig = function deleteServingConfig(request, callback) { + return this.rpcCall(deleteServingConfig, $root.google.cloud.retail.v2.DeleteServingConfigRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteServingConfig" }); + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|updateServingConfig}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef UpdateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ServingConfig} [response] ServingConfig + */ + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.UpdateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.updateServingConfig = function updateServingConfig(request, callback) { + return this.rpcCall(updateServingConfig, $root.google.cloud.retail.v2.UpdateServingConfigRequest, $root.google.cloud.retail.v2.ServingConfig, request, callback); + }, "name", { value: "UpdateServingConfig" }); + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|getServingConfig}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef GetServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ServingConfig} [response] ServingConfig + */ + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.GetServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.getServingConfig = function getServingConfig(request, callback) { + return this.rpcCall(getServingConfig, $root.google.cloud.retail.v2.GetServingConfigRequest, $root.google.cloud.retail.v2.ServingConfig, request, callback); + }, "name", { value: "GetServingConfig" }); + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|listServingConfigs}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef ListServingConfigsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ListServingConfigsResponse} [response] ListServingConfigsResponse + */ + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.ListServingConfigsCallback} callback Node-style callback called with the error, if any, and ListServingConfigsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.listServingConfigs = function listServingConfigs(request, callback) { + return this.rpcCall(listServingConfigs, $root.google.cloud.retail.v2.ListServingConfigsRequest, $root.google.cloud.retail.v2.ListServingConfigsResponse, request, callback); + }, "name", { value: "ListServingConfigs" }); + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|addControl}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef AddControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ServingConfig} [response] ServingConfig + */ + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IAddControlRequest} request AddControlRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.AddControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.addControl = function addControl(request, callback) { + return this.rpcCall(addControl, $root.google.cloud.retail.v2.AddControlRequest, $root.google.cloud.retail.v2.ServingConfig, request, callback); + }, "name", { value: "AddControl" }); + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IAddControlRequest} request AddControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.ServingConfigService|removeControl}. + * @memberof google.cloud.retail.v2.ServingConfigService + * @typedef RemoveControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.ServingConfig} [response] ServingConfig + */ + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @param {google.cloud.retail.v2.ServingConfigService.RemoveControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.removeControl = function removeControl(request, callback) { + return this.rpcCall(removeControl, $root.google.cloud.retail.v2.RemoveControlRequest, $root.google.cloud.retail.v2.ServingConfig, request, callback); + }, "name", { value: "RemoveControl" }); + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2.ServingConfigService + * @instance + * @param {google.cloud.retail.v2.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ServingConfigService; + })(); + + v2.CreateServingConfigRequest = (function() { + + /** + * Properties of a CreateServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface ICreateServingConfigRequest + * @property {string|null} [parent] CreateServingConfigRequest parent + * @property {google.cloud.retail.v2.IServingConfig|null} [servingConfig] CreateServingConfigRequest servingConfig + * @property {string|null} [servingConfigId] CreateServingConfigRequest servingConfigId + */ + + /** + * Constructs a new CreateServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CreateServingConfigRequest. + * @implements ICreateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2.ICreateServingConfigRequest=} [properties] Properties to set + */ + function CreateServingConfigRequest(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]]; + } + + /** + * CreateServingConfigRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.parent = ""; + + /** + * CreateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfig = null; + + /** + * CreateServingConfigRequest servingConfigId. + * @member {string} servingConfigId + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfigId = ""; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.ICreateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CreateServingConfigRequest} CreateServingConfigRequest instance + */ + CreateServingConfigRequest.create = function create(properties) { + return new CreateServingConfigRequest(properties); + }; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.CreateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.servingConfigId != null && Object.hasOwnProperty.call(message, "servingConfigId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.servingConfigId); + return writer; + }; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CreateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.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.cloud.retail.v2.CreateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.servingConfig = $root.google.cloud.retail.v2.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.servingConfigId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + if (!$util.isString(message.servingConfigId)) + return "servingConfigId: string expected"; + return null; + }; + + /** + * Creates a CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CreateServingConfigRequest} CreateServingConfigRequest + */ + CreateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CreateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.CreateServingConfigRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2.CreateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2.ServingConfig.fromObject(object.servingConfig); + } + if (object.servingConfigId != null) + message.servingConfigId = String(object.servingConfigId); + return message; + }; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.CreateServingConfigRequest} message CreateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.servingConfig = null; + object.servingConfigId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2.ServingConfig.toObject(message.servingConfig, options); + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + object.servingConfigId = message.servingConfigId; + return object; + }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + CreateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CreateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CreateServingConfigRequest"; + }; + + return CreateServingConfigRequest; + })(); + + v2.UpdateServingConfigRequest = (function() { + + /** + * Properties of an UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IUpdateServingConfigRequest + * @property {google.cloud.retail.v2.IServingConfig|null} [servingConfig] UpdateServingConfigRequest servingConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateServingConfigRequest updateMask + */ + + /** + * Constructs a new UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an UpdateServingConfigRequest. + * @implements IUpdateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest=} [properties] Properties to set + */ + function UpdateServingConfigRequest(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]]; + } + + /** + * UpdateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.servingConfig = null; + + /** + * UpdateServingConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.UpdateServingConfigRequest} UpdateServingConfigRequest instance + */ + UpdateServingConfigRequest.create = function create(properties) { + return new UpdateServingConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.UpdateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.UpdateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.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.cloud.retail.v2.UpdateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = $root.google.cloud.retail.v2.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.UpdateServingConfigRequest} UpdateServingConfigRequest + */ + UpdateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.UpdateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.UpdateServingConfigRequest(); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2.ServingConfig.fromObject(object.servingConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2.UpdateServingConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2.UpdateServingConfigRequest} message UpdateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = null; + object.updateMask = null; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2.ServingConfig.toObject(message.servingConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.UpdateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.UpdateServingConfigRequest"; + }; + + return UpdateServingConfigRequest; + })(); + + v2.DeleteServingConfigRequest = (function() { + + /** + * Properties of a DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IDeleteServingConfigRequest + * @property {string|null} [name] DeleteServingConfigRequest name + */ + + /** + * Constructs a new DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a DeleteServingConfigRequest. + * @implements IDeleteServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest=} [properties] Properties to set + */ + function DeleteServingConfigRequest(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]]; + } + + /** + * DeleteServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @instance + */ + DeleteServingConfigRequest.prototype.name = ""; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.DeleteServingConfigRequest} DeleteServingConfigRequest instance + */ + DeleteServingConfigRequest.create = function create(properties) { + return new DeleteServingConfigRequest(properties); + }; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.DeleteServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.DeleteServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.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.cloud.retail.v2.DeleteServingConfigRequest(); + 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 DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.DeleteServingConfigRequest} DeleteServingConfigRequest + */ + DeleteServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.DeleteServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.DeleteServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2.DeleteServingConfigRequest} message DeleteServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.DeleteServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.DeleteServingConfigRequest"; + }; + + return DeleteServingConfigRequest; + })(); + + v2.GetServingConfigRequest = (function() { + + /** + * Properties of a GetServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @interface IGetServingConfigRequest + * @property {string|null} [name] GetServingConfigRequest name + */ + + /** + * Constructs a new GetServingConfigRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a GetServingConfigRequest. + * @implements IGetServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2.IGetServingConfigRequest=} [properties] Properties to set + */ + function GetServingConfigRequest(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]]; + } + + /** + * GetServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @instance + */ + GetServingConfigRequest.prototype.name = ""; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.GetServingConfigRequest} GetServingConfigRequest instance + */ + GetServingConfigRequest.create = function create(properties) { + return new GetServingConfigRequest(properties); + }; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2.GetServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.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 GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.GetServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.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.cloud.retail.v2.GetServingConfigRequest(); + 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 GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetServingConfigRequest.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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.GetServingConfigRequest} GetServingConfigRequest + */ + GetServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.GetServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2.GetServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2.GetServingConfigRequest} message GetServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetServingConfigRequest.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 GetServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.GetServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.GetServingConfigRequest"; + }; + + return GetServingConfigRequest; + })(); + + v2.ListServingConfigsRequest = (function() { + + /** + * Properties of a ListServingConfigsRequest. + * @memberof google.cloud.retail.v2 + * @interface IListServingConfigsRequest + * @property {string|null} [parent] ListServingConfigsRequest parent + * @property {number|null} [pageSize] ListServingConfigsRequest pageSize + * @property {string|null} [pageToken] ListServingConfigsRequest pageToken + */ + + /** + * Constructs a new ListServingConfigsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListServingConfigsRequest. + * @implements IListServingConfigsRequest + * @constructor + * @param {google.cloud.retail.v2.IListServingConfigsRequest=} [properties] Properties to set + */ + function ListServingConfigsRequest(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]]; + } + + /** + * ListServingConfigsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.parent = ""; + + /** + * ListServingConfigsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageSize = 0; + + /** + * ListServingConfigsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2.IListServingConfigsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListServingConfigsRequest} ListServingConfigsRequest instance + */ + ListServingConfigsRequest.create = function create(properties) { + return new ListServingConfigsRequest(properties); + }; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.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.cloud.retail.v2.ListServingConfigsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListServingConfigsRequest} ListServingConfigsRequest + */ + ListServingConfigsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListServingConfigsRequest) + return object; + var message = new $root.google.cloud.retail.v2.ListServingConfigsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListServingConfigsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2.ListServingConfigsRequest} message ListServingConfigsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListServingConfigsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListServingConfigsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListServingConfigsRequest"; + }; + + return ListServingConfigsRequest; + })(); + + v2.ListServingConfigsResponse = (function() { + + /** + * Properties of a ListServingConfigsResponse. + * @memberof google.cloud.retail.v2 + * @interface IListServingConfigsResponse + * @property {Array.|null} [servingConfigs] ListServingConfigsResponse servingConfigs + * @property {string|null} [nextPageToken] ListServingConfigsResponse nextPageToken + */ + + /** + * Constructs a new ListServingConfigsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a ListServingConfigsResponse. + * @implements IListServingConfigsResponse + * @constructor + * @param {google.cloud.retail.v2.IListServingConfigsResponse=} [properties] Properties to set + */ + function ListServingConfigsResponse(properties) { + this.servingConfigs = []; + 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]]; + } + + /** + * ListServingConfigsResponse servingConfigs. + * @member {Array.} servingConfigs + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.servingConfigs = $util.emptyArray; + + /** + * ListServingConfigsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2.IListServingConfigsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.ListServingConfigsResponse} ListServingConfigsResponse instance + */ + ListServingConfigsResponse.create = function create(properties) { + return new ListServingConfigsResponse(properties); + }; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigs != null && message.servingConfigs.length) + for (var i = 0; i < message.servingConfigs.length; ++i) + $root.google.cloud.retail.v2.ServingConfig.encode(message.servingConfigs[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 ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.ListServingConfigsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.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.cloud.retail.v2.ListServingConfigsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.servingConfigs && message.servingConfigs.length)) + message.servingConfigs = []; + message.servingConfigs.push($root.google.cloud.retail.v2.ServingConfig.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfigs != null && message.hasOwnProperty("servingConfigs")) { + if (!Array.isArray(message.servingConfigs)) + return "servingConfigs: array expected"; + for (var i = 0; i < message.servingConfigs.length; ++i) { + var error = $root.google.cloud.retail.v2.ServingConfig.verify(message.servingConfigs[i]); + if (error) + return "servingConfigs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.ListServingConfigsResponse} ListServingConfigsResponse + */ + ListServingConfigsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.ListServingConfigsResponse) + return object; + var message = new $root.google.cloud.retail.v2.ListServingConfigsResponse(); + if (object.servingConfigs) { + if (!Array.isArray(object.servingConfigs)) + throw TypeError(".google.cloud.retail.v2.ListServingConfigsResponse.servingConfigs: array expected"); + message.servingConfigs = []; + for (var i = 0; i < object.servingConfigs.length; ++i) { + if (typeof object.servingConfigs[i] !== "object") + throw TypeError(".google.cloud.retail.v2.ListServingConfigsResponse.servingConfigs: object expected"); + message.servingConfigs[i] = $root.google.cloud.retail.v2.ServingConfig.fromObject(object.servingConfigs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2.ListServingConfigsResponse} message ListServingConfigsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.servingConfigs && message.servingConfigs.length) { + object.servingConfigs = []; + for (var j = 0; j < message.servingConfigs.length; ++j) + object.servingConfigs[j] = $root.google.cloud.retail.v2.ServingConfig.toObject(message.servingConfigs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.ListServingConfigsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.ListServingConfigsResponse"; + }; + + return ListServingConfigsResponse; + })(); + + v2.AddControlRequest = (function() { + + /** + * Properties of an AddControlRequest. + * @memberof google.cloud.retail.v2 + * @interface IAddControlRequest + * @property {string|null} [servingConfig] AddControlRequest servingConfig + * @property {string|null} [controlId] AddControlRequest controlId + */ + + /** + * Constructs a new AddControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents an AddControlRequest. + * @implements IAddControlRequest + * @constructor + * @param {google.cloud.retail.v2.IAddControlRequest=} [properties] Properties to set + */ + function AddControlRequest(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]]; + } + + /** + * AddControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2.AddControlRequest + * @instance + */ + AddControlRequest.prototype.servingConfig = ""; + + /** + * AddControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2.AddControlRequest + * @instance + */ + AddControlRequest.prototype.controlId = ""; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {google.cloud.retail.v2.IAddControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.AddControlRequest} AddControlRequest instance + */ + AddControlRequest.create = function create(properties) { + return new AddControlRequest(properties); + }; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2.AddControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {google.cloud.retail.v2.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.AddControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {google.cloud.retail.v2.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.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.cloud.retail.v2.AddControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates an AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.AddControlRequest} AddControlRequest + */ + AddControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.AddControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.AddControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {google.cloud.retail.v2.AddControlRequest} message AddControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this AddControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.AddControlRequest + * @instance + * @returns {Object.} JSON object + */ + AddControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.AddControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.AddControlRequest"; + }; + + return AddControlRequest; + })(); + + v2.RemoveControlRequest = (function() { + + /** + * Properties of a RemoveControlRequest. + * @memberof google.cloud.retail.v2 + * @interface IRemoveControlRequest + * @property {string|null} [servingConfig] RemoveControlRequest servingConfig + * @property {string|null} [controlId] RemoveControlRequest controlId + */ + + /** + * Constructs a new RemoveControlRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RemoveControlRequest. + * @implements IRemoveControlRequest + * @constructor + * @param {google.cloud.retail.v2.IRemoveControlRequest=} [properties] Properties to set + */ + function RemoveControlRequest(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]]; + } + + /** + * RemoveControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.servingConfig = ""; + + /** + * RemoveControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.controlId = ""; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2.IRemoveControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RemoveControlRequest} RemoveControlRequest instance + */ + RemoveControlRequest.create = function create(properties) { + return new RemoveControlRequest(properties); + }; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2.RemoveControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RemoveControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.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.cloud.retail.v2.RemoveControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RemoveControlRequest} RemoveControlRequest + */ + RemoveControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RemoveControlRequest) + return object; + var message = new $root.google.cloud.retail.v2.RemoveControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2.RemoveControlRequest} message RemoveControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this RemoveControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RemoveControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RemoveControlRequest"; + }; + + return RemoveControlRequest; + })(); + + v2.UserEventService = (function() { + + /** + * Constructs a new UserEventService service. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a UserEventService + * @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 UserEventService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (UserEventService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = UserEventService; + + /** + * Creates new UserEventService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2.UserEventService + * @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 {UserEventService} RPC service. Useful where requests and/or responses are streamed. + */ + UserEventService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|writeUserEvent}. + * @memberof google.cloud.retail.v2.UserEventService + * @typedef WriteUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2.UserEvent} [response] UserEvent + */ + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @param {google.cloud.retail.v2.UserEventService.WriteUserEventCallback} callback Node-style callback called with the error, if any, and UserEvent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.writeUserEvent = function writeUserEvent(request, callback) { + return this.rpcCall(writeUserEvent, $root.google.cloud.retail.v2.WriteUserEventRequest, $root.google.cloud.retail.v2.UserEvent, request, callback); + }, "name", { value: "WriteUserEvent" }); + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|collectUserEvent}. + * @memberof google.cloud.retail.v2.UserEventService + * @typedef CollectUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.api.HttpBody} [response] HttpBody + */ + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @param {google.cloud.retail.v2.UserEventService.CollectUserEventCallback} callback Node-style callback called with the error, if any, and HttpBody + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.collectUserEvent = function collectUserEvent(request, callback) { + return this.rpcCall(collectUserEvent, $root.google.cloud.retail.v2.CollectUserEventRequest, $root.google.api.HttpBody, request, callback); + }, "name", { value: "CollectUserEvent" }); + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|purgeUserEvents}. + * @memberof google.cloud.retail.v2.UserEventService + * @typedef PurgeUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @param {google.cloud.retail.v2.UserEventService.PurgeUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.purgeUserEvents = function purgeUserEvents(request, callback) { + return this.rpcCall(purgeUserEvents, $root.google.cloud.retail.v2.PurgeUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "PurgeUserEvents" }); + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|importUserEvents}. + * @memberof google.cloud.retail.v2.UserEventService + * @typedef ImportUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @param {google.cloud.retail.v2.UserEventService.ImportUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.importUserEvents = function importUserEvents(request, callback) { + return this.rpcCall(importUserEvents, $root.google.cloud.retail.v2.ImportUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportUserEvents" }); + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2.UserEventService|rejoinUserEvents}. + * @memberof google.cloud.retail.v2.UserEventService + * @typedef RejoinUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @param {google.cloud.retail.v2.UserEventService.RejoinUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.rejoinUserEvents = function rejoinUserEvents(request, callback) { + return this.rpcCall(rejoinUserEvents, $root.google.cloud.retail.v2.RejoinUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RejoinUserEvents" }); + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2.UserEventService + * @instance + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return UserEventService; + })(); + + v2.WriteUserEventRequest = (function() { + + /** + * Properties of a WriteUserEventRequest. + * @memberof google.cloud.retail.v2 + * @interface IWriteUserEventRequest + * @property {string|null} [parent] WriteUserEventRequest parent + * @property {google.cloud.retail.v2.IUserEvent|null} [userEvent] WriteUserEventRequest userEvent + */ + + /** + * Constructs a new WriteUserEventRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a WriteUserEventRequest. + * @implements IWriteUserEventRequest + * @constructor + * @param {google.cloud.retail.v2.IWriteUserEventRequest=} [properties] Properties to set + */ + function WriteUserEventRequest(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]]; + } + + /** + * WriteUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.parent = ""; + + /** + * WriteUserEventRequest userEvent. + * @member {google.cloud.retail.v2.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.userEvent = null; + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2.IWriteUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.WriteUserEventRequest} WriteUserEventRequest instance + */ + WriteUserEventRequest.create = function create(properties) { + return new WriteUserEventRequest(properties); + }; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2.WriteUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.WriteUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.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.cloud.retail.v2.WriteUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2.UserEvent.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + return null; + }; + + /** + * Creates a WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.WriteUserEventRequest} WriteUserEventRequest + */ + WriteUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.WriteUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2.WriteUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2.WriteUserEventRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2.UserEvent.fromObject(object.userEvent); + } + return message; + }; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2.WriteUserEventRequest} message WriteUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2.UserEvent.toObject(message.userEvent, options); + return object; + }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + WriteUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WriteUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.WriteUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WriteUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.WriteUserEventRequest"; + }; + + return WriteUserEventRequest; + })(); + + v2.CollectUserEventRequest = (function() { + + /** + * Properties of a CollectUserEventRequest. + * @memberof google.cloud.retail.v2 + * @interface ICollectUserEventRequest + * @property {string|null} [parent] CollectUserEventRequest parent + * @property {string|null} [userEvent] CollectUserEventRequest userEvent + * @property {string|null} [uri] CollectUserEventRequest uri + * @property {number|Long|null} [ets] CollectUserEventRequest ets + */ + + /** + * Constructs a new CollectUserEventRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a CollectUserEventRequest. + * @implements ICollectUserEventRequest + * @constructor + * @param {google.cloud.retail.v2.ICollectUserEventRequest=} [properties] Properties to set + */ + function CollectUserEventRequest(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]]; + } + + /** + * CollectUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.parent = ""; + + /** + * CollectUserEventRequest userEvent. + * @member {string} userEvent + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.userEvent = ""; + + /** + * CollectUserEventRequest uri. + * @member {string} uri + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.uri = ""; + + /** + * CollectUserEventRequest ets. + * @member {number|Long} ets + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.ets = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2.ICollectUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.CollectUserEventRequest} CollectUserEventRequest instance + */ + CollectUserEventRequest.create = function create(properties) { + return new CollectUserEventRequest(properties); + }; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2.CollectUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.userEvent); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); + if (message.ets != null && Object.hasOwnProperty.call(message, "ets")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.ets); + return writer; + }; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.CollectUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.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.cloud.retail.v2.CollectUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = reader.string(); + break; + } + case 3: { + message.uri = reader.string(); + break; + } + case 4: { + message.ets = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CollectUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CollectUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + if (!$util.isString(message.userEvent)) + return "userEvent: string expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.ets != null && message.hasOwnProperty("ets")) + if (!$util.isInteger(message.ets) && !(message.ets && $util.isInteger(message.ets.low) && $util.isInteger(message.ets.high))) + return "ets: integer|Long expected"; + return null; + }; + + /** + * Creates a CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.CollectUserEventRequest} CollectUserEventRequest + */ + CollectUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.CollectUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2.CollectUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) + message.userEvent = String(object.userEvent); + if (object.uri != null) + message.uri = String(object.uri); + if (object.ets != null) + if ($util.Long) + (message.ets = $util.Long.fromValue(object.ets)).unsigned = false; + else if (typeof object.ets === "string") + message.ets = parseInt(object.ets, 10); + else if (typeof object.ets === "number") + message.ets = object.ets; + else if (typeof object.ets === "object") + message.ets = new $util.LongBits(object.ets.low >>> 0, object.ets.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2.CollectUserEventRequest} message CollectUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CollectUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = ""; + object.uri = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.ets = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.ets = options.longs === String ? "0" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = message.userEvent; + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.ets != null && message.hasOwnProperty("ets")) + if (typeof message.ets === "number") + object.ets = options.longs === String ? String(message.ets) : message.ets; + else + object.ets = options.longs === String ? $util.Long.prototype.toString.call(message.ets) : options.longs === Number ? new $util.LongBits(message.ets.low >>> 0, message.ets.high >>> 0).toNumber() : message.ets; + return object; + }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + CollectUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CollectUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.CollectUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CollectUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.CollectUserEventRequest"; + }; + + return CollectUserEventRequest; + })(); + + v2.RejoinUserEventsRequest = (function() { + + /** + * Properties of a RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @interface IRejoinUserEventsRequest + * @property {string|null} [parent] RejoinUserEventsRequest parent + * @property {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope|null} [userEventRejoinScope] RejoinUserEventsRequest userEventRejoinScope + */ + + /** + * Constructs a new RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RejoinUserEventsRequest. + * @implements IRejoinUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest=} [properties] Properties to set + */ + function RejoinUserEventsRequest(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]]; + } + + /** + * RejoinUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.parent = ""; + + /** + * RejoinUserEventsRequest userEventRejoinScope. + * @member {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} userEventRejoinScope + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.userEventRejoinScope = 0; + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RejoinUserEventsRequest} RejoinUserEventsRequest instance + */ + RejoinUserEventsRequest.create = function create(properties) { + return new RejoinUserEventsRequest(properties); + }; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEventRejoinScope != null && Object.hasOwnProperty.call(message, "userEventRejoinScope")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.userEventRejoinScope); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.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.cloud.retail.v2.RejoinUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEventRejoinScope = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + switch (message.userEventRejoinScope) { + default: + return "userEventRejoinScope: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RejoinUserEventsRequest} RejoinUserEventsRequest + */ + RejoinUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RejoinUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2.RejoinUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + switch (object.userEventRejoinScope) { + default: + if (typeof object.userEventRejoinScope === "number") { + message.userEventRejoinScope = object.userEventRejoinScope; + break; + } + break; + case "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": + case 0: + message.userEventRejoinScope = 0; + break; + case "JOINED_EVENTS": + case 1: + message.userEventRejoinScope = 1; + break; + case "UNJOINED_EVENTS": + case 2: + message.userEventRejoinScope = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2.RejoinUserEventsRequest} message RejoinUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEventRejoinScope = options.enums === String ? "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + object.userEventRejoinScope = options.enums === String ? $root.google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] === undefined ? message.userEventRejoinScope : $root.google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] : message.userEventRejoinScope; + return object; + }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RejoinUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RejoinUserEventsRequest"; + }; + + /** + * UserEventRejoinScope enum. + * @name google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope + * @enum {number} + * @property {number} USER_EVENT_REJOIN_SCOPE_UNSPECIFIED=0 USER_EVENT_REJOIN_SCOPE_UNSPECIFIED value + * @property {number} JOINED_EVENTS=1 JOINED_EVENTS value + * @property {number} UNJOINED_EVENTS=2 UNJOINED_EVENTS value + */ + RejoinUserEventsRequest.UserEventRejoinScope = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "JOINED_EVENTS"] = 1; + values[valuesById[2] = "UNJOINED_EVENTS"] = 2; + return values; + })(); + + return RejoinUserEventsRequest; + })(); + + v2.RejoinUserEventsResponse = (function() { + + /** + * Properties of a RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @interface IRejoinUserEventsResponse + * @property {number|Long|null} [rejoinedUserEventsCount] RejoinUserEventsResponse rejoinedUserEventsCount + */ + + /** + * Constructs a new RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RejoinUserEventsResponse. + * @implements IRejoinUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2.IRejoinUserEventsResponse=} [properties] Properties to set + */ + function RejoinUserEventsResponse(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]]; + } + + /** + * RejoinUserEventsResponse rejoinedUserEventsCount. + * @member {number|Long} rejoinedUserEventsCount + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @instance + */ + RejoinUserEventsResponse.prototype.rejoinedUserEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RejoinUserEventsResponse} RejoinUserEventsResponse instance + */ + RejoinUserEventsResponse.create = function create(properties) { + return new RejoinUserEventsResponse(properties); + }; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rejoinedUserEventsCount != null && Object.hasOwnProperty.call(message, "rejoinedUserEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.rejoinedUserEventsCount); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.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.cloud.retail.v2.RejoinUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.rejoinedUserEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (!$util.isInteger(message.rejoinedUserEventsCount) && !(message.rejoinedUserEventsCount && $util.isInteger(message.rejoinedUserEventsCount.low) && $util.isInteger(message.rejoinedUserEventsCount.high))) + return "rejoinedUserEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RejoinUserEventsResponse} RejoinUserEventsResponse + */ + RejoinUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RejoinUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2.RejoinUserEventsResponse(); + if (object.rejoinedUserEventsCount != null) + if ($util.Long) + (message.rejoinedUserEventsCount = $util.Long.fromValue(object.rejoinedUserEventsCount)).unsigned = false; + else if (typeof object.rejoinedUserEventsCount === "string") + message.rejoinedUserEventsCount = parseInt(object.rejoinedUserEventsCount, 10); + else if (typeof object.rejoinedUserEventsCount === "number") + message.rejoinedUserEventsCount = object.rejoinedUserEventsCount; + else if (typeof object.rejoinedUserEventsCount === "object") + message.rejoinedUserEventsCount = new $util.LongBits(object.rejoinedUserEventsCount.low >>> 0, object.rejoinedUserEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2.RejoinUserEventsResponse} message RejoinUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsResponse.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.rejoinedUserEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.rejoinedUserEventsCount = options.longs === String ? "0" : 0; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (typeof message.rejoinedUserEventsCount === "number") + object.rejoinedUserEventsCount = options.longs === String ? String(message.rejoinedUserEventsCount) : message.rejoinedUserEventsCount; + else + object.rejoinedUserEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.rejoinedUserEventsCount) : options.longs === Number ? new $util.LongBits(message.rejoinedUserEventsCount.low >>> 0, message.rejoinedUserEventsCount.high >>> 0).toNumber() : message.rejoinedUserEventsCount; + return object; + }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RejoinUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RejoinUserEventsResponse"; + }; + + return RejoinUserEventsResponse; + })(); + + v2.RejoinUserEventsMetadata = (function() { + + /** + * Properties of a RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2 + * @interface IRejoinUserEventsMetadata + */ + + /** + * Constructs a new RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2 + * @classdesc Represents a RejoinUserEventsMetadata. + * @implements IRejoinUserEventsMetadata + * @constructor + * @param {google.cloud.retail.v2.IRejoinUserEventsMetadata=} [properties] Properties to set + */ + function RejoinUserEventsMetadata(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 RejoinUserEventsMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2.RejoinUserEventsMetadata} RejoinUserEventsMetadata instance + */ + RejoinUserEventsMetadata.create = function create(properties) { + return new RejoinUserEventsMetadata(properties); + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2.RejoinUserEventsMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.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.cloud.retail.v2.RejoinUserEventsMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsMetadata message. + * @function verify + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2.RejoinUserEventsMetadata} RejoinUserEventsMetadata + */ + RejoinUserEventsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2.RejoinUserEventsMetadata) + return object; + return new $root.google.cloud.retail.v2.RejoinUserEventsMetadata(); + }; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2.RejoinUserEventsMetadata} message RejoinUserEventsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2.RejoinUserEventsMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2.RejoinUserEventsMetadata"; + }; + + return RejoinUserEventsMetadata; + })(); + + return v2; + })(); + + retail.v2alpha = (function() { + + /** + * Namespace v2alpha. + * @memberof google.cloud.retail + * @namespace + */ + var v2alpha = {}; + + v2alpha.ProductLevelConfig = (function() { + + /** + * Properties of a ProductLevelConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IProductLevelConfig + * @property {string|null} [ingestionProductType] ProductLevelConfig ingestionProductType + * @property {string|null} [merchantCenterProductIdField] ProductLevelConfig merchantCenterProductIdField + */ + + /** + * Constructs a new ProductLevelConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ProductLevelConfig. + * @implements IProductLevelConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IProductLevelConfig=} [properties] Properties to set + */ + function ProductLevelConfig(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]]; + } + + /** + * ProductLevelConfig ingestionProductType. + * @member {string} ingestionProductType + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.ingestionProductType = ""; + + /** + * ProductLevelConfig merchantCenterProductIdField. + * @member {string} merchantCenterProductIdField + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.merchantCenterProductIdField = ""; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductLevelConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ProductLevelConfig} ProductLevelConfig instance + */ + ProductLevelConfig.create = function create(properties) { + return new ProductLevelConfig(properties); + }; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductLevelConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ingestionProductType != null && Object.hasOwnProperty.call(message, "ingestionProductType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ingestionProductType); + if (message.merchantCenterProductIdField != null && Object.hasOwnProperty.call(message, "merchantCenterProductIdField")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.merchantCenterProductIdField); + return writer; + }; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductLevelConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.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.cloud.retail.v2alpha.ProductLevelConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ingestionProductType = reader.string(); + break; + } + case 2: { + message.merchantCenterProductIdField = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductLevelConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductLevelConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + if (!$util.isString(message.ingestionProductType)) + return "ingestionProductType: string expected"; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + if (!$util.isString(message.merchantCenterProductIdField)) + return "merchantCenterProductIdField: string expected"; + return null; + }; + + /** + * Creates a ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ProductLevelConfig} ProductLevelConfig + */ + ProductLevelConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ProductLevelConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.ProductLevelConfig(); + if (object.ingestionProductType != null) + message.ingestionProductType = String(object.ingestionProductType); + if (object.merchantCenterProductIdField != null) + message.merchantCenterProductIdField = String(object.merchantCenterProductIdField); + return message; + }; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2alpha.ProductLevelConfig} message ProductLevelConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductLevelConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ingestionProductType = ""; + object.merchantCenterProductIdField = ""; + } + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + object.ingestionProductType = message.ingestionProductType; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + object.merchantCenterProductIdField = message.merchantCenterProductIdField; + return object; + }; + + /** + * Converts this ProductLevelConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @instance + * @returns {Object.} JSON object + */ + ProductLevelConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductLevelConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ProductLevelConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductLevelConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ProductLevelConfig"; + }; + + return ProductLevelConfig; + })(); + + v2alpha.CatalogAttribute = (function() { + + /** + * Properties of a CatalogAttribute. + * @memberof google.cloud.retail.v2alpha + * @interface ICatalogAttribute + * @property {string|null} [key] CatalogAttribute key + * @property {boolean|null} [inUse] CatalogAttribute inUse + * @property {google.cloud.retail.v2alpha.CatalogAttribute.AttributeType|null} [type] CatalogAttribute type + * @property {google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption|null} [indexableOption] CatalogAttribute indexableOption + * @property {google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption|null} [dynamicFacetableOption] CatalogAttribute dynamicFacetableOption + * @property {google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption|null} [searchableOption] CatalogAttribute searchableOption + * @property {google.cloud.retail.v2alpha.RecommendationsFilteringOption|null} [recommendationsFilteringOption] CatalogAttribute recommendationsFilteringOption + */ + + /** + * Constructs a new CatalogAttribute. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CatalogAttribute. + * @implements ICatalogAttribute + * @constructor + * @param {google.cloud.retail.v2alpha.ICatalogAttribute=} [properties] Properties to set + */ + function CatalogAttribute(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]]; + } + + /** + * CatalogAttribute key. + * @member {string} key + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.key = ""; + + /** + * CatalogAttribute inUse. + * @member {boolean} inUse + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.inUse = false; + + /** + * CatalogAttribute type. + * @member {google.cloud.retail.v2alpha.CatalogAttribute.AttributeType} type + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.type = 0; + + /** + * CatalogAttribute indexableOption. + * @member {google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption} indexableOption + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.indexableOption = 0; + + /** + * CatalogAttribute dynamicFacetableOption. + * @member {google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption} dynamicFacetableOption + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.dynamicFacetableOption = 0; + + /** + * CatalogAttribute searchableOption. + * @member {google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption} searchableOption + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.searchableOption = 0; + + /** + * CatalogAttribute recommendationsFilteringOption. + * @member {google.cloud.retail.v2alpha.RecommendationsFilteringOption} recommendationsFilteringOption + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.recommendationsFilteringOption = 0; + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICatalogAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CatalogAttribute} CatalogAttribute instance + */ + CatalogAttribute.create = function create(properties) { + return new CatalogAttribute(properties); + }; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2alpha.CatalogAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.indexableOption != null && Object.hasOwnProperty.call(message, "indexableOption")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.indexableOption); + if (message.dynamicFacetableOption != null && Object.hasOwnProperty.call(message, "dynamicFacetableOption")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.dynamicFacetableOption); + if (message.searchableOption != null && Object.hasOwnProperty.call(message, "searchableOption")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.searchableOption); + if (message.recommendationsFilteringOption != null && Object.hasOwnProperty.call(message, "recommendationsFilteringOption")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.recommendationsFilteringOption); + if (message.inUse != null && Object.hasOwnProperty.call(message, "inUse")) + writer.uint32(/* id 9, wireType 0 =*/72).bool(message.inUse); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.type); + return writer; + }; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CatalogAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.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.cloud.retail.v2alpha.CatalogAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 9: { + message.inUse = reader.bool(); + break; + } + case 10: { + message.type = reader.int32(); + break; + } + case 5: { + message.indexableOption = reader.int32(); + break; + } + case 6: { + message.dynamicFacetableOption = reader.int32(); + break; + } + case 7: { + message.searchableOption = reader.int32(); + break; + } + case 8: { + message.recommendationsFilteringOption = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CatalogAttribute message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CatalogAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.inUse != null && message.hasOwnProperty("inUse")) + if (typeof message.inUse !== "boolean") + return "inUse: boolean expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + switch (message.indexableOption) { + default: + return "indexableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + switch (message.dynamicFacetableOption) { + default: + return "dynamicFacetableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + switch (message.searchableOption) { + default: + return "searchableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.recommendationsFilteringOption != null && message.hasOwnProperty("recommendationsFilteringOption")) + switch (message.recommendationsFilteringOption) { + default: + return "recommendationsFilteringOption: enum value expected"; + case 0: + case 1: + case 3: + break; + } + return null; + }; + + /** + * Creates a CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CatalogAttribute} CatalogAttribute + */ + CatalogAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CatalogAttribute) + return object; + var message = new $root.google.cloud.retail.v2alpha.CatalogAttribute(); + if (object.key != null) + message.key = String(object.key); + if (object.inUse != null) + message.inUse = Boolean(object.inUse); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "UNKNOWN": + case 0: + message.type = 0; + break; + case "TEXTUAL": + case 1: + message.type = 1; + break; + case "NUMERICAL": + case 2: + message.type = 2; + break; + } + switch (object.indexableOption) { + default: + if (typeof object.indexableOption === "number") { + message.indexableOption = object.indexableOption; + break; + } + break; + case "INDEXABLE_OPTION_UNSPECIFIED": + case 0: + message.indexableOption = 0; + break; + case "INDEXABLE_ENABLED": + case 1: + message.indexableOption = 1; + break; + case "INDEXABLE_DISABLED": + case 2: + message.indexableOption = 2; + break; + } + switch (object.dynamicFacetableOption) { + default: + if (typeof object.dynamicFacetableOption === "number") { + message.dynamicFacetableOption = object.dynamicFacetableOption; + break; + } + break; + case "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": + case 0: + message.dynamicFacetableOption = 0; + break; + case "DYNAMIC_FACETABLE_ENABLED": + case 1: + message.dynamicFacetableOption = 1; + break; + case "DYNAMIC_FACETABLE_DISABLED": + case 2: + message.dynamicFacetableOption = 2; + break; + } + switch (object.searchableOption) { + default: + if (typeof object.searchableOption === "number") { + message.searchableOption = object.searchableOption; + break; + } + break; + case "SEARCHABLE_OPTION_UNSPECIFIED": + case 0: + message.searchableOption = 0; + break; + case "SEARCHABLE_ENABLED": + case 1: + message.searchableOption = 1; + break; + case "SEARCHABLE_DISABLED": + case 2: + message.searchableOption = 2; + break; + } + switch (object.recommendationsFilteringOption) { + default: + if (typeof object.recommendationsFilteringOption === "number") { + message.recommendationsFilteringOption = object.recommendationsFilteringOption; + break; + } + break; + case "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": + case 0: + message.recommendationsFilteringOption = 0; + break; + case "RECOMMENDATIONS_FILTERING_DISABLED": + case 1: + message.recommendationsFilteringOption = 1; + break; + case "RECOMMENDATIONS_FILTERING_ENABLED": + case 3: + message.recommendationsFilteringOption = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {google.cloud.retail.v2alpha.CatalogAttribute} message CatalogAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CatalogAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.key = ""; + object.indexableOption = options.enums === String ? "INDEXABLE_OPTION_UNSPECIFIED" : 0; + object.dynamicFacetableOption = options.enums === String ? "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED" : 0; + object.searchableOption = options.enums === String ? "SEARCHABLE_OPTION_UNSPECIFIED" : 0; + object.recommendationsFilteringOption = options.enums === String ? "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED" : 0; + object.inUse = false; + object.type = options.enums === String ? "UNKNOWN" : 0; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + object.indexableOption = options.enums === String ? $root.google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption[message.indexableOption] === undefined ? message.indexableOption : $root.google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption[message.indexableOption] : message.indexableOption; + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + object.dynamicFacetableOption = options.enums === String ? $root.google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] === undefined ? message.dynamicFacetableOption : $root.google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] : message.dynamicFacetableOption; + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + object.searchableOption = options.enums === String ? $root.google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption[message.searchableOption] === undefined ? message.searchableOption : $root.google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption[message.searchableOption] : message.searchableOption; + if (message.recommendationsFilteringOption != null && message.hasOwnProperty("recommendationsFilteringOption")) + object.recommendationsFilteringOption = options.enums === String ? $root.google.cloud.retail.v2alpha.RecommendationsFilteringOption[message.recommendationsFilteringOption] === undefined ? message.recommendationsFilteringOption : $root.google.cloud.retail.v2alpha.RecommendationsFilteringOption[message.recommendationsFilteringOption] : message.recommendationsFilteringOption; + if (message.inUse != null && message.hasOwnProperty("inUse")) + object.inUse = message.inUse; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2alpha.CatalogAttribute.AttributeType[message.type] === undefined ? message.type : $root.google.cloud.retail.v2alpha.CatalogAttribute.AttributeType[message.type] : message.type; + return object; + }; + + /** + * Converts this CatalogAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @instance + * @returns {Object.} JSON object + */ + CatalogAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CatalogAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CatalogAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CatalogAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CatalogAttribute"; + }; + + /** + * AttributeType enum. + * @name google.cloud.retail.v2alpha.CatalogAttribute.AttributeType + * @enum {number} + * @property {number} UNKNOWN=0 UNKNOWN value + * @property {number} TEXTUAL=1 TEXTUAL value + * @property {number} NUMERICAL=2 NUMERICAL value + */ + CatalogAttribute.AttributeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN"] = 0; + values[valuesById[1] = "TEXTUAL"] = 1; + values[valuesById[2] = "NUMERICAL"] = 2; + return values; + })(); + + /** + * IndexableOption enum. + * @name google.cloud.retail.v2alpha.CatalogAttribute.IndexableOption + * @enum {number} + * @property {number} INDEXABLE_OPTION_UNSPECIFIED=0 INDEXABLE_OPTION_UNSPECIFIED value + * @property {number} INDEXABLE_ENABLED=1 INDEXABLE_ENABLED value + * @property {number} INDEXABLE_DISABLED=2 INDEXABLE_DISABLED value + */ + CatalogAttribute.IndexableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "INDEXABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "INDEXABLE_ENABLED"] = 1; + values[valuesById[2] = "INDEXABLE_DISABLED"] = 2; + return values; + })(); + + /** + * DynamicFacetableOption enum. + * @name google.cloud.retail.v2alpha.CatalogAttribute.DynamicFacetableOption + * @enum {number} + * @property {number} DYNAMIC_FACETABLE_OPTION_UNSPECIFIED=0 DYNAMIC_FACETABLE_OPTION_UNSPECIFIED value + * @property {number} DYNAMIC_FACETABLE_ENABLED=1 DYNAMIC_FACETABLE_ENABLED value + * @property {number} DYNAMIC_FACETABLE_DISABLED=2 DYNAMIC_FACETABLE_DISABLED value + */ + CatalogAttribute.DynamicFacetableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DYNAMIC_FACETABLE_ENABLED"] = 1; + values[valuesById[2] = "DYNAMIC_FACETABLE_DISABLED"] = 2; + return values; + })(); + + /** + * SearchableOption enum. + * @name google.cloud.retail.v2alpha.CatalogAttribute.SearchableOption + * @enum {number} + * @property {number} SEARCHABLE_OPTION_UNSPECIFIED=0 SEARCHABLE_OPTION_UNSPECIFIED value + * @property {number} SEARCHABLE_ENABLED=1 SEARCHABLE_ENABLED value + * @property {number} SEARCHABLE_DISABLED=2 SEARCHABLE_DISABLED value + */ + CatalogAttribute.SearchableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCHABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCHABLE_ENABLED"] = 1; + values[valuesById[2] = "SEARCHABLE_DISABLED"] = 2; + return values; + })(); + + return CatalogAttribute; + })(); + + v2alpha.AttributesConfig = (function() { + + /** + * Properties of an AttributesConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IAttributesConfig + * @property {string|null} [name] AttributesConfig name + * @property {Object.|null} [catalogAttributes] AttributesConfig catalogAttributes + * @property {google.cloud.retail.v2alpha.AttributeConfigLevel|null} [attributeConfigLevel] AttributesConfig attributeConfigLevel + */ + + /** + * Constructs a new AttributesConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AttributesConfig. + * @implements IAttributesConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IAttributesConfig=} [properties] Properties to set + */ + function AttributesConfig(properties) { + this.catalogAttributes = {}; + 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]]; + } + + /** + * AttributesConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @instance + */ + AttributesConfig.prototype.name = ""; + + /** + * AttributesConfig catalogAttributes. + * @member {Object.} catalogAttributes + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @instance + */ + AttributesConfig.prototype.catalogAttributes = $util.emptyObject; + + /** + * AttributesConfig attributeConfigLevel. + * @member {google.cloud.retail.v2alpha.AttributeConfigLevel} attributeConfigLevel + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @instance + */ + AttributesConfig.prototype.attributeConfigLevel = 0; + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {google.cloud.retail.v2alpha.IAttributesConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AttributesConfig} AttributesConfig instance + */ + AttributesConfig.create = function create(properties) { + return new AttributesConfig(properties); + }; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.AttributesConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {google.cloud.retail.v2alpha.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.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.catalogAttributes != null && Object.hasOwnProperty.call(message, "catalogAttributes")) + for (var keys = Object.keys(message.catalogAttributes), 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.cloud.retail.v2alpha.CatalogAttribute.encode(message.catalogAttributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.attributeConfigLevel != null && Object.hasOwnProperty.call(message, "attributeConfigLevel")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.attributeConfigLevel); + return writer; + }; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AttributesConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {google.cloud.retail.v2alpha.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.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.cloud.retail.v2alpha.AttributesConfig(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (message.catalogAttributes === $util.emptyObject) + message.catalogAttributes = {}; + 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.cloud.retail.v2alpha.CatalogAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.catalogAttributes[key] = value; + break; + } + case 3: { + message.attributeConfigLevel = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AttributesConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AttributesConfig.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.catalogAttributes != null && message.hasOwnProperty("catalogAttributes")) { + if (!$util.isObject(message.catalogAttributes)) + return "catalogAttributes: object expected"; + var key = Object.keys(message.catalogAttributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CatalogAttribute.verify(message.catalogAttributes[key[i]]); + if (error) + return "catalogAttributes." + error; + } + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + switch (message.attributeConfigLevel) { + default: + return "attributeConfigLevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AttributesConfig} AttributesConfig + */ + AttributesConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AttributesConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.AttributesConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.catalogAttributes) { + if (typeof object.catalogAttributes !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes = {}; + for (var keys = Object.keys(object.catalogAttributes), i = 0; i < keys.length; ++i) { + if (typeof object.catalogAttributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes[keys[i]] = $root.google.cloud.retail.v2alpha.CatalogAttribute.fromObject(object.catalogAttributes[keys[i]]); + } + } + switch (object.attributeConfigLevel) { + default: + if (typeof object.attributeConfigLevel === "number") { + message.attributeConfigLevel = object.attributeConfigLevel; + break; + } + break; + case "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": + case 0: + message.attributeConfigLevel = 0; + break; + case "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": + case 1: + message.attributeConfigLevel = 1; + break; + case "CATALOG_LEVEL_ATTRIBUTE_CONFIG": + case 2: + message.attributeConfigLevel = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {google.cloud.retail.v2alpha.AttributesConfig} message AttributesConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AttributesConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.catalogAttributes = {}; + if (options.defaults) { + object.name = ""; + object.attributeConfigLevel = options.enums === String ? "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + var keys2; + if (message.catalogAttributes && (keys2 = Object.keys(message.catalogAttributes)).length) { + object.catalogAttributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.catalogAttributes[keys2[j]] = $root.google.cloud.retail.v2alpha.CatalogAttribute.toObject(message.catalogAttributes[keys2[j]], options); + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + object.attributeConfigLevel = options.enums === String ? $root.google.cloud.retail.v2alpha.AttributeConfigLevel[message.attributeConfigLevel] === undefined ? message.attributeConfigLevel : $root.google.cloud.retail.v2alpha.AttributeConfigLevel[message.attributeConfigLevel] : message.attributeConfigLevel; + return object; + }; + + /** + * Converts this AttributesConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @instance + * @returns {Object.} JSON object + */ + AttributesConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AttributesConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AttributesConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AttributesConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AttributesConfig"; + }; + + return AttributesConfig; + })(); + + v2alpha.CompletionConfig = (function() { + + /** + * Properties of a CompletionConfig. + * @memberof google.cloud.retail.v2alpha + * @interface ICompletionConfig + * @property {string|null} [name] CompletionConfig name + * @property {string|null} [matchingOrder] CompletionConfig matchingOrder + * @property {number|null} [maxSuggestions] CompletionConfig maxSuggestions + * @property {number|null} [minPrefixLength] CompletionConfig minPrefixLength + * @property {boolean|null} [autoLearning] CompletionConfig autoLearning + * @property {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null} [suggestionsInputConfig] CompletionConfig suggestionsInputConfig + * @property {string|null} [lastSuggestionsImportOperation] CompletionConfig lastSuggestionsImportOperation + * @property {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null} [denylistInputConfig] CompletionConfig denylistInputConfig + * @property {string|null} [lastDenylistImportOperation] CompletionConfig lastDenylistImportOperation + * @property {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null} [allowlistInputConfig] CompletionConfig allowlistInputConfig + * @property {string|null} [lastAllowlistImportOperation] CompletionConfig lastAllowlistImportOperation + */ + + /** + * Constructs a new CompletionConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompletionConfig. + * @implements ICompletionConfig + * @constructor + * @param {google.cloud.retail.v2alpha.ICompletionConfig=} [properties] Properties to set + */ + function CompletionConfig(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]]; + } + + /** + * CompletionConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.name = ""; + + /** + * CompletionConfig matchingOrder. + * @member {string} matchingOrder + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.matchingOrder = ""; + + /** + * CompletionConfig maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.maxSuggestions = 0; + + /** + * CompletionConfig minPrefixLength. + * @member {number} minPrefixLength + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.minPrefixLength = 0; + + /** + * CompletionConfig autoLearning. + * @member {boolean} autoLearning + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.autoLearning = false; + + /** + * CompletionConfig suggestionsInputConfig. + * @member {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null|undefined} suggestionsInputConfig + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.suggestionsInputConfig = null; + + /** + * CompletionConfig lastSuggestionsImportOperation. + * @member {string} lastSuggestionsImportOperation + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastSuggestionsImportOperation = ""; + + /** + * CompletionConfig denylistInputConfig. + * @member {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null|undefined} denylistInputConfig + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.denylistInputConfig = null; + + /** + * CompletionConfig lastDenylistImportOperation. + * @member {string} lastDenylistImportOperation + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastDenylistImportOperation = ""; + + /** + * CompletionConfig allowlistInputConfig. + * @member {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null|undefined} allowlistInputConfig + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.allowlistInputConfig = null; + + /** + * CompletionConfig lastAllowlistImportOperation. + * @member {string} lastAllowlistImportOperation + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastAllowlistImportOperation = ""; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompletionConfig} CompletionConfig instance + */ + CompletionConfig.create = function create(properties) { + return new CompletionConfig(properties); + }; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.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.matchingOrder != null && Object.hasOwnProperty.call(message, "matchingOrder")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.matchingOrder); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.maxSuggestions); + if (message.minPrefixLength != null && Object.hasOwnProperty.call(message, "minPrefixLength")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.minPrefixLength); + if (message.suggestionsInputConfig != null && Object.hasOwnProperty.call(message, "suggestionsInputConfig")) + $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.encode(message.suggestionsInputConfig, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.lastSuggestionsImportOperation != null && Object.hasOwnProperty.call(message, "lastSuggestionsImportOperation")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.lastSuggestionsImportOperation); + if (message.denylistInputConfig != null && Object.hasOwnProperty.call(message, "denylistInputConfig")) + $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.encode(message.denylistInputConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.lastDenylistImportOperation != null && Object.hasOwnProperty.call(message, "lastDenylistImportOperation")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.lastDenylistImportOperation); + if (message.allowlistInputConfig != null && Object.hasOwnProperty.call(message, "allowlistInputConfig")) + $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.encode(message.allowlistInputConfig, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.lastAllowlistImportOperation != null && Object.hasOwnProperty.call(message, "lastAllowlistImportOperation")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.lastAllowlistImportOperation); + if (message.autoLearning != null && Object.hasOwnProperty.call(message, "autoLearning")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.autoLearning); + return writer; + }; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.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.cloud.retail.v2alpha.CompletionConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.matchingOrder = reader.string(); + break; + } + case 3: { + message.maxSuggestions = reader.int32(); + break; + } + case 4: { + message.minPrefixLength = reader.int32(); + break; + } + case 11: { + message.autoLearning = reader.bool(); + break; + } + case 5: { + message.suggestionsInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 6: { + message.lastSuggestionsImportOperation = reader.string(); + break; + } + case 7: { + message.denylistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 8: { + message.lastDenylistImportOperation = reader.string(); + break; + } + case 9: { + message.allowlistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 10: { + message.lastAllowlistImportOperation = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionConfig.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.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + if (!$util.isString(message.matchingOrder)) + return "matchingOrder: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + if (!$util.isInteger(message.minPrefixLength)) + return "minPrefixLength: integer expected"; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + if (typeof message.autoLearning !== "boolean") + return "autoLearning: boolean expected"; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) { + var error = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.verify(message.suggestionsInputConfig); + if (error) + return "suggestionsInputConfig." + error; + } + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + if (!$util.isString(message.lastSuggestionsImportOperation)) + return "lastSuggestionsImportOperation: string expected"; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) { + var error = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.verify(message.denylistInputConfig); + if (error) + return "denylistInputConfig." + error; + } + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + if (!$util.isString(message.lastDenylistImportOperation)) + return "lastDenylistImportOperation: string expected"; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) { + var error = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.verify(message.allowlistInputConfig); + if (error) + return "allowlistInputConfig." + error; + } + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + if (!$util.isString(message.lastAllowlistImportOperation)) + return "lastAllowlistImportOperation: string expected"; + return null; + }; + + /** + * Creates a CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompletionConfig} CompletionConfig + */ + CompletionConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompletionConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompletionConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.matchingOrder != null) + message.matchingOrder = String(object.matchingOrder); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + if (object.minPrefixLength != null) + message.minPrefixLength = object.minPrefixLength | 0; + if (object.autoLearning != null) + message.autoLearning = Boolean(object.autoLearning); + if (object.suggestionsInputConfig != null) { + if (typeof object.suggestionsInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompletionConfig.suggestionsInputConfig: object expected"); + message.suggestionsInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.fromObject(object.suggestionsInputConfig); + } + if (object.lastSuggestionsImportOperation != null) + message.lastSuggestionsImportOperation = String(object.lastSuggestionsImportOperation); + if (object.denylistInputConfig != null) { + if (typeof object.denylistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompletionConfig.denylistInputConfig: object expected"); + message.denylistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.fromObject(object.denylistInputConfig); + } + if (object.lastDenylistImportOperation != null) + message.lastDenylistImportOperation = String(object.lastDenylistImportOperation); + if (object.allowlistInputConfig != null) { + if (typeof object.allowlistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompletionConfig.allowlistInputConfig: object expected"); + message.allowlistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.fromObject(object.allowlistInputConfig); + } + if (object.lastAllowlistImportOperation != null) + message.lastAllowlistImportOperation = String(object.lastAllowlistImportOperation); + return message; + }; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {google.cloud.retail.v2alpha.CompletionConfig} message CompletionConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.matchingOrder = ""; + object.maxSuggestions = 0; + object.minPrefixLength = 0; + object.suggestionsInputConfig = null; + object.lastSuggestionsImportOperation = ""; + object.denylistInputConfig = null; + object.lastDenylistImportOperation = ""; + object.allowlistInputConfig = null; + object.lastAllowlistImportOperation = ""; + object.autoLearning = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + object.matchingOrder = message.matchingOrder; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + object.minPrefixLength = message.minPrefixLength; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) + object.suggestionsInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.toObject(message.suggestionsInputConfig, options); + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + object.lastSuggestionsImportOperation = message.lastSuggestionsImportOperation; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) + object.denylistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.toObject(message.denylistInputConfig, options); + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + object.lastDenylistImportOperation = message.lastDenylistImportOperation; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) + object.allowlistInputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.toObject(message.allowlistInputConfig, options); + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + object.lastAllowlistImportOperation = message.lastAllowlistImportOperation; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + object.autoLearning = message.autoLearning; + return object; + }; + + /** + * Converts this CompletionConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompletionConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompletionConfig"; + }; + + return CompletionConfig; + })(); + + v2alpha.MerchantCenterLink = (function() { + + /** + * Properties of a MerchantCenterLink. + * @memberof google.cloud.retail.v2alpha + * @interface IMerchantCenterLink + * @property {number|Long|null} [merchantCenterAccountId] MerchantCenterLink merchantCenterAccountId + * @property {string|null} [branchId] MerchantCenterLink branchId + * @property {Array.|null} [destinations] MerchantCenterLink destinations + * @property {string|null} [regionCode] MerchantCenterLink regionCode + * @property {string|null} [languageCode] MerchantCenterLink languageCode + */ + + /** + * Constructs a new MerchantCenterLink. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a MerchantCenterLink. + * @implements IMerchantCenterLink + * @constructor + * @param {google.cloud.retail.v2alpha.IMerchantCenterLink=} [properties] Properties to set + */ + function MerchantCenterLink(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]]; + } + + /** + * MerchantCenterLink merchantCenterAccountId. + * @member {number|Long} merchantCenterAccountId + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.merchantCenterAccountId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * MerchantCenterLink branchId. + * @member {string} branchId + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.branchId = ""; + + /** + * MerchantCenterLink destinations. + * @member {Array.} destinations + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.destinations = $util.emptyArray; + + /** + * MerchantCenterLink regionCode. + * @member {string} regionCode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.regionCode = ""; + + /** + * MerchantCenterLink languageCode. + * @member {string} languageCode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.languageCode = ""; + + /** + * Creates a new MerchantCenterLink instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLink=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.MerchantCenterLink} MerchantCenterLink instance + */ + MerchantCenterLink.create = function create(properties) { + return new MerchantCenterLink(properties); + }; + + /** + * Encodes the specified MerchantCenterLink message. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLink.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLink} message MerchantCenterLink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLink.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.merchantCenterAccountId != null && Object.hasOwnProperty.call(message, "merchantCenterAccountId")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.merchantCenterAccountId); + if (message.branchId != null && Object.hasOwnProperty.call(message, "branchId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branchId); + if (message.destinations != null && message.destinations.length) + for (var i = 0; i < message.destinations.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.destinations[i]); + if (message.regionCode != null && Object.hasOwnProperty.call(message, "regionCode")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.regionCode); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.languageCode); + return writer; + }; + + /** + * Encodes the specified MerchantCenterLink message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLink.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLink} message MerchantCenterLink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLink.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.MerchantCenterLink} MerchantCenterLink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLink.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.cloud.retail.v2alpha.MerchantCenterLink(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.merchantCenterAccountId = reader.int64(); + break; + } + case 2: { + message.branchId = reader.string(); + break; + } + case 3: { + if (!(message.destinations && message.destinations.length)) + message.destinations = []; + message.destinations.push(reader.string()); + break; + } + case 4: { + message.regionCode = reader.string(); + break; + } + case 5: { + message.languageCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.MerchantCenterLink} MerchantCenterLink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLink.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MerchantCenterLink message. + * @function verify + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MerchantCenterLink.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.merchantCenterAccountId != null && message.hasOwnProperty("merchantCenterAccountId")) + if (!$util.isInteger(message.merchantCenterAccountId) && !(message.merchantCenterAccountId && $util.isInteger(message.merchantCenterAccountId.low) && $util.isInteger(message.merchantCenterAccountId.high))) + return "merchantCenterAccountId: integer|Long expected"; + if (message.branchId != null && message.hasOwnProperty("branchId")) + if (!$util.isString(message.branchId)) + return "branchId: 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) + if (!$util.isString(message.destinations[i])) + return "destinations: string[] expected"; + } + if (message.regionCode != null && message.hasOwnProperty("regionCode")) + if (!$util.isString(message.regionCode)) + return "regionCode: string expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + return null; + }; + + /** + * Creates a MerchantCenterLink message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.MerchantCenterLink} MerchantCenterLink + */ + MerchantCenterLink.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.MerchantCenterLink) + return object; + var message = new $root.google.cloud.retail.v2alpha.MerchantCenterLink(); + if (object.merchantCenterAccountId != null) + if ($util.Long) + (message.merchantCenterAccountId = $util.Long.fromValue(object.merchantCenterAccountId)).unsigned = false; + else if (typeof object.merchantCenterAccountId === "string") + message.merchantCenterAccountId = parseInt(object.merchantCenterAccountId, 10); + else if (typeof object.merchantCenterAccountId === "number") + message.merchantCenterAccountId = object.merchantCenterAccountId; + else if (typeof object.merchantCenterAccountId === "object") + message.merchantCenterAccountId = new $util.LongBits(object.merchantCenterAccountId.low >>> 0, object.merchantCenterAccountId.high >>> 0).toNumber(); + if (object.branchId != null) + message.branchId = String(object.branchId); + if (object.destinations) { + if (!Array.isArray(object.destinations)) + throw TypeError(".google.cloud.retail.v2alpha.MerchantCenterLink.destinations: array expected"); + message.destinations = []; + for (var i = 0; i < object.destinations.length; ++i) + message.destinations[i] = String(object.destinations[i]); + } + if (object.regionCode != null) + message.regionCode = String(object.regionCode); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + return message; + }; + + /** + * Creates a plain object from a MerchantCenterLink message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2alpha.MerchantCenterLink} message MerchantCenterLink + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MerchantCenterLink.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.destinations = []; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.merchantCenterAccountId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.merchantCenterAccountId = options.longs === String ? "0" : 0; + object.branchId = ""; + object.regionCode = ""; + object.languageCode = ""; + } + if (message.merchantCenterAccountId != null && message.hasOwnProperty("merchantCenterAccountId")) + if (typeof message.merchantCenterAccountId === "number") + object.merchantCenterAccountId = options.longs === String ? String(message.merchantCenterAccountId) : message.merchantCenterAccountId; + else + object.merchantCenterAccountId = options.longs === String ? $util.Long.prototype.toString.call(message.merchantCenterAccountId) : options.longs === Number ? new $util.LongBits(message.merchantCenterAccountId.low >>> 0, message.merchantCenterAccountId.high >>> 0).toNumber() : message.merchantCenterAccountId; + if (message.branchId != null && message.hasOwnProperty("branchId")) + object.branchId = message.branchId; + if (message.destinations && message.destinations.length) { + object.destinations = []; + for (var j = 0; j < message.destinations.length; ++j) + object.destinations[j] = message.destinations[j]; + } + if (message.regionCode != null && message.hasOwnProperty("regionCode")) + object.regionCode = message.regionCode; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + return object; + }; + + /** + * Converts this MerchantCenterLink to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @instance + * @returns {Object.} JSON object + */ + MerchantCenterLink.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MerchantCenterLink + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.MerchantCenterLink + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MerchantCenterLink.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.MerchantCenterLink"; + }; + + return MerchantCenterLink; + })(); + + v2alpha.MerchantCenterLinkingConfig = (function() { + + /** + * Properties of a MerchantCenterLinkingConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IMerchantCenterLinkingConfig + * @property {Array.|null} [links] MerchantCenterLinkingConfig links + */ + + /** + * Constructs a new MerchantCenterLinkingConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a MerchantCenterLinkingConfig. + * @implements IMerchantCenterLinkingConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig=} [properties] Properties to set + */ + function MerchantCenterLinkingConfig(properties) { + this.links = []; + 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]]; + } + + /** + * MerchantCenterLinkingConfig links. + * @member {Array.} links + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @instance + */ + MerchantCenterLinkingConfig.prototype.links = $util.emptyArray; + + /** + * Creates a new MerchantCenterLinkingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig instance + */ + MerchantCenterLinkingConfig.create = function create(properties) { + return new MerchantCenterLinkingConfig(properties); + }; + + /** + * Encodes the specified MerchantCenterLinkingConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig} message MerchantCenterLinkingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLinkingConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.links != null && message.links.length) + for (var i = 0; i < message.links.length; ++i) + $root.google.cloud.retail.v2alpha.MerchantCenterLink.encode(message.links[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MerchantCenterLinkingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig} message MerchantCenterLinkingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLinkingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLinkingConfig.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.cloud.retail.v2alpha.MerchantCenterLinkingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.links && message.links.length)) + message.links = []; + message.links.push($root.google.cloud.retail.v2alpha.MerchantCenterLink.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLinkingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MerchantCenterLinkingConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MerchantCenterLinkingConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.links != null && message.hasOwnProperty("links")) { + if (!Array.isArray(message.links)) + return "links: array expected"; + for (var i = 0; i < message.links.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.MerchantCenterLink.verify(message.links[i]); + if (error) + return "links." + error; + } + } + return null; + }; + + /** + * Creates a MerchantCenterLinkingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + */ + MerchantCenterLinkingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig(); + if (object.links) { + if (!Array.isArray(object.links)) + throw TypeError(".google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.links: array expected"); + message.links = []; + for (var i = 0; i < object.links.length; ++i) { + if (typeof object.links[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.links: object expected"); + message.links[i] = $root.google.cloud.retail.v2alpha.MerchantCenterLink.fromObject(object.links[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a MerchantCenterLinkingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2alpha.MerchantCenterLinkingConfig} message MerchantCenterLinkingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MerchantCenterLinkingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.links = []; + if (message.links && message.links.length) { + object.links = []; + for (var j = 0; j < message.links.length; ++j) + object.links[j] = $root.google.cloud.retail.v2alpha.MerchantCenterLink.toObject(message.links[j], options); + } + return object; + }; + + /** + * Converts this MerchantCenterLinkingConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @instance + * @returns {Object.} JSON object + */ + MerchantCenterLinkingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MerchantCenterLinkingConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.MerchantCenterLinkingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MerchantCenterLinkingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.MerchantCenterLinkingConfig"; + }; + + return MerchantCenterLinkingConfig; + })(); + + v2alpha.Catalog = (function() { + + /** + * Properties of a Catalog. + * @memberof google.cloud.retail.v2alpha + * @interface ICatalog + * @property {string|null} [name] Catalog name + * @property {string|null} [displayName] Catalog displayName + * @property {google.cloud.retail.v2alpha.IProductLevelConfig|null} [productLevelConfig] Catalog productLevelConfig + * @property {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig|null} [merchantCenterLinkingConfig] Catalog merchantCenterLinkingConfig + */ + + /** + * Constructs a new Catalog. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Catalog. + * @implements ICatalog + * @constructor + * @param {google.cloud.retail.v2alpha.ICatalog=} [properties] Properties to set + */ + function Catalog(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]]; + } + + /** + * Catalog name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.Catalog + * @instance + */ + Catalog.prototype.name = ""; + + /** + * Catalog displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2alpha.Catalog + * @instance + */ + Catalog.prototype.displayName = ""; + + /** + * Catalog productLevelConfig. + * @member {google.cloud.retail.v2alpha.IProductLevelConfig|null|undefined} productLevelConfig + * @memberof google.cloud.retail.v2alpha.Catalog + * @instance + */ + Catalog.prototype.productLevelConfig = null; + + /** + * Catalog merchantCenterLinkingConfig. + * @member {google.cloud.retail.v2alpha.IMerchantCenterLinkingConfig|null|undefined} merchantCenterLinkingConfig + * @memberof google.cloud.retail.v2alpha.Catalog + * @instance + */ + Catalog.prototype.merchantCenterLinkingConfig = null; + + /** + * Creates a new Catalog instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {google.cloud.retail.v2alpha.ICatalog=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Catalog} Catalog instance + */ + Catalog.create = function create(properties) { + return new Catalog(properties); + }; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2alpha.Catalog.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {google.cloud.retail.v2alpha.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.productLevelConfig != null && Object.hasOwnProperty.call(message, "productLevelConfig")) + $root.google.cloud.retail.v2alpha.ProductLevelConfig.encode(message.productLevelConfig, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.merchantCenterLinkingConfig != null && Object.hasOwnProperty.call(message, "merchantCenterLinkingConfig")) + $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.encode(message.merchantCenterLinkingConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Catalog.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {google.cloud.retail.v2alpha.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.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.cloud.retail.v2alpha.Catalog(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 4: { + message.productLevelConfig = $root.google.cloud.retail.v2alpha.ProductLevelConfig.decode(reader, reader.uint32()); + break; + } + case 6: { + message.merchantCenterLinkingConfig = $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Catalog message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Catalog.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) { + var error = $root.google.cloud.retail.v2alpha.ProductLevelConfig.verify(message.productLevelConfig); + if (error) + return "productLevelConfig." + error; + } + if (message.merchantCenterLinkingConfig != null && message.hasOwnProperty("merchantCenterLinkingConfig")) { + var error = $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.verify(message.merchantCenterLinkingConfig); + if (error) + return "merchantCenterLinkingConfig." + error; + } + return null; + }; + + /** + * Creates a Catalog message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Catalog} Catalog + */ + Catalog.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Catalog) + return object; + var message = new $root.google.cloud.retail.v2alpha.Catalog(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.productLevelConfig != null) { + if (typeof object.productLevelConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Catalog.productLevelConfig: object expected"); + message.productLevelConfig = $root.google.cloud.retail.v2alpha.ProductLevelConfig.fromObject(object.productLevelConfig); + } + if (object.merchantCenterLinkingConfig != null) { + if (typeof object.merchantCenterLinkingConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Catalog.merchantCenterLinkingConfig: object expected"); + message.merchantCenterLinkingConfig = $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.fromObject(object.merchantCenterLinkingConfig); + } + return message; + }; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {google.cloud.retail.v2alpha.Catalog} message Catalog + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Catalog.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.productLevelConfig = null; + object.merchantCenterLinkingConfig = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) + object.productLevelConfig = $root.google.cloud.retail.v2alpha.ProductLevelConfig.toObject(message.productLevelConfig, options); + if (message.merchantCenterLinkingConfig != null && message.hasOwnProperty("merchantCenterLinkingConfig")) + object.merchantCenterLinkingConfig = $root.google.cloud.retail.v2alpha.MerchantCenterLinkingConfig.toObject(message.merchantCenterLinkingConfig, options); + return object; + }; + + /** + * Converts this Catalog to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Catalog + * @instance + * @returns {Object.} JSON object + */ + Catalog.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Catalog + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Catalog + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Catalog.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Catalog"; + }; + + return Catalog; + })(); + + /** + * AttributeConfigLevel enum. + * @name google.cloud.retail.v2alpha.AttributeConfigLevel + * @enum {number} + * @property {number} ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED=0 ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED value + * @property {number} PRODUCT_LEVEL_ATTRIBUTE_CONFIG=1 PRODUCT_LEVEL_ATTRIBUTE_CONFIG value + * @property {number} CATALOG_LEVEL_ATTRIBUTE_CONFIG=2 CATALOG_LEVEL_ATTRIBUTE_CONFIG value + */ + v2alpha.AttributeConfigLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_LEVEL_ATTRIBUTE_CONFIG"] = 1; + values[valuesById[2] = "CATALOG_LEVEL_ATTRIBUTE_CONFIG"] = 2; + return values; + })(); + + /** + * SolutionType enum. + * @name google.cloud.retail.v2alpha.SolutionType + * @enum {number} + * @property {number} SOLUTION_TYPE_UNSPECIFIED=0 SOLUTION_TYPE_UNSPECIFIED value + * @property {number} SOLUTION_TYPE_RECOMMENDATION=1 SOLUTION_TYPE_RECOMMENDATION value + * @property {number} SOLUTION_TYPE_SEARCH=2 SOLUTION_TYPE_SEARCH value + */ + v2alpha.SolutionType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SOLUTION_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SOLUTION_TYPE_RECOMMENDATION"] = 1; + values[valuesById[2] = "SOLUTION_TYPE_SEARCH"] = 2; + return values; + })(); + + /** + * RecommendationsFilteringOption enum. + * @name google.cloud.retail.v2alpha.RecommendationsFilteringOption + * @enum {number} + * @property {number} RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED=0 RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED value + * @property {number} RECOMMENDATIONS_FILTERING_DISABLED=1 RECOMMENDATIONS_FILTERING_DISABLED value + * @property {number} RECOMMENDATIONS_FILTERING_ENABLED=3 RECOMMENDATIONS_FILTERING_ENABLED value + */ + v2alpha.RecommendationsFilteringOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "RECOMMENDATIONS_FILTERING_DISABLED"] = 1; + values[valuesById[3] = "RECOMMENDATIONS_FILTERING_ENABLED"] = 3; + return values; + })(); + + /** + * SearchSolutionUseCase enum. + * @name google.cloud.retail.v2alpha.SearchSolutionUseCase + * @enum {number} + * @property {number} SEARCH_SOLUTION_USE_CASE_UNSPECIFIED=0 SEARCH_SOLUTION_USE_CASE_UNSPECIFIED value + * @property {number} SEARCH_SOLUTION_USE_CASE_SEARCH=1 SEARCH_SOLUTION_USE_CASE_SEARCH value + * @property {number} SEARCH_SOLUTION_USE_CASE_BROWSE=2 SEARCH_SOLUTION_USE_CASE_BROWSE value + */ + v2alpha.SearchSolutionUseCase = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCH_SOLUTION_USE_CASE_SEARCH"] = 1; + values[valuesById[2] = "SEARCH_SOLUTION_USE_CASE_BROWSE"] = 2; + return values; + })(); + + v2alpha.Condition = (function() { + + /** + * Properties of a Condition. + * @memberof google.cloud.retail.v2alpha + * @interface ICondition + * @property {Array.|null} [queryTerms] Condition queryTerms + * @property {Array.|null} [activeTimeRange] Condition activeTimeRange + */ + + /** + * Constructs a new Condition. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Condition. + * @implements ICondition + * @constructor + * @param {google.cloud.retail.v2alpha.ICondition=} [properties] Properties to set + */ + function Condition(properties) { + this.queryTerms = []; + this.activeTimeRange = []; + 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]]; + } + + /** + * Condition queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2alpha.Condition + * @instance + */ + Condition.prototype.queryTerms = $util.emptyArray; + + /** + * Condition activeTimeRange. + * @member {Array.} activeTimeRange + * @memberof google.cloud.retail.v2alpha.Condition + * @instance + */ + Condition.prototype.activeTimeRange = $util.emptyArray; + + /** + * Creates a new Condition instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {google.cloud.retail.v2alpha.ICondition=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Condition} Condition instance + */ + Condition.create = function create(properties) { + return new Condition(properties); + }; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {google.cloud.retail.v2alpha.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + $root.google.cloud.retail.v2alpha.Condition.QueryTerm.encode(message.queryTerms[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.activeTimeRange != null && message.activeTimeRange.length) + for (var i = 0; i < message.activeTimeRange.length; ++i) + $root.google.cloud.retail.v2alpha.Condition.TimeRange.encode(message.activeTimeRange[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {google.cloud.retail.v2alpha.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.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.cloud.retail.v2alpha.Condition(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push($root.google.cloud.retail.v2alpha.Condition.QueryTerm.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.activeTimeRange && message.activeTimeRange.length)) + message.activeTimeRange = []; + message.activeTimeRange.push($root.google.cloud.retail.v2alpha.Condition.TimeRange.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Condition message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Condition.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Condition.QueryTerm.verify(message.queryTerms[i]); + if (error) + return "queryTerms." + error; + } + } + if (message.activeTimeRange != null && message.hasOwnProperty("activeTimeRange")) { + if (!Array.isArray(message.activeTimeRange)) + return "activeTimeRange: array expected"; + for (var i = 0; i < message.activeTimeRange.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Condition.TimeRange.verify(message.activeTimeRange[i]); + if (error) + return "activeTimeRange." + error; + } + } + return null; + }; + + /** + * Creates a Condition message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Condition} Condition + */ + Condition.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Condition) + return object; + var message = new $root.google.cloud.retail.v2alpha.Condition(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Condition.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) { + if (typeof object.queryTerms[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Condition.queryTerms: object expected"); + message.queryTerms[i] = $root.google.cloud.retail.v2alpha.Condition.QueryTerm.fromObject(object.queryTerms[i]); + } + } + if (object.activeTimeRange) { + if (!Array.isArray(object.activeTimeRange)) + throw TypeError(".google.cloud.retail.v2alpha.Condition.activeTimeRange: array expected"); + message.activeTimeRange = []; + for (var i = 0; i < object.activeTimeRange.length; ++i) { + if (typeof object.activeTimeRange[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Condition.activeTimeRange: object expected"); + message.activeTimeRange[i] = $root.google.cloud.retail.v2alpha.Condition.TimeRange.fromObject(object.activeTimeRange[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {google.cloud.retail.v2alpha.Condition} message Condition + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Condition.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.queryTerms = []; + object.activeTimeRange = []; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = $root.google.cloud.retail.v2alpha.Condition.QueryTerm.toObject(message.queryTerms[j], options); + } + if (message.activeTimeRange && message.activeTimeRange.length) { + object.activeTimeRange = []; + for (var j = 0; j < message.activeTimeRange.length; ++j) + object.activeTimeRange[j] = $root.google.cloud.retail.v2alpha.Condition.TimeRange.toObject(message.activeTimeRange[j], options); + } + return object; + }; + + /** + * Converts this Condition to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Condition + * @instance + * @returns {Object.} JSON object + */ + Condition.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Condition + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Condition + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Condition.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Condition"; + }; + + Condition.QueryTerm = (function() { + + /** + * Properties of a QueryTerm. + * @memberof google.cloud.retail.v2alpha.Condition + * @interface IQueryTerm + * @property {string|null} [value] QueryTerm value + * @property {boolean|null} [fullMatch] QueryTerm fullMatch + */ + + /** + * Constructs a new QueryTerm. + * @memberof google.cloud.retail.v2alpha.Condition + * @classdesc Represents a QueryTerm. + * @implements IQueryTerm + * @constructor + * @param {google.cloud.retail.v2alpha.Condition.IQueryTerm=} [properties] Properties to set + */ + function QueryTerm(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]]; + } + + /** + * QueryTerm value. + * @member {string} value + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.value = ""; + + /** + * QueryTerm fullMatch. + * @member {boolean} fullMatch + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.fullMatch = false; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2alpha.Condition.IQueryTerm=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Condition.QueryTerm} QueryTerm instance + */ + QueryTerm.create = function create(properties) { + return new QueryTerm(properties); + }; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.QueryTerm.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2alpha.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.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); + if (message.fullMatch != null && Object.hasOwnProperty.call(message, "fullMatch")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullMatch); + return writer; + }; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.QueryTerm.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2alpha.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.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.cloud.retail.v2alpha.Condition.QueryTerm(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.fullMatch = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryTerm message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryTerm.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"; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + if (typeof message.fullMatch !== "boolean") + return "fullMatch: boolean expected"; + return null; + }; + + /** + * Creates a QueryTerm message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Condition.QueryTerm} QueryTerm + */ + QueryTerm.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Condition.QueryTerm) + return object; + var message = new $root.google.cloud.retail.v2alpha.Condition.QueryTerm(); + if (object.value != null) + message.value = String(object.value); + if (object.fullMatch != null) + message.fullMatch = Boolean(object.fullMatch); + return message; + }; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2alpha.Condition.QueryTerm} message QueryTerm + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryTerm.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.fullMatch = false; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + object.fullMatch = message.fullMatch; + return object; + }; + + /** + * Converts this QueryTerm to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @instance + * @returns {Object.} JSON object + */ + QueryTerm.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryTerm + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Condition.QueryTerm + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryTerm.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Condition.QueryTerm"; + }; + + return QueryTerm; + })(); + + Condition.TimeRange = (function() { + + /** + * Properties of a TimeRange. + * @memberof google.cloud.retail.v2alpha.Condition + * @interface ITimeRange + * @property {google.protobuf.ITimestamp|null} [startTime] TimeRange startTime + * @property {google.protobuf.ITimestamp|null} [endTime] TimeRange endTime + */ + + /** + * Constructs a new TimeRange. + * @memberof google.cloud.retail.v2alpha.Condition + * @classdesc Represents a TimeRange. + * @implements ITimeRange + * @constructor + * @param {google.cloud.retail.v2alpha.Condition.ITimeRange=} [properties] Properties to set + */ + function TimeRange(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]]; + } + + /** + * TimeRange startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @instance + */ + TimeRange.prototype.startTime = null; + + /** + * TimeRange endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @instance + */ + TimeRange.prototype.endTime = null; + + /** + * Creates a new TimeRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2alpha.Condition.ITimeRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Condition.TimeRange} TimeRange instance + */ + TimeRange.create = function create(properties) { + return new TimeRange(properties); + }; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.TimeRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2alpha.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.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(); + return writer; + }; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Condition.TimeRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2alpha.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.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.cloud.retail.v2alpha.Condition.TimeRange(); + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TimeRange message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TimeRange.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; + } + return null; + }; + + /** + * Creates a TimeRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Condition.TimeRange} TimeRange + */ + TimeRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Condition.TimeRange) + return object; + var message = new $root.google.cloud.retail.v2alpha.Condition.TimeRange(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Condition.TimeRange.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Condition.TimeRange.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2alpha.Condition.TimeRange} message TimeRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TimeRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + } + 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); + return object; + }; + + /** + * Converts this TimeRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @instance + * @returns {Object.} JSON object + */ + TimeRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TimeRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Condition.TimeRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TimeRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Condition.TimeRange"; + }; + + return TimeRange; + })(); + + return Condition; + })(); + + v2alpha.Rule = (function() { + + /** + * Properties of a Rule. + * @memberof google.cloud.retail.v2alpha + * @interface IRule + * @property {google.cloud.retail.v2alpha.Rule.IBoostAction|null} [boostAction] Rule boostAction + * @property {google.cloud.retail.v2alpha.Rule.IRedirectAction|null} [redirectAction] Rule redirectAction + * @property {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction|null} [onewaySynonymsAction] Rule onewaySynonymsAction + * @property {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction|null} [doNotAssociateAction] Rule doNotAssociateAction + * @property {google.cloud.retail.v2alpha.Rule.IReplacementAction|null} [replacementAction] Rule replacementAction + * @property {google.cloud.retail.v2alpha.Rule.IIgnoreAction|null} [ignoreAction] Rule ignoreAction + * @property {google.cloud.retail.v2alpha.Rule.IFilterAction|null} [filterAction] Rule filterAction + * @property {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction|null} [twowaySynonymsAction] Rule twowaySynonymsAction + * @property {google.cloud.retail.v2alpha.ICondition|null} [condition] Rule condition + */ + + /** + * Constructs a new Rule. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Rule. + * @implements IRule + * @constructor + * @param {google.cloud.retail.v2alpha.IRule=} [properties] Properties to set + */ + function Rule(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]]; + } + + /** + * Rule boostAction. + * @member {google.cloud.retail.v2alpha.Rule.IBoostAction|null|undefined} boostAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.boostAction = null; + + /** + * Rule redirectAction. + * @member {google.cloud.retail.v2alpha.Rule.IRedirectAction|null|undefined} redirectAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.redirectAction = null; + + /** + * Rule onewaySynonymsAction. + * @member {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction|null|undefined} onewaySynonymsAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.onewaySynonymsAction = null; + + /** + * Rule doNotAssociateAction. + * @member {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction|null|undefined} doNotAssociateAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.doNotAssociateAction = null; + + /** + * Rule replacementAction. + * @member {google.cloud.retail.v2alpha.Rule.IReplacementAction|null|undefined} replacementAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.replacementAction = null; + + /** + * Rule ignoreAction. + * @member {google.cloud.retail.v2alpha.Rule.IIgnoreAction|null|undefined} ignoreAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.ignoreAction = null; + + /** + * Rule filterAction. + * @member {google.cloud.retail.v2alpha.Rule.IFilterAction|null|undefined} filterAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.filterAction = null; + + /** + * Rule twowaySynonymsAction. + * @member {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction|null|undefined} twowaySynonymsAction + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.twowaySynonymsAction = null; + + /** + * Rule condition. + * @member {google.cloud.retail.v2alpha.ICondition|null|undefined} condition + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Rule.prototype.condition = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Rule action. + * @member {"boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"|undefined} action + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + */ + Object.defineProperty(Rule.prototype, "action", { + get: $util.oneOfGetter($oneOfFields = ["boostAction", "redirectAction", "onewaySynonymsAction", "doNotAssociateAction", "replacementAction", "ignoreAction", "filterAction", "twowaySynonymsAction"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Rule instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {google.cloud.retail.v2alpha.IRule=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule} Rule instance + */ + Rule.create = function create(properties) { + return new Rule(properties); + }; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {google.cloud.retail.v2alpha.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + $root.google.cloud.retail.v2alpha.Condition.encode(message.condition, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.boostAction != null && Object.hasOwnProperty.call(message, "boostAction")) + $root.google.cloud.retail.v2alpha.Rule.BoostAction.encode(message.boostAction, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.redirectAction != null && Object.hasOwnProperty.call(message, "redirectAction")) + $root.google.cloud.retail.v2alpha.Rule.RedirectAction.encode(message.redirectAction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.onewaySynonymsAction != null && Object.hasOwnProperty.call(message, "onewaySynonymsAction")) + $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.encode(message.onewaySynonymsAction, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.doNotAssociateAction != null && Object.hasOwnProperty.call(message, "doNotAssociateAction")) + $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.encode(message.doNotAssociateAction, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.replacementAction != null && Object.hasOwnProperty.call(message, "replacementAction")) + $root.google.cloud.retail.v2alpha.Rule.ReplacementAction.encode(message.replacementAction, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.ignoreAction != null && Object.hasOwnProperty.call(message, "ignoreAction")) + $root.google.cloud.retail.v2alpha.Rule.IgnoreAction.encode(message.ignoreAction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.filterAction != null && Object.hasOwnProperty.call(message, "filterAction")) + $root.google.cloud.retail.v2alpha.Rule.FilterAction.encode(message.filterAction, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.twowaySynonymsAction != null && Object.hasOwnProperty.call(message, "twowaySynonymsAction")) + $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.encode(message.twowaySynonymsAction, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {google.cloud.retail.v2alpha.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.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.cloud.retail.v2alpha.Rule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.boostAction = $root.google.cloud.retail.v2alpha.Rule.BoostAction.decode(reader, reader.uint32()); + break; + } + case 3: { + message.redirectAction = $root.google.cloud.retail.v2alpha.Rule.RedirectAction.decode(reader, reader.uint32()); + break; + } + case 6: { + message.onewaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 7: { + message.doNotAssociateAction = $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.decode(reader, reader.uint32()); + break; + } + case 8: { + message.replacementAction = $root.google.cloud.retail.v2alpha.Rule.ReplacementAction.decode(reader, reader.uint32()); + break; + } + case 9: { + message.ignoreAction = $root.google.cloud.retail.v2alpha.Rule.IgnoreAction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.filterAction = $root.google.cloud.retail.v2alpha.Rule.FilterAction.decode(reader, reader.uint32()); + break; + } + case 11: { + message.twowaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 1: { + message.condition = $root.google.cloud.retail.v2alpha.Condition.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rule message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.BoostAction.verify(message.boostAction); + if (error) + return "boostAction." + error; + } + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.RedirectAction.verify(message.redirectAction); + if (error) + return "redirectAction." + error; + } + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.verify(message.onewaySynonymsAction); + if (error) + return "onewaySynonymsAction." + error; + } + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.verify(message.doNotAssociateAction); + if (error) + return "doNotAssociateAction." + error; + } + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.ReplacementAction.verify(message.replacementAction); + if (error) + return "replacementAction." + error; + } + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.IgnoreAction.verify(message.ignoreAction); + if (error) + return "ignoreAction." + error; + } + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.FilterAction.verify(message.filterAction); + if (error) + return "filterAction." + error; + } + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.verify(message.twowaySynonymsAction); + if (error) + return "twowaySynonymsAction." + error; + } + } + if (message.condition != null && message.hasOwnProperty("condition")) { + var error = $root.google.cloud.retail.v2alpha.Condition.verify(message.condition); + if (error) + return "condition." + error; + } + return null; + }; + + /** + * Creates a Rule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule} Rule + */ + Rule.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule(); + if (object.boostAction != null) { + if (typeof object.boostAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.boostAction: object expected"); + message.boostAction = $root.google.cloud.retail.v2alpha.Rule.BoostAction.fromObject(object.boostAction); + } + if (object.redirectAction != null) { + if (typeof object.redirectAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.redirectAction: object expected"); + message.redirectAction = $root.google.cloud.retail.v2alpha.Rule.RedirectAction.fromObject(object.redirectAction); + } + if (object.onewaySynonymsAction != null) { + if (typeof object.onewaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.onewaySynonymsAction: object expected"); + message.onewaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.fromObject(object.onewaySynonymsAction); + } + if (object.doNotAssociateAction != null) { + if (typeof object.doNotAssociateAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.doNotAssociateAction: object expected"); + message.doNotAssociateAction = $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.fromObject(object.doNotAssociateAction); + } + if (object.replacementAction != null) { + if (typeof object.replacementAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.replacementAction: object expected"); + message.replacementAction = $root.google.cloud.retail.v2alpha.Rule.ReplacementAction.fromObject(object.replacementAction); + } + if (object.ignoreAction != null) { + if (typeof object.ignoreAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.ignoreAction: object expected"); + message.ignoreAction = $root.google.cloud.retail.v2alpha.Rule.IgnoreAction.fromObject(object.ignoreAction); + } + if (object.filterAction != null) { + if (typeof object.filterAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.filterAction: object expected"); + message.filterAction = $root.google.cloud.retail.v2alpha.Rule.FilterAction.fromObject(object.filterAction); + } + if (object.twowaySynonymsAction != null) { + if (typeof object.twowaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.twowaySynonymsAction: object expected"); + message.twowaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.fromObject(object.twowaySynonymsAction); + } + if (object.condition != null) { + if (typeof object.condition !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Rule.condition: object expected"); + message.condition = $root.google.cloud.retail.v2alpha.Condition.fromObject(object.condition); + } + return message; + }; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {google.cloud.retail.v2alpha.Rule} message Rule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.condition = null; + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = $root.google.cloud.retail.v2alpha.Condition.toObject(message.condition, options); + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + object.boostAction = $root.google.cloud.retail.v2alpha.Rule.BoostAction.toObject(message.boostAction, options); + if (options.oneofs) + object.action = "boostAction"; + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + object.redirectAction = $root.google.cloud.retail.v2alpha.Rule.RedirectAction.toObject(message.redirectAction, options); + if (options.oneofs) + object.action = "redirectAction"; + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + object.onewaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.toObject(message.onewaySynonymsAction, options); + if (options.oneofs) + object.action = "onewaySynonymsAction"; + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + object.doNotAssociateAction = $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.toObject(message.doNotAssociateAction, options); + if (options.oneofs) + object.action = "doNotAssociateAction"; + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + object.replacementAction = $root.google.cloud.retail.v2alpha.Rule.ReplacementAction.toObject(message.replacementAction, options); + if (options.oneofs) + object.action = "replacementAction"; + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + object.ignoreAction = $root.google.cloud.retail.v2alpha.Rule.IgnoreAction.toObject(message.ignoreAction, options); + if (options.oneofs) + object.action = "ignoreAction"; + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + object.filterAction = $root.google.cloud.retail.v2alpha.Rule.FilterAction.toObject(message.filterAction, options); + if (options.oneofs) + object.action = "filterAction"; + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + object.twowaySynonymsAction = $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.toObject(message.twowaySynonymsAction, options); + if (options.oneofs) + object.action = "twowaySynonymsAction"; + } + return object; + }; + + /** + * Converts this Rule to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule + * @instance + * @returns {Object.} JSON object + */ + Rule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rule + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule"; + }; + + Rule.BoostAction = (function() { + + /** + * Properties of a BoostAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IBoostAction + * @property {number|null} [boost] BoostAction boost + * @property {string|null} [productsFilter] BoostAction productsFilter + */ + + /** + * Constructs a new BoostAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a BoostAction. + * @implements IBoostAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IBoostAction=} [properties] Properties to set + */ + function BoostAction(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]]; + } + + /** + * BoostAction boost. + * @member {number} boost + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @instance + */ + BoostAction.prototype.boost = 0; + + /** + * BoostAction productsFilter. + * @member {string} productsFilter + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @instance + */ + BoostAction.prototype.productsFilter = ""; + + /** + * Creates a new BoostAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IBoostAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.BoostAction} BoostAction instance + */ + BoostAction.create = function create(properties) { + return new BoostAction(properties); + }; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.BoostAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.boost); + if (message.productsFilter != null && Object.hasOwnProperty.call(message, "productsFilter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.productsFilter); + return writer; + }; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.BoostAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.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.cloud.retail.v2alpha.Rule.BoostAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.boost = reader.float(); + break; + } + case 2: { + message.productsFilter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + if (!$util.isString(message.productsFilter)) + return "productsFilter: string expected"; + return null; + }; + + /** + * Creates a BoostAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.BoostAction} BoostAction + */ + BoostAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.BoostAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.BoostAction(); + if (object.boost != null) + message.boost = Number(object.boost); + if (object.productsFilter != null) + message.productsFilter = String(object.productsFilter); + return message; + }; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.BoostAction} message BoostAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.boost = 0; + object.productsFilter = ""; + } + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + object.productsFilter = message.productsFilter; + return object; + }; + + /** + * Converts this BoostAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @instance + * @returns {Object.} JSON object + */ + BoostAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.BoostAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.BoostAction"; + }; + + return BoostAction; + })(); + + Rule.FilterAction = (function() { + + /** + * Properties of a FilterAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IFilterAction + * @property {string|null} [filter] FilterAction filter + */ + + /** + * Constructs a new FilterAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a FilterAction. + * @implements IFilterAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IFilterAction=} [properties] Properties to set + */ + function FilterAction(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]]; + } + + /** + * FilterAction filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @instance + */ + FilterAction.prototype.filter = ""; + + /** + * Creates a new FilterAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IFilterAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.FilterAction} FilterAction instance + */ + FilterAction.create = function create(properties) { + return new FilterAction(properties); + }; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.FilterAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.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); + return writer; + }; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.FilterAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.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.cloud.retail.v2alpha.Rule.FilterAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FilterAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FilterAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a FilterAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.FilterAction} FilterAction + */ + FilterAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.FilterAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.FilterAction(); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.FilterAction} message FilterAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FilterAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.filter = ""; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this FilterAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @instance + * @returns {Object.} JSON object + */ + FilterAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FilterAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.FilterAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FilterAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.FilterAction"; + }; + + return FilterAction; + })(); + + Rule.RedirectAction = (function() { + + /** + * Properties of a RedirectAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IRedirectAction + * @property {string|null} [redirectUri] RedirectAction redirectUri + */ + + /** + * Constructs a new RedirectAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a RedirectAction. + * @implements IRedirectAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IRedirectAction=} [properties] Properties to set + */ + function RedirectAction(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]]; + } + + /** + * RedirectAction redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @instance + */ + RedirectAction.prototype.redirectUri = ""; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IRedirectAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.RedirectAction} RedirectAction instance + */ + RedirectAction.create = function create(properties) { + return new RedirectAction(properties); + }; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.RedirectAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.redirectUri); + return writer; + }; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.RedirectAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.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.cloud.retail.v2alpha.Rule.RedirectAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.redirectUri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RedirectAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RedirectAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + return null; + }; + + /** + * Creates a RedirectAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.RedirectAction} RedirectAction + */ + RedirectAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.RedirectAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.RedirectAction(); + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + return message; + }; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.RedirectAction} message RedirectAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RedirectAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.redirectUri = ""; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + return object; + }; + + /** + * Converts this RedirectAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @instance + * @returns {Object.} JSON object + */ + RedirectAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RedirectAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.RedirectAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RedirectAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.RedirectAction"; + }; + + return RedirectAction; + })(); + + Rule.TwowaySynonymsAction = (function() { + + /** + * Properties of a TwowaySynonymsAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface ITwowaySynonymsAction + * @property {Array.|null} [synonyms] TwowaySynonymsAction synonyms + */ + + /** + * Constructs a new TwowaySynonymsAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a TwowaySynonymsAction. + * @implements ITwowaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction=} [properties] Properties to set + */ + function TwowaySynonymsAction(properties) { + this.synonyms = []; + 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]]; + } + + /** + * TwowaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @instance + */ + TwowaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction} TwowaySynonymsAction instance + */ + TwowaySynonymsAction.create = function create(properties) { + return new TwowaySynonymsAction(properties); + }; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.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.cloud.retail.v2alpha.Rule.TwowaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TwowaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TwowaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + return null; + }; + + /** + * Creates a TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction} TwowaySynonymsAction + */ + TwowaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction(); + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + return message; + }; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction} message TwowaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TwowaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.synonyms = []; + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + TwowaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TwowaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.TwowaySynonymsAction"; + }; + + return TwowaySynonymsAction; + })(); + + Rule.OnewaySynonymsAction = (function() { + + /** + * Properties of an OnewaySynonymsAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IOnewaySynonymsAction + * @property {Array.|null} [queryTerms] OnewaySynonymsAction queryTerms + * @property {Array.|null} [synonyms] OnewaySynonymsAction synonyms + * @property {Array.|null} [onewayTerms] OnewaySynonymsAction onewayTerms + */ + + /** + * Constructs a new OnewaySynonymsAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents an OnewaySynonymsAction. + * @implements IOnewaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction=} [properties] Properties to set + */ + function OnewaySynonymsAction(properties) { + this.queryTerms = []; + this.synonyms = []; + this.onewayTerms = []; + 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]]; + } + + /** + * OnewaySynonymsAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.queryTerms = $util.emptyArray; + + /** + * OnewaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * OnewaySynonymsAction onewayTerms. + * @member {Array.} onewayTerms + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.onewayTerms = $util.emptyArray; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction} OnewaySynonymsAction instance + */ + OnewaySynonymsAction.create = function create(properties) { + return new OnewaySynonymsAction(properties); + }; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.onewayTerms != null && message.onewayTerms.length) + for (var i = 0; i < message.onewayTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.onewayTerms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.queryTerms[i]); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.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.cloud.retail.v2alpha.Rule.OnewaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 4: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + case 2: { + if (!(message.onewayTerms && message.onewayTerms.length)) + message.onewayTerms = []; + message.onewayTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OnewaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OnewaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + if (message.onewayTerms != null && message.hasOwnProperty("onewayTerms")) { + if (!Array.isArray(message.onewayTerms)) + return "onewayTerms: array expected"; + for (var i = 0; i < message.onewayTerms.length; ++i) + if (!$util.isString(message.onewayTerms[i])) + return "onewayTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction} OnewaySynonymsAction + */ + OnewaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + if (object.onewayTerms) { + if (!Array.isArray(object.onewayTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction.onewayTerms: array expected"); + message.onewayTerms = []; + for (var i = 0; i < object.onewayTerms.length; ++i) + message.onewayTerms[i] = String(object.onewayTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction} message OnewaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OnewaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.onewayTerms = []; + object.queryTerms = []; + object.synonyms = []; + } + if (message.onewayTerms && message.onewayTerms.length) { + object.onewayTerms = []; + for (var j = 0; j < message.onewayTerms.length; ++j) + object.onewayTerms[j] = message.onewayTerms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + OnewaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OnewaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.OnewaySynonymsAction"; + }; + + return OnewaySynonymsAction; + })(); + + Rule.DoNotAssociateAction = (function() { + + /** + * Properties of a DoNotAssociateAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IDoNotAssociateAction + * @property {Array.|null} [queryTerms] DoNotAssociateAction queryTerms + * @property {Array.|null} [doNotAssociateTerms] DoNotAssociateAction doNotAssociateTerms + * @property {Array.|null} [terms] DoNotAssociateAction terms + */ + + /** + * Constructs a new DoNotAssociateAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a DoNotAssociateAction. + * @implements IDoNotAssociateAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction=} [properties] Properties to set + */ + function DoNotAssociateAction(properties) { + this.queryTerms = []; + this.doNotAssociateTerms = []; + this.terms = []; + 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]]; + } + + /** + * DoNotAssociateAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.queryTerms = $util.emptyArray; + + /** + * DoNotAssociateAction doNotAssociateTerms. + * @member {Array.} doNotAssociateTerms + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.doNotAssociateTerms = $util.emptyArray; + + /** + * DoNotAssociateAction terms. + * @member {Array.} terms + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.terms = $util.emptyArray; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.DoNotAssociateAction} DoNotAssociateAction instance + */ + DoNotAssociateAction.create = function create(properties) { + return new DoNotAssociateAction(properties); + }; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.terms != null && message.terms.length) + for (var i = 0; i < message.terms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.terms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.doNotAssociateTerms != null && message.doNotAssociateTerms.length) + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.doNotAssociateTerms[i]); + return writer; + }; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.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.cloud.retail.v2alpha.Rule.DoNotAssociateAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + if (!(message.doNotAssociateTerms && message.doNotAssociateTerms.length)) + message.doNotAssociateTerms = []; + message.doNotAssociateTerms.push(reader.string()); + break; + } + case 1: { + if (!(message.terms && message.terms.length)) + message.terms = []; + message.terms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DoNotAssociateAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DoNotAssociateAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.doNotAssociateTerms != null && message.hasOwnProperty("doNotAssociateTerms")) { + if (!Array.isArray(message.doNotAssociateTerms)) + return "doNotAssociateTerms: array expected"; + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + if (!$util.isString(message.doNotAssociateTerms[i])) + return "doNotAssociateTerms: string[] expected"; + } + if (message.terms != null && message.hasOwnProperty("terms")) { + if (!Array.isArray(message.terms)) + return "terms: array expected"; + for (var i = 0; i < message.terms.length; ++i) + if (!$util.isString(message.terms[i])) + return "terms: string[] expected"; + } + return null; + }; + + /** + * Creates a DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.DoNotAssociateAction} DoNotAssociateAction + */ + DoNotAssociateAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.DoNotAssociateAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.doNotAssociateTerms) { + if (!Array.isArray(object.doNotAssociateTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.doNotAssociateTerms: array expected"); + message.doNotAssociateTerms = []; + for (var i = 0; i < object.doNotAssociateTerms.length; ++i) + message.doNotAssociateTerms[i] = String(object.doNotAssociateTerms[i]); + } + if (object.terms) { + if (!Array.isArray(object.terms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.DoNotAssociateAction.terms: array expected"); + message.terms = []; + for (var i = 0; i < object.terms.length; ++i) + message.terms[i] = String(object.terms[i]); + } + return message; + }; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.DoNotAssociateAction} message DoNotAssociateAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoNotAssociateAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.terms = []; + object.queryTerms = []; + object.doNotAssociateTerms = []; + } + if (message.terms && message.terms.length) { + object.terms = []; + for (var j = 0; j < message.terms.length; ++j) + object.terms[j] = message.terms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.doNotAssociateTerms && message.doNotAssociateTerms.length) { + object.doNotAssociateTerms = []; + for (var j = 0; j < message.doNotAssociateTerms.length; ++j) + object.doNotAssociateTerms[j] = message.doNotAssociateTerms[j]; + } + return object; + }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @instance + * @returns {Object.} JSON object + */ + DoNotAssociateAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DoNotAssociateAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.DoNotAssociateAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DoNotAssociateAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.DoNotAssociateAction"; + }; + + return DoNotAssociateAction; + })(); + + Rule.ReplacementAction = (function() { + + /** + * Properties of a ReplacementAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IReplacementAction + * @property {Array.|null} [queryTerms] ReplacementAction queryTerms + * @property {string|null} [replacementTerm] ReplacementAction replacementTerm + * @property {string|null} [term] ReplacementAction term + */ + + /** + * Constructs a new ReplacementAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents a ReplacementAction. + * @implements IReplacementAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IReplacementAction=} [properties] Properties to set + */ + function ReplacementAction(properties) { + this.queryTerms = []; + 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]]; + } + + /** + * ReplacementAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.queryTerms = $util.emptyArray; + + /** + * ReplacementAction replacementTerm. + * @member {string} replacementTerm + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.replacementTerm = ""; + + /** + * ReplacementAction term. + * @member {string} term + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.term = ""; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IReplacementAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.ReplacementAction} ReplacementAction instance + */ + ReplacementAction.create = function create(properties) { + return new ReplacementAction(properties); + }; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.ReplacementAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.term != null && Object.hasOwnProperty.call(message, "term")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.term); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.replacementTerm != null && Object.hasOwnProperty.call(message, "replacementTerm")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.replacementTerm); + return writer; + }; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.ReplacementAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.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.cloud.retail.v2alpha.Rule.ReplacementAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + message.replacementTerm = reader.string(); + break; + } + case 1: { + message.term = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplacementAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplacementAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + if (!$util.isString(message.replacementTerm)) + return "replacementTerm: string expected"; + if (message.term != null && message.hasOwnProperty("term")) + if (!$util.isString(message.term)) + return "term: string expected"; + return null; + }; + + /** + * Creates a ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.ReplacementAction} ReplacementAction + */ + ReplacementAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.ReplacementAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.ReplacementAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.ReplacementAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.replacementTerm != null) + message.replacementTerm = String(object.replacementTerm); + if (object.term != null) + message.term = String(object.term); + return message; + }; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.ReplacementAction} message ReplacementAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplacementAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.queryTerms = []; + if (options.defaults) { + object.term = ""; + object.replacementTerm = ""; + } + if (message.term != null && message.hasOwnProperty("term")) + object.term = message.term; + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + object.replacementTerm = message.replacementTerm; + return object; + }; + + /** + * Converts this ReplacementAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @instance + * @returns {Object.} JSON object + */ + ReplacementAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplacementAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.ReplacementAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplacementAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.ReplacementAction"; + }; + + return ReplacementAction; + })(); + + Rule.IgnoreAction = (function() { + + /** + * Properties of an IgnoreAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @interface IIgnoreAction + * @property {Array.|null} [ignoreTerms] IgnoreAction ignoreTerms + */ + + /** + * Constructs a new IgnoreAction. + * @memberof google.cloud.retail.v2alpha.Rule + * @classdesc Represents an IgnoreAction. + * @implements IIgnoreAction + * @constructor + * @param {google.cloud.retail.v2alpha.Rule.IIgnoreAction=} [properties] Properties to set + */ + function IgnoreAction(properties) { + this.ignoreTerms = []; + 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]]; + } + + /** + * IgnoreAction ignoreTerms. + * @member {Array.} ignoreTerms + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @instance + */ + IgnoreAction.prototype.ignoreTerms = $util.emptyArray; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IIgnoreAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rule.IgnoreAction} IgnoreAction instance + */ + IgnoreAction.create = function create(properties) { + return new IgnoreAction(properties); + }; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.IgnoreAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ignoreTerms != null && message.ignoreTerms.length) + for (var i = 0; i < message.ignoreTerms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ignoreTerms[i]); + return writer; + }; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rule.IgnoreAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.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.cloud.retail.v2alpha.Rule.IgnoreAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.ignoreTerms && message.ignoreTerms.length)) + message.ignoreTerms = []; + message.ignoreTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IgnoreAction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IgnoreAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ignoreTerms != null && message.hasOwnProperty("ignoreTerms")) { + if (!Array.isArray(message.ignoreTerms)) + return "ignoreTerms: array expected"; + for (var i = 0; i < message.ignoreTerms.length; ++i) + if (!$util.isString(message.ignoreTerms[i])) + return "ignoreTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rule.IgnoreAction} IgnoreAction + */ + IgnoreAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rule.IgnoreAction) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rule.IgnoreAction(); + if (object.ignoreTerms) { + if (!Array.isArray(object.ignoreTerms)) + throw TypeError(".google.cloud.retail.v2alpha.Rule.IgnoreAction.ignoreTerms: array expected"); + message.ignoreTerms = []; + for (var i = 0; i < object.ignoreTerms.length; ++i) + message.ignoreTerms[i] = String(object.ignoreTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2alpha.Rule.IgnoreAction} message IgnoreAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IgnoreAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ignoreTerms = []; + if (message.ignoreTerms && message.ignoreTerms.length) { + object.ignoreTerms = []; + for (var j = 0; j < message.ignoreTerms.length; ++j) + object.ignoreTerms[j] = message.ignoreTerms[j]; + } + return object; + }; + + /** + * Converts this IgnoreAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @instance + * @returns {Object.} JSON object + */ + IgnoreAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IgnoreAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rule.IgnoreAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IgnoreAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rule.IgnoreAction"; + }; + + return IgnoreAction; + })(); + + return Rule; + })(); + + v2alpha.Audience = (function() { + + /** + * Properties of an Audience. + * @memberof google.cloud.retail.v2alpha + * @interface IAudience + * @property {Array.|null} [genders] Audience genders + * @property {Array.|null} [ageGroups] Audience ageGroups + */ + + /** + * Constructs a new Audience. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an Audience. + * @implements IAudience + * @constructor + * @param {google.cloud.retail.v2alpha.IAudience=} [properties] Properties to set + */ + function Audience(properties) { + this.genders = []; + this.ageGroups = []; + 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]]; + } + + /** + * Audience genders. + * @member {Array.} genders + * @memberof google.cloud.retail.v2alpha.Audience + * @instance + */ + Audience.prototype.genders = $util.emptyArray; + + /** + * Audience ageGroups. + * @member {Array.} ageGroups + * @memberof google.cloud.retail.v2alpha.Audience + * @instance + */ + Audience.prototype.ageGroups = $util.emptyArray; + + /** + * Creates a new Audience instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {google.cloud.retail.v2alpha.IAudience=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Audience} Audience instance + */ + Audience.create = function create(properties) { + return new Audience(properties); + }; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2alpha.Audience.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {google.cloud.retail.v2alpha.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.genders != null && message.genders.length) + for (var i = 0; i < message.genders.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.genders[i]); + if (message.ageGroups != null && message.ageGroups.length) + for (var i = 0; i < message.ageGroups.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ageGroups[i]); + return writer; + }; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Audience.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {google.cloud.retail.v2alpha.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.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.cloud.retail.v2alpha.Audience(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.genders && message.genders.length)) + message.genders = []; + message.genders.push(reader.string()); + break; + } + case 2: { + if (!(message.ageGroups && message.ageGroups.length)) + message.ageGroups = []; + message.ageGroups.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Audience message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Audience.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.genders != null && message.hasOwnProperty("genders")) { + if (!Array.isArray(message.genders)) + return "genders: array expected"; + for (var i = 0; i < message.genders.length; ++i) + if (!$util.isString(message.genders[i])) + return "genders: string[] expected"; + } + if (message.ageGroups != null && message.hasOwnProperty("ageGroups")) { + if (!Array.isArray(message.ageGroups)) + return "ageGroups: array expected"; + for (var i = 0; i < message.ageGroups.length; ++i) + if (!$util.isString(message.ageGroups[i])) + return "ageGroups: string[] expected"; + } + return null; + }; + + /** + * Creates an Audience message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Audience} Audience + */ + Audience.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Audience) + return object; + var message = new $root.google.cloud.retail.v2alpha.Audience(); + if (object.genders) { + if (!Array.isArray(object.genders)) + throw TypeError(".google.cloud.retail.v2alpha.Audience.genders: array expected"); + message.genders = []; + for (var i = 0; i < object.genders.length; ++i) + message.genders[i] = String(object.genders[i]); + } + if (object.ageGroups) { + if (!Array.isArray(object.ageGroups)) + throw TypeError(".google.cloud.retail.v2alpha.Audience.ageGroups: array expected"); + message.ageGroups = []; + for (var i = 0; i < object.ageGroups.length; ++i) + message.ageGroups[i] = String(object.ageGroups[i]); + } + return message; + }; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {google.cloud.retail.v2alpha.Audience} message Audience + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Audience.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.genders = []; + object.ageGroups = []; + } + if (message.genders && message.genders.length) { + object.genders = []; + for (var j = 0; j < message.genders.length; ++j) + object.genders[j] = message.genders[j]; + } + if (message.ageGroups && message.ageGroups.length) { + object.ageGroups = []; + for (var j = 0; j < message.ageGroups.length; ++j) + object.ageGroups[j] = message.ageGroups[j]; + } + return object; + }; + + /** + * Converts this Audience to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Audience + * @instance + * @returns {Object.} JSON object + */ + Audience.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Audience + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Audience + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Audience.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Audience"; + }; + + return Audience; + })(); + + v2alpha.ColorInfo = (function() { + + /** + * Properties of a ColorInfo. + * @memberof google.cloud.retail.v2alpha + * @interface IColorInfo + * @property {Array.|null} [colorFamilies] ColorInfo colorFamilies + * @property {Array.|null} [colors] ColorInfo colors + */ + + /** + * Constructs a new ColorInfo. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ColorInfo. + * @implements IColorInfo + * @constructor + * @param {google.cloud.retail.v2alpha.IColorInfo=} [properties] Properties to set + */ + function ColorInfo(properties) { + this.colorFamilies = []; + this.colors = []; + 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]]; + } + + /** + * ColorInfo colorFamilies. + * @member {Array.} colorFamilies + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @instance + */ + ColorInfo.prototype.colorFamilies = $util.emptyArray; + + /** + * ColorInfo colors. + * @member {Array.} colors + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @instance + */ + ColorInfo.prototype.colors = $util.emptyArray; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {google.cloud.retail.v2alpha.IColorInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ColorInfo} ColorInfo instance + */ + ColorInfo.create = function create(properties) { + return new ColorInfo(properties); + }; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.ColorInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {google.cloud.retail.v2alpha.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.colorFamilies != null && message.colorFamilies.length) + for (var i = 0; i < message.colorFamilies.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.colorFamilies[i]); + if (message.colors != null && message.colors.length) + for (var i = 0; i < message.colors.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.colors[i]); + return writer; + }; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ColorInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {google.cloud.retail.v2alpha.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.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.cloud.retail.v2alpha.ColorInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.colorFamilies && message.colorFamilies.length)) + message.colorFamilies = []; + message.colorFamilies.push(reader.string()); + break; + } + case 2: { + if (!(message.colors && message.colors.length)) + message.colors = []; + message.colors.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ColorInfo message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ColorInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.colorFamilies != null && message.hasOwnProperty("colorFamilies")) { + if (!Array.isArray(message.colorFamilies)) + return "colorFamilies: array expected"; + for (var i = 0; i < message.colorFamilies.length; ++i) + if (!$util.isString(message.colorFamilies[i])) + return "colorFamilies: string[] expected"; + } + if (message.colors != null && message.hasOwnProperty("colors")) { + if (!Array.isArray(message.colors)) + return "colors: array expected"; + for (var i = 0; i < message.colors.length; ++i) + if (!$util.isString(message.colors[i])) + return "colors: string[] expected"; + } + return null; + }; + + /** + * Creates a ColorInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ColorInfo} ColorInfo + */ + ColorInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ColorInfo) + return object; + var message = new $root.google.cloud.retail.v2alpha.ColorInfo(); + if (object.colorFamilies) { + if (!Array.isArray(object.colorFamilies)) + throw TypeError(".google.cloud.retail.v2alpha.ColorInfo.colorFamilies: array expected"); + message.colorFamilies = []; + for (var i = 0; i < object.colorFamilies.length; ++i) + message.colorFamilies[i] = String(object.colorFamilies[i]); + } + if (object.colors) { + if (!Array.isArray(object.colors)) + throw TypeError(".google.cloud.retail.v2alpha.ColorInfo.colors: array expected"); + message.colors = []; + for (var i = 0; i < object.colors.length; ++i) + message.colors[i] = String(object.colors[i]); + } + return message; + }; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {google.cloud.retail.v2alpha.ColorInfo} message ColorInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ColorInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.colorFamilies = []; + object.colors = []; + } + if (message.colorFamilies && message.colorFamilies.length) { + object.colorFamilies = []; + for (var j = 0; j < message.colorFamilies.length; ++j) + object.colorFamilies[j] = message.colorFamilies[j]; + } + if (message.colors && message.colors.length) { + object.colors = []; + for (var j = 0; j < message.colors.length; ++j) + object.colors[j] = message.colors[j]; + } + return object; + }; + + /** + * Converts this ColorInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @instance + * @returns {Object.} JSON object + */ + ColorInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ColorInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ColorInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ColorInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ColorInfo"; + }; + + return ColorInfo; + })(); + + v2alpha.CustomAttribute = (function() { + + /** + * Properties of a CustomAttribute. + * @memberof google.cloud.retail.v2alpha + * @interface ICustomAttribute + * @property {Array.|null} [text] CustomAttribute text + * @property {Array.|null} [numbers] CustomAttribute numbers + * @property {boolean|null} [searchable] CustomAttribute searchable + * @property {boolean|null} [indexable] CustomAttribute indexable + */ + + /** + * Constructs a new CustomAttribute. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CustomAttribute. + * @implements ICustomAttribute + * @constructor + * @param {google.cloud.retail.v2alpha.ICustomAttribute=} [properties] Properties to set + */ + function CustomAttribute(properties) { + this.text = []; + this.numbers = []; + 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]]; + } + + /** + * CustomAttribute text. + * @member {Array.} text + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + CustomAttribute.prototype.text = $util.emptyArray; + + /** + * CustomAttribute numbers. + * @member {Array.} numbers + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + CustomAttribute.prototype.numbers = $util.emptyArray; + + /** + * CustomAttribute searchable. + * @member {boolean|null|undefined} searchable + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + CustomAttribute.prototype.searchable = null; + + /** + * CustomAttribute indexable. + * @member {boolean|null|undefined} indexable + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + CustomAttribute.prototype.indexable = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CustomAttribute _searchable. + * @member {"searchable"|undefined} _searchable + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_searchable", { + get: $util.oneOfGetter($oneOfFields = ["searchable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CustomAttribute _indexable. + * @member {"indexable"|undefined} _indexable + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_indexable", { + get: $util.oneOfGetter($oneOfFields = ["indexable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICustomAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CustomAttribute} CustomAttribute instance + */ + CustomAttribute.create = function create(properties) { + return new CustomAttribute(properties); + }; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2alpha.CustomAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.text != null && message.text.length) + for (var i = 0; i < message.text.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.text[i]); + if (message.numbers != null && message.numbers.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.numbers.length; ++i) + writer.double(message.numbers[i]); + writer.ldelim(); + } + if (message.searchable != null && Object.hasOwnProperty.call(message, "searchable")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.searchable); + if (message.indexable != null && Object.hasOwnProperty.call(message, "indexable")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.indexable); + return writer; + }; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CustomAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {google.cloud.retail.v2alpha.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.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.cloud.retail.v2alpha.CustomAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.text && message.text.length)) + message.text = []; + message.text.push(reader.string()); + break; + } + case 2: { + if (!(message.numbers && message.numbers.length)) + message.numbers = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.numbers.push(reader.double()); + } else + message.numbers.push(reader.double()); + break; + } + case 3: { + message.searchable = reader.bool(); + break; + } + case 4: { + message.indexable = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomAttribute message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.text != null && message.hasOwnProperty("text")) { + if (!Array.isArray(message.text)) + return "text: array expected"; + for (var i = 0; i < message.text.length; ++i) + if (!$util.isString(message.text[i])) + return "text: string[] expected"; + } + if (message.numbers != null && message.hasOwnProperty("numbers")) { + if (!Array.isArray(message.numbers)) + return "numbers: array expected"; + for (var i = 0; i < message.numbers.length; ++i) + if (typeof message.numbers[i] !== "number") + return "numbers: number[] expected"; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + properties._searchable = 1; + if (typeof message.searchable !== "boolean") + return "searchable: boolean expected"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + properties._indexable = 1; + if (typeof message.indexable !== "boolean") + return "indexable: boolean expected"; + } + return null; + }; + + /** + * Creates a CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CustomAttribute} CustomAttribute + */ + CustomAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CustomAttribute) + return object; + var message = new $root.google.cloud.retail.v2alpha.CustomAttribute(); + if (object.text) { + if (!Array.isArray(object.text)) + throw TypeError(".google.cloud.retail.v2alpha.CustomAttribute.text: array expected"); + message.text = []; + for (var i = 0; i < object.text.length; ++i) + message.text[i] = String(object.text[i]); + } + if (object.numbers) { + if (!Array.isArray(object.numbers)) + throw TypeError(".google.cloud.retail.v2alpha.CustomAttribute.numbers: array expected"); + message.numbers = []; + for (var i = 0; i < object.numbers.length; ++i) + message.numbers[i] = Number(object.numbers[i]); + } + if (object.searchable != null) + message.searchable = Boolean(object.searchable); + if (object.indexable != null) + message.indexable = Boolean(object.indexable); + return message; + }; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {google.cloud.retail.v2alpha.CustomAttribute} message CustomAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.text = []; + object.numbers = []; + } + if (message.text && message.text.length) { + object.text = []; + for (var j = 0; j < message.text.length; ++j) + object.text[j] = message.text[j]; + } + if (message.numbers && message.numbers.length) { + object.numbers = []; + for (var j = 0; j < message.numbers.length; ++j) + object.numbers[j] = options.json && !isFinite(message.numbers[j]) ? String(message.numbers[j]) : message.numbers[j]; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + object.searchable = message.searchable; + if (options.oneofs) + object._searchable = "searchable"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + object.indexable = message.indexable; + if (options.oneofs) + object._indexable = "indexable"; + } + return object; + }; + + /** + * Converts this CustomAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @instance + * @returns {Object.} JSON object + */ + CustomAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CustomAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CustomAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CustomAttribute"; + }; + + return CustomAttribute; + })(); + + v2alpha.FulfillmentInfo = (function() { + + /** + * Properties of a FulfillmentInfo. + * @memberof google.cloud.retail.v2alpha + * @interface IFulfillmentInfo + * @property {string|null} [type] FulfillmentInfo type + * @property {Array.|null} [placeIds] FulfillmentInfo placeIds + */ + + /** + * Constructs a new FulfillmentInfo. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a FulfillmentInfo. + * @implements IFulfillmentInfo + * @constructor + * @param {google.cloud.retail.v2alpha.IFulfillmentInfo=} [properties] Properties to set + */ + function FulfillmentInfo(properties) { + this.placeIds = []; + 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]]; + } + + /** + * FulfillmentInfo type. + * @member {string} type + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.type = ""; + + /** + * FulfillmentInfo placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.placeIds = $util.emptyArray; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2alpha.IFulfillmentInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.FulfillmentInfo} FulfillmentInfo instance + */ + FulfillmentInfo.create = function create(properties) { + return new FulfillmentInfo(properties); + }; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.FulfillmentInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2alpha.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + return writer; + }; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.FulfillmentInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2alpha.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.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.cloud.retail.v2alpha.FulfillmentInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FulfillmentInfo message. + * @function verify + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FulfillmentInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + return null; + }; + + /** + * Creates a FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.FulfillmentInfo} FulfillmentInfo + */ + FulfillmentInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.FulfillmentInfo) + return object; + var message = new $root.google.cloud.retail.v2alpha.FulfillmentInfo(); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2alpha.FulfillmentInfo.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2alpha.FulfillmentInfo} message FulfillmentInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FulfillmentInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) + object.type = ""; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + return object; + }; + + /** + * Converts this FulfillmentInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @instance + * @returns {Object.} JSON object + */ + FulfillmentInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FulfillmentInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.FulfillmentInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FulfillmentInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.FulfillmentInfo"; + }; + + return FulfillmentInfo; + })(); + + v2alpha.Image = (function() { + + /** + * Properties of an Image. + * @memberof google.cloud.retail.v2alpha + * @interface IImage + * @property {string|null} [uri] Image uri + * @property {number|null} [height] Image height + * @property {number|null} [width] Image width + */ + + /** + * Constructs a new Image. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an Image. + * @implements IImage + * @constructor + * @param {google.cloud.retail.v2alpha.IImage=} [properties] Properties to set + */ + function Image(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]]; + } + + /** + * Image uri. + * @member {string} uri + * @memberof google.cloud.retail.v2alpha.Image + * @instance + */ + Image.prototype.uri = ""; + + /** + * Image height. + * @member {number} height + * @memberof google.cloud.retail.v2alpha.Image + * @instance + */ + Image.prototype.height = 0; + + /** + * Image width. + * @member {number} width + * @memberof google.cloud.retail.v2alpha.Image + * @instance + */ + Image.prototype.width = 0; + + /** + * Creates a new Image instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {google.cloud.retail.v2alpha.IImage=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Image} Image instance + */ + Image.create = function create(properties) { + return new Image(properties); + }; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2alpha.Image.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {google.cloud.retail.v2alpha.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri); + if (message.height != null && Object.hasOwnProperty.call(message, "height")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.height); + if (message.width != null && Object.hasOwnProperty.call(message, "width")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.width); + return writer; + }; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Image.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {google.cloud.retail.v2alpha.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Image message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.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.cloud.retail.v2alpha.Image(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.uri = reader.string(); + break; + } + case 2: { + message.height = reader.int32(); + break; + } + case 3: { + message.width = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Image message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Image.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.height != null && message.hasOwnProperty("height")) + if (!$util.isInteger(message.height)) + return "height: integer expected"; + if (message.width != null && message.hasOwnProperty("width")) + if (!$util.isInteger(message.width)) + return "width: integer expected"; + return null; + }; + + /** + * Creates an Image message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Image} Image + */ + Image.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Image) + return object; + var message = new $root.google.cloud.retail.v2alpha.Image(); + if (object.uri != null) + message.uri = String(object.uri); + if (object.height != null) + message.height = object.height | 0; + if (object.width != null) + message.width = object.width | 0; + return message; + }; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {google.cloud.retail.v2alpha.Image} message Image + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Image.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.uri = ""; + object.height = 0; + object.width = 0; + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.height != null && message.hasOwnProperty("height")) + object.height = message.height; + if (message.width != null && message.hasOwnProperty("width")) + object.width = message.width; + return object; + }; + + /** + * Converts this Image to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Image + * @instance + * @returns {Object.} JSON object + */ + Image.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Image + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Image + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Image.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Image"; + }; + + return Image; + })(); + + v2alpha.Interval = (function() { + + /** + * Properties of an Interval. + * @memberof google.cloud.retail.v2alpha + * @interface IInterval + * @property {number|null} [minimum] Interval minimum + * @property {number|null} [exclusiveMinimum] Interval exclusiveMinimum + * @property {number|null} [maximum] Interval maximum + * @property {number|null} [exclusiveMaximum] Interval exclusiveMaximum + */ + + /** + * Constructs a new Interval. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an Interval. + * @implements IInterval + * @constructor + * @param {google.cloud.retail.v2alpha.IInterval=} [properties] Properties to set + */ + function Interval(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]]; + } + + /** + * Interval minimum. + * @member {number|null|undefined} minimum + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Interval.prototype.minimum = null; + + /** + * Interval exclusiveMinimum. + * @member {number|null|undefined} exclusiveMinimum + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Interval.prototype.exclusiveMinimum = null; + + /** + * Interval maximum. + * @member {number|null|undefined} maximum + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Interval.prototype.maximum = null; + + /** + * Interval exclusiveMaximum. + * @member {number|null|undefined} exclusiveMaximum + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Interval.prototype.exclusiveMaximum = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Interval min. + * @member {"minimum"|"exclusiveMinimum"|undefined} min + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "min", { + get: $util.oneOfGetter($oneOfFields = ["minimum", "exclusiveMinimum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Interval max. + * @member {"maximum"|"exclusiveMaximum"|undefined} max + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "max", { + get: $util.oneOfGetter($oneOfFields = ["maximum", "exclusiveMaximum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Interval instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {google.cloud.retail.v2alpha.IInterval=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Interval} Interval instance + */ + Interval.create = function create(properties) { + return new Interval(properties); + }; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2alpha.Interval.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {google.cloud.retail.v2alpha.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.minimum != null && Object.hasOwnProperty.call(message, "minimum")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.minimum); + if (message.exclusiveMinimum != null && Object.hasOwnProperty.call(message, "exclusiveMinimum")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.exclusiveMinimum); + if (message.maximum != null && Object.hasOwnProperty.call(message, "maximum")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.maximum); + if (message.exclusiveMaximum != null && Object.hasOwnProperty.call(message, "exclusiveMaximum")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.exclusiveMaximum); + return writer; + }; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Interval.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {google.cloud.retail.v2alpha.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.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.cloud.retail.v2alpha.Interval(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.minimum = reader.double(); + break; + } + case 2: { + message.exclusiveMinimum = reader.double(); + break; + } + case 3: { + message.maximum = reader.double(); + break; + } + case 4: { + message.exclusiveMaximum = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Interval message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Interval.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + properties.min = 1; + if (typeof message.minimum !== "number") + return "minimum: number expected"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + if (properties.min === 1) + return "min: multiple values"; + properties.min = 1; + if (typeof message.exclusiveMinimum !== "number") + return "exclusiveMinimum: number expected"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + properties.max = 1; + if (typeof message.maximum !== "number") + return "maximum: number expected"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + if (properties.max === 1) + return "max: multiple values"; + properties.max = 1; + if (typeof message.exclusiveMaximum !== "number") + return "exclusiveMaximum: number expected"; + } + return null; + }; + + /** + * Creates an Interval message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Interval} Interval + */ + Interval.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Interval) + return object; + var message = new $root.google.cloud.retail.v2alpha.Interval(); + if (object.minimum != null) + message.minimum = Number(object.minimum); + if (object.exclusiveMinimum != null) + message.exclusiveMinimum = Number(object.exclusiveMinimum); + if (object.maximum != null) + message.maximum = Number(object.maximum); + if (object.exclusiveMaximum != null) + message.exclusiveMaximum = Number(object.exclusiveMaximum); + return message; + }; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {google.cloud.retail.v2alpha.Interval} message Interval + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Interval.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = options.json && !isFinite(message.minimum) ? String(message.minimum) : message.minimum; + if (options.oneofs) + object.min = "minimum"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + object.exclusiveMinimum = options.json && !isFinite(message.exclusiveMinimum) ? String(message.exclusiveMinimum) : message.exclusiveMinimum; + if (options.oneofs) + object.min = "exclusiveMinimum"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = options.json && !isFinite(message.maximum) ? String(message.maximum) : message.maximum; + if (options.oneofs) + object.max = "maximum"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + object.exclusiveMaximum = options.json && !isFinite(message.exclusiveMaximum) ? String(message.exclusiveMaximum) : message.exclusiveMaximum; + if (options.oneofs) + object.max = "exclusiveMaximum"; + } + return object; + }; + + /** + * Converts this Interval to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Interval + * @instance + * @returns {Object.} JSON object + */ + Interval.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Interval + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Interval + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Interval.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Interval"; + }; + + return Interval; + })(); + + v2alpha.PriceInfo = (function() { + + /** + * Properties of a PriceInfo. + * @memberof google.cloud.retail.v2alpha + * @interface IPriceInfo + * @property {string|null} [currencyCode] PriceInfo currencyCode + * @property {number|null} [price] PriceInfo price + * @property {number|null} [originalPrice] PriceInfo originalPrice + * @property {number|null} [cost] PriceInfo cost + * @property {google.protobuf.ITimestamp|null} [priceEffectiveTime] PriceInfo priceEffectiveTime + * @property {google.protobuf.ITimestamp|null} [priceExpireTime] PriceInfo priceExpireTime + * @property {google.cloud.retail.v2alpha.PriceInfo.IPriceRange|null} [priceRange] PriceInfo priceRange + */ + + /** + * Constructs a new PriceInfo. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PriceInfo. + * @implements IPriceInfo + * @constructor + * @param {google.cloud.retail.v2alpha.IPriceInfo=} [properties] Properties to set + */ + function PriceInfo(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]]; + } + + /** + * PriceInfo currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.currencyCode = ""; + + /** + * PriceInfo price. + * @member {number} price + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.price = 0; + + /** + * PriceInfo originalPrice. + * @member {number} originalPrice + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.originalPrice = 0; + + /** + * PriceInfo cost. + * @member {number} cost + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.cost = 0; + + /** + * PriceInfo priceEffectiveTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceEffectiveTime + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.priceEffectiveTime = null; + + /** + * PriceInfo priceExpireTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceExpireTime + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.priceExpireTime = null; + + /** + * PriceInfo priceRange. + * @member {google.cloud.retail.v2alpha.PriceInfo.IPriceRange|null|undefined} priceRange + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + */ + PriceInfo.prototype.priceRange = null; + + /** + * Creates a new PriceInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {google.cloud.retail.v2alpha.IPriceInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PriceInfo} PriceInfo instance + */ + PriceInfo.create = function create(properties) { + return new PriceInfo(properties); + }; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {google.cloud.retail.v2alpha.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.currencyCode); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.price); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.originalPrice); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.priceEffectiveTime != null && Object.hasOwnProperty.call(message, "priceEffectiveTime")) + $root.google.protobuf.Timestamp.encode(message.priceEffectiveTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.priceExpireTime != null && Object.hasOwnProperty.call(message, "priceExpireTime")) + $root.google.protobuf.Timestamp.encode(message.priceExpireTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.priceRange != null && Object.hasOwnProperty.call(message, "priceRange")) + $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange.encode(message.priceRange, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {google.cloud.retail.v2alpha.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.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.cloud.retail.v2alpha.PriceInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.currencyCode = reader.string(); + break; + } + case 2: { + message.price = reader.float(); + break; + } + case 3: { + message.originalPrice = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.priceEffectiveTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.priceExpireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 7: { + message.priceRange = $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceInfo message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + if (message.price != null && message.hasOwnProperty("price")) + if (typeof message.price !== "number") + return "price: number expected"; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + if (typeof message.originalPrice !== "number") + return "originalPrice: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceEffectiveTime); + if (error) + return "priceEffectiveTime." + error; + } + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceExpireTime); + if (error) + return "priceExpireTime." + error; + } + if (message.priceRange != null && message.hasOwnProperty("priceRange")) { + var error = $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange.verify(message.priceRange); + if (error) + return "priceRange." + error; + } + return null; + }; + + /** + * Creates a PriceInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PriceInfo} PriceInfo + */ + PriceInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PriceInfo) + return object; + var message = new $root.google.cloud.retail.v2alpha.PriceInfo(); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + if (object.price != null) + message.price = Number(object.price); + if (object.originalPrice != null) + message.originalPrice = Number(object.originalPrice); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.priceEffectiveTime != null) { + if (typeof object.priceEffectiveTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PriceInfo.priceEffectiveTime: object expected"); + message.priceEffectiveTime = $root.google.protobuf.Timestamp.fromObject(object.priceEffectiveTime); + } + if (object.priceExpireTime != null) { + if (typeof object.priceExpireTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PriceInfo.priceExpireTime: object expected"); + message.priceExpireTime = $root.google.protobuf.Timestamp.fromObject(object.priceExpireTime); + } + if (object.priceRange != null) { + if (typeof object.priceRange !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PriceInfo.priceRange: object expected"); + message.priceRange = $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange.fromObject(object.priceRange); + } + return message; + }; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {google.cloud.retail.v2alpha.PriceInfo} message PriceInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.currencyCode = ""; + object.price = 0; + object.originalPrice = 0; + object.cost = 0; + object.priceEffectiveTime = null; + object.priceExpireTime = null; + object.priceRange = null; + } + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + if (message.price != null && message.hasOwnProperty("price")) + object.price = options.json && !isFinite(message.price) ? String(message.price) : message.price; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = options.json && !isFinite(message.originalPrice) ? String(message.originalPrice) : message.originalPrice; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) + object.priceEffectiveTime = $root.google.protobuf.Timestamp.toObject(message.priceEffectiveTime, options); + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) + object.priceExpireTime = $root.google.protobuf.Timestamp.toObject(message.priceExpireTime, options); + if (message.priceRange != null && message.hasOwnProperty("priceRange")) + object.priceRange = $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange.toObject(message.priceRange, options); + return object; + }; + + /** + * Converts this PriceInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @instance + * @returns {Object.} JSON object + */ + PriceInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PriceInfo"; + }; + + PriceInfo.PriceRange = (function() { + + /** + * Properties of a PriceRange. + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @interface IPriceRange + * @property {google.cloud.retail.v2alpha.IInterval|null} [price] PriceRange price + * @property {google.cloud.retail.v2alpha.IInterval|null} [originalPrice] PriceRange originalPrice + */ + + /** + * Constructs a new PriceRange. + * @memberof google.cloud.retail.v2alpha.PriceInfo + * @classdesc Represents a PriceRange. + * @implements IPriceRange + * @constructor + * @param {google.cloud.retail.v2alpha.PriceInfo.IPriceRange=} [properties] Properties to set + */ + function PriceRange(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]]; + } + + /** + * PriceRange price. + * @member {google.cloud.retail.v2alpha.IInterval|null|undefined} price + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.price = null; + + /** + * PriceRange originalPrice. + * @member {google.cloud.retail.v2alpha.IInterval|null|undefined} originalPrice + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.originalPrice = null; + + /** + * Creates a new PriceRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2alpha.PriceInfo.IPriceRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PriceInfo.PriceRange} PriceRange instance + */ + PriceRange.create = function create(properties) { + return new PriceRange(properties); + }; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.PriceRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2alpha.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + $root.google.cloud.retail.v2alpha.Interval.encode(message.price, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + $root.google.cloud.retail.v2alpha.Interval.encode(message.originalPrice, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PriceInfo.PriceRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2alpha.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.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.cloud.retail.v2alpha.PriceInfo.PriceRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.price = $root.google.cloud.retail.v2alpha.Interval.decode(reader, reader.uint32()); + break; + } + case 2: { + message.originalPrice = $root.google.cloud.retail.v2alpha.Interval.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceRange message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.price != null && message.hasOwnProperty("price")) { + var error = $root.google.cloud.retail.v2alpha.Interval.verify(message.price); + if (error) + return "price." + error; + } + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) { + var error = $root.google.cloud.retail.v2alpha.Interval.verify(message.originalPrice); + if (error) + return "originalPrice." + error; + } + return null; + }; + + /** + * Creates a PriceRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PriceInfo.PriceRange} PriceRange + */ + PriceRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange) + return object; + var message = new $root.google.cloud.retail.v2alpha.PriceInfo.PriceRange(); + if (object.price != null) { + if (typeof object.price !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PriceInfo.PriceRange.price: object expected"); + message.price = $root.google.cloud.retail.v2alpha.Interval.fromObject(object.price); + } + if (object.originalPrice != null) { + if (typeof object.originalPrice !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PriceInfo.PriceRange.originalPrice: object expected"); + message.originalPrice = $root.google.cloud.retail.v2alpha.Interval.fromObject(object.originalPrice); + } + return message; + }; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2alpha.PriceInfo.PriceRange} message PriceRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.price = null; + object.originalPrice = null; + } + if (message.price != null && message.hasOwnProperty("price")) + object.price = $root.google.cloud.retail.v2alpha.Interval.toObject(message.price, options); + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = $root.google.cloud.retail.v2alpha.Interval.toObject(message.originalPrice, options); + return object; + }; + + /** + * Converts this PriceRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @instance + * @returns {Object.} JSON object + */ + PriceRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PriceInfo.PriceRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PriceInfo.PriceRange"; + }; + + return PriceRange; + })(); + + return PriceInfo; + })(); + + v2alpha.Rating = (function() { + + /** + * Properties of a Rating. + * @memberof google.cloud.retail.v2alpha + * @interface IRating + * @property {number|null} [ratingCount] Rating ratingCount + * @property {number|null} [averageRating] Rating averageRating + * @property {Array.|null} [ratingHistogram] Rating ratingHistogram + */ + + /** + * Constructs a new Rating. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Rating. + * @implements IRating + * @constructor + * @param {google.cloud.retail.v2alpha.IRating=} [properties] Properties to set + */ + function Rating(properties) { + this.ratingHistogram = []; + 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]]; + } + + /** + * Rating ratingCount. + * @member {number} ratingCount + * @memberof google.cloud.retail.v2alpha.Rating + * @instance + */ + Rating.prototype.ratingCount = 0; + + /** + * Rating averageRating. + * @member {number} averageRating + * @memberof google.cloud.retail.v2alpha.Rating + * @instance + */ + Rating.prototype.averageRating = 0; + + /** + * Rating ratingHistogram. + * @member {Array.} ratingHistogram + * @memberof google.cloud.retail.v2alpha.Rating + * @instance + */ + Rating.prototype.ratingHistogram = $util.emptyArray; + + /** + * Creates a new Rating instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {google.cloud.retail.v2alpha.IRating=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Rating} Rating instance + */ + Rating.create = function create(properties) { + return new Rating(properties); + }; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2alpha.Rating.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {google.cloud.retail.v2alpha.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ratingCount != null && Object.hasOwnProperty.call(message, "ratingCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ratingCount); + if (message.averageRating != null && Object.hasOwnProperty.call(message, "averageRating")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.averageRating); + if (message.ratingHistogram != null && message.ratingHistogram.length) { + writer.uint32(/* id 3, wireType 2 =*/26).fork(); + for (var i = 0; i < message.ratingHistogram.length; ++i) + writer.int32(message.ratingHistogram[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Rating.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {google.cloud.retail.v2alpha.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.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.cloud.retail.v2alpha.Rating(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ratingCount = reader.int32(); + break; + } + case 2: { + message.averageRating = reader.float(); + break; + } + case 3: { + if (!(message.ratingHistogram && message.ratingHistogram.length)) + message.ratingHistogram = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.ratingHistogram.push(reader.int32()); + } else + message.ratingHistogram.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rating message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rating.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + if (!$util.isInteger(message.ratingCount)) + return "ratingCount: integer expected"; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + if (typeof message.averageRating !== "number") + return "averageRating: number expected"; + if (message.ratingHistogram != null && message.hasOwnProperty("ratingHistogram")) { + if (!Array.isArray(message.ratingHistogram)) + return "ratingHistogram: array expected"; + for (var i = 0; i < message.ratingHistogram.length; ++i) + if (!$util.isInteger(message.ratingHistogram[i])) + return "ratingHistogram: integer[] expected"; + } + return null; + }; + + /** + * Creates a Rating message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Rating} Rating + */ + Rating.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Rating) + return object; + var message = new $root.google.cloud.retail.v2alpha.Rating(); + if (object.ratingCount != null) + message.ratingCount = object.ratingCount | 0; + if (object.averageRating != null) + message.averageRating = Number(object.averageRating); + if (object.ratingHistogram) { + if (!Array.isArray(object.ratingHistogram)) + throw TypeError(".google.cloud.retail.v2alpha.Rating.ratingHistogram: array expected"); + message.ratingHistogram = []; + for (var i = 0; i < object.ratingHistogram.length; ++i) + message.ratingHistogram[i] = object.ratingHistogram[i] | 0; + } + return message; + }; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {google.cloud.retail.v2alpha.Rating} message Rating + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rating.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ratingHistogram = []; + if (options.defaults) { + object.ratingCount = 0; + object.averageRating = 0; + } + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + object.ratingCount = message.ratingCount; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + object.averageRating = options.json && !isFinite(message.averageRating) ? String(message.averageRating) : message.averageRating; + if (message.ratingHistogram && message.ratingHistogram.length) { + object.ratingHistogram = []; + for (var j = 0; j < message.ratingHistogram.length; ++j) + object.ratingHistogram[j] = message.ratingHistogram[j]; + } + return object; + }; + + /** + * Converts this Rating to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Rating + * @instance + * @returns {Object.} JSON object + */ + Rating.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rating + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Rating + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rating.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Rating"; + }; + + return Rating; + })(); + + v2alpha.UserInfo = (function() { + + /** + * Properties of a UserInfo. + * @memberof google.cloud.retail.v2alpha + * @interface IUserInfo + * @property {string|null} [userId] UserInfo userId + * @property {string|null} [ipAddress] UserInfo ipAddress + * @property {string|null} [userAgent] UserInfo userAgent + * @property {boolean|null} [directUserRequest] UserInfo directUserRequest + */ + + /** + * Constructs a new UserInfo. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserInfo. + * @implements IUserInfo + * @constructor + * @param {google.cloud.retail.v2alpha.IUserInfo=} [properties] Properties to set + */ + function UserInfo(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]]; + } + + /** + * UserInfo userId. + * @member {string} userId + * @memberof google.cloud.retail.v2alpha.UserInfo + * @instance + */ + UserInfo.prototype.userId = ""; + + /** + * UserInfo ipAddress. + * @member {string} ipAddress + * @memberof google.cloud.retail.v2alpha.UserInfo + * @instance + */ + UserInfo.prototype.ipAddress = ""; + + /** + * UserInfo userAgent. + * @member {string} userAgent + * @memberof google.cloud.retail.v2alpha.UserInfo + * @instance + */ + UserInfo.prototype.userAgent = ""; + + /** + * UserInfo directUserRequest. + * @member {boolean} directUserRequest + * @memberof google.cloud.retail.v2alpha.UserInfo + * @instance + */ + UserInfo.prototype.directUserRequest = false; + + /** + * Creates a new UserInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {google.cloud.retail.v2alpha.IUserInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UserInfo} UserInfo instance + */ + UserInfo.create = function create(properties) { + return new UserInfo(properties); + }; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.UserInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {google.cloud.retail.v2alpha.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userId != null && Object.hasOwnProperty.call(message, "userId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.userId); + if (message.ipAddress != null && Object.hasOwnProperty.call(message, "ipAddress")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ipAddress); + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.userAgent); + if (message.directUserRequest != null && Object.hasOwnProperty.call(message, "directUserRequest")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.directUserRequest); + return writer; + }; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {google.cloud.retail.v2alpha.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.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.cloud.retail.v2alpha.UserInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userId = reader.string(); + break; + } + case 2: { + message.ipAddress = reader.string(); + break; + } + case 3: { + message.userAgent = reader.string(); + break; + } + case 4: { + message.directUserRequest = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserInfo message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userId != null && message.hasOwnProperty("userId")) + if (!$util.isString(message.userId)) + return "userId: string expected"; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + if (!$util.isString(message.ipAddress)) + return "ipAddress: string expected"; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + if (!$util.isString(message.userAgent)) + return "userAgent: string expected"; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + if (typeof message.directUserRequest !== "boolean") + return "directUserRequest: boolean expected"; + return null; + }; + + /** + * Creates a UserInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UserInfo} UserInfo + */ + UserInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UserInfo) + return object; + var message = new $root.google.cloud.retail.v2alpha.UserInfo(); + if (object.userId != null) + message.userId = String(object.userId); + if (object.ipAddress != null) + message.ipAddress = String(object.ipAddress); + if (object.userAgent != null) + message.userAgent = String(object.userAgent); + if (object.directUserRequest != null) + message.directUserRequest = Boolean(object.directUserRequest); + return message; + }; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {google.cloud.retail.v2alpha.UserInfo} message UserInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.userId = ""; + object.ipAddress = ""; + object.userAgent = ""; + object.directUserRequest = false; + } + if (message.userId != null && message.hasOwnProperty("userId")) + object.userId = message.userId; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + object.ipAddress = message.ipAddress; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + object.userAgent = message.userAgent; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + object.directUserRequest = message.directUserRequest; + return object; + }; + + /** + * Converts this UserInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UserInfo + * @instance + * @returns {Object.} JSON object + */ + UserInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UserInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UserInfo"; + }; + + return UserInfo; + })(); + + v2alpha.LocalInventory = (function() { + + /** + * Properties of a LocalInventory. + * @memberof google.cloud.retail.v2alpha + * @interface ILocalInventory + * @property {string|null} [placeId] LocalInventory placeId + * @property {google.cloud.retail.v2alpha.IPriceInfo|null} [priceInfo] LocalInventory priceInfo + * @property {Object.|null} [attributes] LocalInventory attributes + * @property {Array.|null} [fulfillmentTypes] LocalInventory fulfillmentTypes + */ + + /** + * Constructs a new LocalInventory. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a LocalInventory. + * @implements ILocalInventory + * @constructor + * @param {google.cloud.retail.v2alpha.ILocalInventory=} [properties] Properties to set + */ + function LocalInventory(properties) { + this.attributes = {}; + this.fulfillmentTypes = []; + 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]]; + } + + /** + * LocalInventory placeId. + * @member {string} placeId + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @instance + */ + LocalInventory.prototype.placeId = ""; + + /** + * LocalInventory priceInfo. + * @member {google.cloud.retail.v2alpha.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @instance + */ + LocalInventory.prototype.priceInfo = null; + + /** + * LocalInventory attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @instance + */ + LocalInventory.prototype.attributes = $util.emptyObject; + + /** + * LocalInventory fulfillmentTypes. + * @member {Array.} fulfillmentTypes + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @instance + */ + LocalInventory.prototype.fulfillmentTypes = $util.emptyArray; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {google.cloud.retail.v2alpha.ILocalInventory=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.LocalInventory} LocalInventory instance + */ + LocalInventory.create = function create(properties) { + return new LocalInventory(properties); + }; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2alpha.LocalInventory.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {google.cloud.retail.v2alpha.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placeId != null && Object.hasOwnProperty.call(message, "placeId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placeId); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2alpha.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2alpha.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.fulfillmentTypes != null && message.fulfillmentTypes.length) + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.fulfillmentTypes[i]); + return writer; + }; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.LocalInventory.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {google.cloud.retail.v2alpha.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.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.cloud.retail.v2alpha.LocalInventory(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placeId = reader.string(); + break; + } + case 2: { + message.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 3: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2alpha.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 4: { + if (!(message.fulfillmentTypes && message.fulfillmentTypes.length)) + message.fulfillmentTypes = []; + message.fulfillmentTypes.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LocalInventory message. + * @function verify + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LocalInventory.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placeId != null && message.hasOwnProperty("placeId")) + if (!$util.isString(message.placeId)) + return "placeId: string expected"; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2alpha.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.fulfillmentTypes != null && message.hasOwnProperty("fulfillmentTypes")) { + if (!Array.isArray(message.fulfillmentTypes)) + return "fulfillmentTypes: array expected"; + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + if (!$util.isString(message.fulfillmentTypes[i])) + return "fulfillmentTypes: string[] expected"; + } + return null; + }; + + /** + * Creates a LocalInventory message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.LocalInventory} LocalInventory + */ + LocalInventory.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.LocalInventory) + return object; + var message = new $root.google.cloud.retail.v2alpha.LocalInventory(); + if (object.placeId != null) + message.placeId = String(object.placeId); + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.LocalInventory.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.fromObject(object.priceInfo); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2alpha.LocalInventory.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.LocalInventory.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2alpha.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.fulfillmentTypes) { + if (!Array.isArray(object.fulfillmentTypes)) + throw TypeError(".google.cloud.retail.v2alpha.LocalInventory.fulfillmentTypes: array expected"); + message.fulfillmentTypes = []; + for (var i = 0; i < object.fulfillmentTypes.length; ++i) + message.fulfillmentTypes[i] = String(object.fulfillmentTypes[i]); + } + return message; + }; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {google.cloud.retail.v2alpha.LocalInventory} message LocalInventory + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocalInventory.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fulfillmentTypes = []; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.placeId = ""; + object.priceInfo = null; + } + if (message.placeId != null && message.hasOwnProperty("placeId")) + object.placeId = message.placeId; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.toObject(message.priceInfo, options); + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2alpha.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.fulfillmentTypes && message.fulfillmentTypes.length) { + object.fulfillmentTypes = []; + for (var j = 0; j < message.fulfillmentTypes.length; ++j) + object.fulfillmentTypes[j] = message.fulfillmentTypes[j]; + } + return object; + }; + + /** + * Converts this LocalInventory to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @instance + * @returns {Object.} JSON object + */ + LocalInventory.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LocalInventory + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.LocalInventory + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LocalInventory.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.LocalInventory"; + }; + + return LocalInventory; + })(); + + v2alpha.GcsSource = (function() { + + /** + * Properties of a GcsSource. + * @memberof google.cloud.retail.v2alpha + * @interface IGcsSource + * @property {Array.|null} [inputUris] GcsSource inputUris + * @property {string|null} [dataSchema] GcsSource dataSchema + */ + + /** + * Constructs a new GcsSource. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GcsSource. + * @implements IGcsSource + * @constructor + * @param {google.cloud.retail.v2alpha.IGcsSource=} [properties] Properties to set + */ + function GcsSource(properties) { + this.inputUris = []; + 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]]; + } + + /** + * GcsSource inputUris. + * @member {Array.} inputUris + * @memberof google.cloud.retail.v2alpha.GcsSource + * @instance + */ + GcsSource.prototype.inputUris = $util.emptyArray; + + /** + * GcsSource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2alpha.GcsSource + * @instance + */ + GcsSource.prototype.dataSchema = ""; + + /** + * Creates a new GcsSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {google.cloud.retail.v2alpha.IGcsSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GcsSource} GcsSource instance + */ + GcsSource.create = function create(properties) { + return new GcsSource(properties); + }; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2alpha.GcsSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {google.cloud.retail.v2alpha.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputUris != null && message.inputUris.length) + for (var i = 0; i < message.inputUris.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.inputUris[i]); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.dataSchema); + return writer; + }; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GcsSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {google.cloud.retail.v2alpha.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.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.cloud.retail.v2alpha.GcsSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.inputUris && message.inputUris.length)) + message.inputUris = []; + message.inputUris.push(reader.string()); + break; + } + case 2: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GcsSource message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GcsSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputUris != null && message.hasOwnProperty("inputUris")) { + if (!Array.isArray(message.inputUris)) + return "inputUris: array expected"; + for (var i = 0; i < message.inputUris.length; ++i) + if (!$util.isString(message.inputUris[i])) + return "inputUris: string[] expected"; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a GcsSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GcsSource} GcsSource + */ + GcsSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GcsSource) + return object; + var message = new $root.google.cloud.retail.v2alpha.GcsSource(); + if (object.inputUris) { + if (!Array.isArray(object.inputUris)) + throw TypeError(".google.cloud.retail.v2alpha.GcsSource.inputUris: array expected"); + message.inputUris = []; + for (var i = 0; i < object.inputUris.length; ++i) + message.inputUris[i] = String(object.inputUris[i]); + } + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {google.cloud.retail.v2alpha.GcsSource} message GcsSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GcsSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputUris = []; + if (options.defaults) + object.dataSchema = ""; + if (message.inputUris && message.inputUris.length) { + object.inputUris = []; + for (var j = 0; j < message.inputUris.length; ++j) + object.inputUris[j] = message.inputUris[j]; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + return object; + }; + + /** + * Converts this GcsSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GcsSource + * @instance + * @returns {Object.} JSON object + */ + GcsSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GcsSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GcsSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GcsSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GcsSource"; + }; + + return GcsSource; + })(); + + v2alpha.BigQuerySource = (function() { + + /** + * Properties of a BigQuerySource. + * @memberof google.cloud.retail.v2alpha + * @interface IBigQuerySource + * @property {google.type.IDate|null} [partitionDate] BigQuerySource partitionDate + * @property {string|null} [projectId] BigQuerySource projectId + * @property {string|null} [datasetId] BigQuerySource datasetId + * @property {string|null} [tableId] BigQuerySource tableId + * @property {string|null} [gcsStagingDir] BigQuerySource gcsStagingDir + * @property {string|null} [dataSchema] BigQuerySource dataSchema + */ + + /** + * Constructs a new BigQuerySource. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a BigQuerySource. + * @implements IBigQuerySource + * @constructor + * @param {google.cloud.retail.v2alpha.IBigQuerySource=} [properties] Properties to set + */ + function BigQuerySource(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]]; + } + + /** + * BigQuerySource partitionDate. + * @member {google.type.IDate|null|undefined} partitionDate + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.partitionDate = null; + + /** + * BigQuerySource projectId. + * @member {string} projectId + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.projectId = ""; + + /** + * BigQuerySource datasetId. + * @member {string} datasetId + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.datasetId = ""; + + /** + * BigQuerySource tableId. + * @member {string} tableId + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.tableId = ""; + + /** + * BigQuerySource gcsStagingDir. + * @member {string} gcsStagingDir + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.gcsStagingDir = ""; + + /** + * BigQuerySource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + BigQuerySource.prototype.dataSchema = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BigQuerySource partition. + * @member {"partitionDate"|undefined} partition + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + */ + Object.defineProperty(BigQuerySource.prototype, "partition", { + get: $util.oneOfGetter($oneOfFields = ["partitionDate"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {google.cloud.retail.v2alpha.IBigQuerySource=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.BigQuerySource} BigQuerySource instance + */ + BigQuerySource.create = function create(properties) { + return new BigQuerySource(properties); + }; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2alpha.BigQuerySource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {google.cloud.retail.v2alpha.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.datasetId != null && Object.hasOwnProperty.call(message, "datasetId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.datasetId); + if (message.tableId != null && Object.hasOwnProperty.call(message, "tableId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.tableId); + if (message.gcsStagingDir != null && Object.hasOwnProperty.call(message, "gcsStagingDir")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.gcsStagingDir); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.dataSchema); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.projectId); + if (message.partitionDate != null && Object.hasOwnProperty.call(message, "partitionDate")) + $root.google.type.Date.encode(message.partitionDate, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.BigQuerySource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {google.cloud.retail.v2alpha.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.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.cloud.retail.v2alpha.BigQuerySource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + message.partitionDate = $root.google.type.Date.decode(reader, reader.uint32()); + break; + } + case 5: { + message.projectId = reader.string(); + break; + } + case 1: { + message.datasetId = reader.string(); + break; + } + case 2: { + message.tableId = reader.string(); + break; + } + case 3: { + message.gcsStagingDir = reader.string(); + break; + } + case 4: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQuerySource message. + * @function verify + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQuerySource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + properties.partition = 1; + { + var error = $root.google.type.Date.verify(message.partitionDate); + if (error) + return "partitionDate." + error; + } + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + if (!$util.isString(message.datasetId)) + return "datasetId: string expected"; + if (message.tableId != null && message.hasOwnProperty("tableId")) + if (!$util.isString(message.tableId)) + return "tableId: string expected"; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + if (!$util.isString(message.gcsStagingDir)) + return "gcsStagingDir: string expected"; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.BigQuerySource} BigQuerySource + */ + BigQuerySource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.BigQuerySource) + return object; + var message = new $root.google.cloud.retail.v2alpha.BigQuerySource(); + if (object.partitionDate != null) { + if (typeof object.partitionDate !== "object") + throw TypeError(".google.cloud.retail.v2alpha.BigQuerySource.partitionDate: object expected"); + message.partitionDate = $root.google.type.Date.fromObject(object.partitionDate); + } + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.datasetId != null) + message.datasetId = String(object.datasetId); + if (object.tableId != null) + message.tableId = String(object.tableId); + if (object.gcsStagingDir != null) + message.gcsStagingDir = String(object.gcsStagingDir); + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {google.cloud.retail.v2alpha.BigQuerySource} message BigQuerySource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQuerySource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.datasetId = ""; + object.tableId = ""; + object.gcsStagingDir = ""; + object.dataSchema = ""; + object.projectId = ""; + } + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + object.datasetId = message.datasetId; + if (message.tableId != null && message.hasOwnProperty("tableId")) + object.tableId = message.tableId; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + object.gcsStagingDir = message.gcsStagingDir; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + object.partitionDate = $root.google.type.Date.toObject(message.partitionDate, options); + if (options.oneofs) + object.partition = "partitionDate"; + } + return object; + }; + + /** + * Converts this BigQuerySource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @instance + * @returns {Object.} JSON object + */ + BigQuerySource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BigQuerySource + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.BigQuerySource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BigQuerySource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.BigQuerySource"; + }; + + return BigQuerySource; + })(); + + v2alpha.ProductInlineSource = (function() { + + /** + * Properties of a ProductInlineSource. + * @memberof google.cloud.retail.v2alpha + * @interface IProductInlineSource + * @property {Array.|null} [products] ProductInlineSource products + */ + + /** + * Constructs a new ProductInlineSource. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ProductInlineSource. + * @implements IProductInlineSource + * @constructor + * @param {google.cloud.retail.v2alpha.IProductInlineSource=} [properties] Properties to set + */ + function ProductInlineSource(properties) { + this.products = []; + 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]]; + } + + /** + * ProductInlineSource products. + * @member {Array.} products + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @instance + */ + ProductInlineSource.prototype.products = $util.emptyArray; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IProductInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ProductInlineSource} ProductInlineSource instance + */ + ProductInlineSource.create = function create(properties) { + return new ProductInlineSource(properties); + }; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2alpha.Product.encode(message.products[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.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.cloud.retail.v2alpha.ProductInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + return null; + }; + + /** + * Creates a ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ProductInlineSource} ProductInlineSource + */ + ProductInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ProductInlineSource) + return object; + var message = new $root.google.cloud.retail.v2alpha.ProductInlineSource(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2alpha.ProductInlineSource.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductInlineSource.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2alpha.Product.fromObject(object.products[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {google.cloud.retail.v2alpha.ProductInlineSource} message ProductInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2alpha.Product.toObject(message.products[j], options); + } + return object; + }; + + /** + * Converts this ProductInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @instance + * @returns {Object.} JSON object + */ + ProductInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ProductInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ProductInlineSource"; + }; + + return ProductInlineSource; + })(); + + v2alpha.UserEventInlineSource = (function() { + + /** + * Properties of a UserEventInlineSource. + * @memberof google.cloud.retail.v2alpha + * @interface IUserEventInlineSource + * @property {Array.|null} [userEvents] UserEventInlineSource userEvents + */ + + /** + * Constructs a new UserEventInlineSource. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserEventInlineSource. + * @implements IUserEventInlineSource + * @constructor + * @param {google.cloud.retail.v2alpha.IUserEventInlineSource=} [properties] Properties to set + */ + function UserEventInlineSource(properties) { + this.userEvents = []; + 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]]; + } + + /** + * UserEventInlineSource userEvents. + * @member {Array.} userEvents + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @instance + */ + UserEventInlineSource.prototype.userEvents = $util.emptyArray; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UserEventInlineSource} UserEventInlineSource instance + */ + UserEventInlineSource.create = function create(properties) { + return new UserEventInlineSource(properties); + }; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEvents != null && message.userEvents.length) + for (var i = 0; i < message.userEvents.length; ++i) + $root.google.cloud.retail.v2alpha.UserEvent.encode(message.userEvents[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.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.cloud.retail.v2alpha.UserEventInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.userEvents && message.userEvents.length)) + message.userEvents = []; + message.userEvents.push($root.google.cloud.retail.v2alpha.UserEvent.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userEvents != null && message.hasOwnProperty("userEvents")) { + if (!Array.isArray(message.userEvents)) + return "userEvents: array expected"; + for (var i = 0; i < message.userEvents.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.UserEvent.verify(message.userEvents[i]); + if (error) + return "userEvents." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UserEventInlineSource} UserEventInlineSource + */ + UserEventInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UserEventInlineSource) + return object; + var message = new $root.google.cloud.retail.v2alpha.UserEventInlineSource(); + if (object.userEvents) { + if (!Array.isArray(object.userEvents)) + throw TypeError(".google.cloud.retail.v2alpha.UserEventInlineSource.userEvents: array expected"); + message.userEvents = []; + for (var i = 0; i < object.userEvents.length; ++i) { + if (typeof object.userEvents[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEventInlineSource.userEvents: object expected"); + message.userEvents[i] = $root.google.cloud.retail.v2alpha.UserEvent.fromObject(object.userEvents[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2alpha.UserEventInlineSource} message UserEventInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.userEvents = []; + if (message.userEvents && message.userEvents.length) { + object.userEvents = []; + for (var j = 0; j < message.userEvents.length; ++j) + object.userEvents[j] = $root.google.cloud.retail.v2alpha.UserEvent.toObject(message.userEvents[j], options); + } + return object; + }; + + /** + * Converts this UserEventInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @instance + * @returns {Object.} JSON object + */ + UserEventInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UserEventInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UserEventInlineSource"; + }; + + return UserEventInlineSource; + })(); + + v2alpha.ImportErrorsConfig = (function() { + + /** + * Properties of an ImportErrorsConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IImportErrorsConfig + * @property {string|null} [gcsPrefix] ImportErrorsConfig gcsPrefix + */ + + /** + * Constructs a new ImportErrorsConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportErrorsConfig. + * @implements IImportErrorsConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IImportErrorsConfig=} [properties] Properties to set + */ + function ImportErrorsConfig(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]]; + } + + /** + * ImportErrorsConfig gcsPrefix. + * @member {string|null|undefined} gcsPrefix + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @instance + */ + ImportErrorsConfig.prototype.gcsPrefix = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ImportErrorsConfig destination. + * @member {"gcsPrefix"|undefined} destination + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @instance + */ + Object.defineProperty(ImportErrorsConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsPrefix"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IImportErrorsConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportErrorsConfig} ImportErrorsConfig instance + */ + ImportErrorsConfig.create = function create(properties) { + return new ImportErrorsConfig(properties); + }; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportErrorsConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsPrefix != null && Object.hasOwnProperty.call(message, "gcsPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsPrefix); + return writer; + }; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportErrorsConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.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.cloud.retail.v2alpha.ImportErrorsConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportErrorsConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportErrorsConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + properties.destination = 1; + if (!$util.isString(message.gcsPrefix)) + return "gcsPrefix: string expected"; + } + return null; + }; + + /** + * Creates an ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportErrorsConfig} ImportErrorsConfig + */ + ImportErrorsConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportErrorsConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportErrorsConfig(); + if (object.gcsPrefix != null) + message.gcsPrefix = String(object.gcsPrefix); + return message; + }; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} message ImportErrorsConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportErrorsConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + object.gcsPrefix = message.gcsPrefix; + if (options.oneofs) + object.destination = "gcsPrefix"; + } + return object; + }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @instance + * @returns {Object.} JSON object + */ + ImportErrorsConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportErrorsConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportErrorsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportErrorsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportErrorsConfig"; + }; + + return ImportErrorsConfig; + })(); + + v2alpha.ImportProductsRequest = (function() { + + /** + * Properties of an ImportProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IImportProductsRequest + * @property {string|null} [parent] ImportProductsRequest parent + * @property {string|null} [requestId] ImportProductsRequest requestId + * @property {google.cloud.retail.v2alpha.IProductInputConfig|null} [inputConfig] ImportProductsRequest inputConfig + * @property {google.cloud.retail.v2alpha.IImportErrorsConfig|null} [errorsConfig] ImportProductsRequest errorsConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] ImportProductsRequest updateMask + * @property {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode|null} [reconciliationMode] ImportProductsRequest reconciliationMode + * @property {string|null} [notificationPubsubTopic] ImportProductsRequest notificationPubsubTopic + * @property {boolean|null} [skipDefaultBranchProtection] ImportProductsRequest skipDefaultBranchProtection + */ + + /** + * Constructs a new ImportProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportProductsRequest. + * @implements IImportProductsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IImportProductsRequest=} [properties] Properties to set + */ + function ImportProductsRequest(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]]; + } + + /** + * ImportProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.parent = ""; + + /** + * ImportProductsRequest requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.requestId = ""; + + /** + * ImportProductsRequest inputConfig. + * @member {google.cloud.retail.v2alpha.IProductInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.inputConfig = null; + + /** + * ImportProductsRequest errorsConfig. + * @member {google.cloud.retail.v2alpha.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.errorsConfig = null; + + /** + * ImportProductsRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.updateMask = null; + + /** + * ImportProductsRequest reconciliationMode. + * @member {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} reconciliationMode + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.reconciliationMode = 0; + + /** + * ImportProductsRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.notificationPubsubTopic = ""; + + /** + * ImportProductsRequest skipDefaultBranchProtection. + * @member {boolean} skipDefaultBranchProtection + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.skipDefaultBranchProtection = false; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportProductsRequest} ImportProductsRequest instance + */ + ImportProductsRequest.create = function create(properties) { + return new ImportProductsRequest(properties); + }; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2alpha.ProductInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.reconciliationMode != null && Object.hasOwnProperty.call(message, "reconciliationMode")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.reconciliationMode); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.notificationPubsubTopic); + if (message.skipDefaultBranchProtection != null && Object.hasOwnProperty.call(message, "skipDefaultBranchProtection")) + writer.uint32(/* id 8, wireType 0 =*/64).bool(message.skipDefaultBranchProtection); + return writer; + }; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.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.cloud.retail.v2alpha.ImportProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 6: { + message.requestId = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2alpha.ProductInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.reconciliationMode = reader.int32(); + break; + } + case 7: { + message.notificationPubsubTopic = reader.string(); + break; + } + case 8: { + message.skipDefaultBranchProtection = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2alpha.ProductInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + switch (message.reconciliationMode) { + default: + return "reconciliationMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + if (message.skipDefaultBranchProtection != null && message.hasOwnProperty("skipDefaultBranchProtection")) + if (typeof message.skipDefaultBranchProtection !== "boolean") + return "skipDefaultBranchProtection: boolean expected"; + return null; + }; + + /** + * Creates an ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportProductsRequest} ImportProductsRequest + */ + ImportProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2alpha.ProductInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + switch (object.reconciliationMode) { + default: + if (typeof object.reconciliationMode === "number") { + message.reconciliationMode = object.reconciliationMode; + break; + } + break; + case "RECONCILIATION_MODE_UNSPECIFIED": + case 0: + message.reconciliationMode = 0; + break; + case "INCREMENTAL": + case 1: + message.reconciliationMode = 1; + break; + case "FULL": + case 2: + message.reconciliationMode = 2; + break; + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + if (object.skipDefaultBranchProtection != null) + message.skipDefaultBranchProtection = Boolean(object.skipDefaultBranchProtection); + return message; + }; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.ImportProductsRequest} message ImportProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + object.updateMask = null; + object.reconciliationMode = options.enums === String ? "RECONCILIATION_MODE_UNSPECIFIED" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + object.skipDefaultBranchProtection = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2alpha.ProductInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + object.reconciliationMode = options.enums === String ? $root.google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] === undefined ? message.reconciliationMode : $root.google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] : message.reconciliationMode; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + if (message.skipDefaultBranchProtection != null && message.hasOwnProperty("skipDefaultBranchProtection")) + object.skipDefaultBranchProtection = message.skipDefaultBranchProtection; + return object; + }; + + /** + * Converts this ImportProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportProductsRequest"; + }; + + /** + * ReconciliationMode enum. + * @name google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode + * @enum {number} + * @property {number} RECONCILIATION_MODE_UNSPECIFIED=0 RECONCILIATION_MODE_UNSPECIFIED value + * @property {number} INCREMENTAL=1 INCREMENTAL value + * @property {number} FULL=2 FULL value + */ + ImportProductsRequest.ReconciliationMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RECONCILIATION_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INCREMENTAL"] = 1; + values[valuesById[2] = "FULL"] = 2; + return values; + })(); + + return ImportProductsRequest; + })(); + + v2alpha.ImportUserEventsRequest = (function() { + + /** + * Properties of an ImportUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IImportUserEventsRequest + * @property {string|null} [parent] ImportUserEventsRequest parent + * @property {google.cloud.retail.v2alpha.IUserEventInputConfig|null} [inputConfig] ImportUserEventsRequest inputConfig + * @property {google.cloud.retail.v2alpha.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsRequest errorsConfig + */ + + /** + * Constructs a new ImportUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportUserEventsRequest. + * @implements IImportUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest=} [properties] Properties to set + */ + function ImportUserEventsRequest(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]]; + } + + /** + * ImportUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.parent = ""; + + /** + * ImportUserEventsRequest inputConfig. + * @member {google.cloud.retail.v2alpha.IUserEventInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.inputConfig = null; + + /** + * ImportUserEventsRequest errorsConfig. + * @member {google.cloud.retail.v2alpha.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.errorsConfig = null; + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportUserEventsRequest} ImportUserEventsRequest instance + */ + ImportUserEventsRequest.create = function create(properties) { + return new ImportUserEventsRequest(properties); + }; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2alpha.UserEventInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.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.cloud.retail.v2alpha.ImportUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2alpha.UserEventInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2alpha.UserEventInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportUserEventsRequest} ImportUserEventsRequest + */ + ImportUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2alpha.UserEventInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.ImportUserEventsRequest} message ImportUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2alpha.UserEventInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportUserEventsRequest"; + }; + + return ImportUserEventsRequest; + })(); + + v2alpha.ImportCompletionDataRequest = (function() { + + /** + * Properties of an ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IImportCompletionDataRequest + * @property {string|null} [parent] ImportCompletionDataRequest parent + * @property {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null} [inputConfig] ImportCompletionDataRequest inputConfig + * @property {string|null} [notificationPubsubTopic] ImportCompletionDataRequest notificationPubsubTopic + */ + + /** + * Constructs a new ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportCompletionDataRequest. + * @implements IImportCompletionDataRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest=} [properties] Properties to set + */ + function ImportCompletionDataRequest(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]]; + } + + /** + * ImportCompletionDataRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.parent = ""; + + /** + * ImportCompletionDataRequest inputConfig. + * @member {google.cloud.retail.v2alpha.ICompletionDataInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.inputConfig = null; + + /** + * ImportCompletionDataRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataRequest} ImportCompletionDataRequest instance + */ + ImportCompletionDataRequest.create = function create(properties) { + return new ImportCompletionDataRequest(properties); + }; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.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.cloud.retail.v2alpha.ImportCompletionDataRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataRequest} ImportCompletionDataRequest + */ + ImportCompletionDataRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportCompletionDataRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportCompletionDataRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportCompletionDataRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.fromObject(object.inputConfig); + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2alpha.ImportCompletionDataRequest} message ImportCompletionDataRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.notificationPubsubTopic = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2alpha.CompletionDataInputConfig.toObject(message.inputConfig, options); + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportCompletionDataRequest"; + }; + + return ImportCompletionDataRequest; + })(); + + v2alpha.ProductInputConfig = (function() { + + /** + * Properties of a ProductInputConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IProductInputConfig + * @property {google.cloud.retail.v2alpha.IProductInlineSource|null} [productInlineSource] ProductInputConfig productInlineSource + * @property {google.cloud.retail.v2alpha.IGcsSource|null} [gcsSource] ProductInputConfig gcsSource + * @property {google.cloud.retail.v2alpha.IBigQuerySource|null} [bigQuerySource] ProductInputConfig bigQuerySource + */ + + /** + * Constructs a new ProductInputConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ProductInputConfig. + * @implements IProductInputConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IProductInputConfig=} [properties] Properties to set + */ + function ProductInputConfig(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]]; + } + + /** + * ProductInputConfig productInlineSource. + * @member {google.cloud.retail.v2alpha.IProductInlineSource|null|undefined} productInlineSource + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.productInlineSource = null; + + /** + * ProductInputConfig gcsSource. + * @member {google.cloud.retail.v2alpha.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.gcsSource = null; + + /** + * ProductInputConfig bigQuerySource. + * @member {google.cloud.retail.v2alpha.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ProductInputConfig source. + * @member {"productInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @instance + */ + Object.defineProperty(ProductInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["productInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ProductInputConfig} ProductInputConfig instance + */ + ProductInputConfig.create = function create(properties) { + return new ProductInputConfig(properties); + }; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.productInlineSource != null && Object.hasOwnProperty.call(message, "productInlineSource")) + $root.google.cloud.retail.v2alpha.ProductInlineSource.encode(message.productInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2alpha.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2alpha.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.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.cloud.retail.v2alpha.ProductInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.productInlineSource = $root.google.cloud.retail.v2alpha.ProductInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.ProductInlineSource.verify(message.productInlineSource); + if (error) + return "productInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ProductInputConfig} ProductInputConfig + */ + ProductInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ProductInputConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.ProductInputConfig(); + if (object.productInlineSource != null) { + if (typeof object.productInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductInputConfig.productInlineSource: object expected"); + message.productInlineSource = $root.google.cloud.retail.v2alpha.ProductInlineSource.fromObject(object.productInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {google.cloud.retail.v2alpha.ProductInputConfig} message ProductInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + object.productInlineSource = $root.google.cloud.retail.v2alpha.ProductInlineSource.toObject(message.productInlineSource, options); + if (options.oneofs) + object.source = "productInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this ProductInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @instance + * @returns {Object.} JSON object + */ + ProductInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ProductInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ProductInputConfig"; + }; + + return ProductInputConfig; + })(); + + v2alpha.UserEventInputConfig = (function() { + + /** + * Properties of a UserEventInputConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IUserEventInputConfig + * @property {google.cloud.retail.v2alpha.IUserEventInlineSource|null} [userEventInlineSource] UserEventInputConfig userEventInlineSource + * @property {google.cloud.retail.v2alpha.IGcsSource|null} [gcsSource] UserEventInputConfig gcsSource + * @property {google.cloud.retail.v2alpha.IBigQuerySource|null} [bigQuerySource] UserEventInputConfig bigQuerySource + */ + + /** + * Constructs a new UserEventInputConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserEventInputConfig. + * @implements IUserEventInputConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IUserEventInputConfig=} [properties] Properties to set + */ + function UserEventInputConfig(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]]; + } + + /** + * UserEventInputConfig userEventInlineSource. + * @member {google.cloud.retail.v2alpha.IUserEventInlineSource|null|undefined} userEventInlineSource + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.userEventInlineSource = null; + + /** + * UserEventInputConfig gcsSource. + * @member {google.cloud.retail.v2alpha.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.gcsSource = null; + + /** + * UserEventInputConfig bigQuerySource. + * @member {google.cloud.retail.v2alpha.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UserEventInputConfig source. + * @member {"userEventInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @instance + */ + Object.defineProperty(UserEventInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["userEventInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UserEventInputConfig} UserEventInputConfig instance + */ + UserEventInputConfig.create = function create(properties) { + return new UserEventInputConfig(properties); + }; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEventInlineSource != null && Object.hasOwnProperty.call(message, "userEventInlineSource")) + $root.google.cloud.retail.v2alpha.UserEventInlineSource.encode(message.userEventInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2alpha.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2alpha.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2alpha.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.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.cloud.retail.v2alpha.UserEventInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userEventInlineSource = $root.google.cloud.retail.v2alpha.UserEventInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.UserEventInlineSource.verify(message.userEventInlineSource); + if (error) + return "userEventInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UserEventInputConfig} UserEventInputConfig + */ + UserEventInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UserEventInputConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.UserEventInputConfig(); + if (object.userEventInlineSource != null) { + if (typeof object.userEventInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEventInputConfig.userEventInlineSource: object expected"); + message.userEventInlineSource = $root.google.cloud.retail.v2alpha.UserEventInlineSource.fromObject(object.userEventInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEventInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEventInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2alpha.UserEventInputConfig} message UserEventInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + object.userEventInlineSource = $root.google.cloud.retail.v2alpha.UserEventInlineSource.toObject(message.userEventInlineSource, options); + if (options.oneofs) + object.source = "userEventInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2alpha.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this UserEventInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @instance + * @returns {Object.} JSON object + */ + UserEventInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UserEventInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UserEventInputConfig"; + }; + + return UserEventInputConfig; + })(); + + v2alpha.CompletionDataInputConfig = (function() { + + /** + * Properties of a CompletionDataInputConfig. + * @memberof google.cloud.retail.v2alpha + * @interface ICompletionDataInputConfig + * @property {google.cloud.retail.v2alpha.IBigQuerySource|null} [bigQuerySource] CompletionDataInputConfig bigQuerySource + */ + + /** + * Constructs a new CompletionDataInputConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompletionDataInputConfig. + * @implements ICompletionDataInputConfig + * @constructor + * @param {google.cloud.retail.v2alpha.ICompletionDataInputConfig=} [properties] Properties to set + */ + function CompletionDataInputConfig(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]]; + } + + /** + * CompletionDataInputConfig bigQuerySource. + * @member {google.cloud.retail.v2alpha.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @instance + */ + CompletionDataInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CompletionDataInputConfig source. + * @member {"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @instance + */ + Object.defineProperty(CompletionDataInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDataInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompletionDataInputConfig} CompletionDataInputConfig instance + */ + CompletionDataInputConfig.create = function create(properties) { + return new CompletionDataInputConfig(properties); + }; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDataInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2alpha.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDataInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.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.cloud.retail.v2alpha.CompletionDataInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDataInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDataInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2alpha.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompletionDataInputConfig} CompletionDataInputConfig + */ + CompletionDataInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompletionDataInputConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompletionDataInputConfig(); + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompletionDataInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} message CompletionDataInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDataInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2alpha.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionDataInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompletionDataInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDataInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompletionDataInputConfig"; + }; + + return CompletionDataInputConfig; + })(); + + v2alpha.ImportMetadata = (function() { + + /** + * Properties of an ImportMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IImportMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] ImportMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ImportMetadata updateTime + * @property {number|Long|null} [successCount] ImportMetadata successCount + * @property {number|Long|null} [failureCount] ImportMetadata failureCount + * @property {string|null} [requestId] ImportMetadata requestId + * @property {string|null} [notificationPubsubTopic] ImportMetadata notificationPubsubTopic + */ + + /** + * Constructs a new ImportMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportMetadata. + * @implements IImportMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IImportMetadata=} [properties] Properties to set + */ + function ImportMetadata(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]]; + } + + /** + * ImportMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.createTime = null; + + /** + * ImportMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.updateTime = null; + + /** + * ImportMetadata successCount. + * @member {number|Long} successCount + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.successCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata failureCount. + * @member {number|Long} failureCount + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.failureCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.requestId = ""; + + /** + * ImportMetadata notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + */ + ImportMetadata.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IImportMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportMetadata} ImportMetadata instance + */ + ImportMetadata.create = function create(properties) { + return new ImportMetadata(properties); + }; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.successCount != null && Object.hasOwnProperty.call(message, "successCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.successCount); + if (message.failureCount != null && Object.hasOwnProperty.call(message, "failureCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.failureCount); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.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.cloud.retail.v2alpha.ImportMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.successCount = reader.int64(); + break; + } + case 4: { + message.failureCount = reader.int64(); + break; + } + case 5: { + message.requestId = reader.string(); + break; + } + case 6: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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.successCount != null && message.hasOwnProperty("successCount")) + if (!$util.isInteger(message.successCount) && !(message.successCount && $util.isInteger(message.successCount.low) && $util.isInteger(message.successCount.high))) + return "successCount: integer|Long expected"; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (!$util.isInteger(message.failureCount) && !(message.failureCount && $util.isInteger(message.failureCount.low) && $util.isInteger(message.failureCount.high))) + return "failureCount: integer|Long expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportMetadata} ImportMetadata + */ + ImportMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportMetadata) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.successCount != null) + if ($util.Long) + (message.successCount = $util.Long.fromValue(object.successCount)).unsigned = false; + else if (typeof object.successCount === "string") + message.successCount = parseInt(object.successCount, 10); + else if (typeof object.successCount === "number") + message.successCount = object.successCount; + else if (typeof object.successCount === "object") + message.successCount = new $util.LongBits(object.successCount.low >>> 0, object.successCount.high >>> 0).toNumber(); + if (object.failureCount != null) + if ($util.Long) + (message.failureCount = $util.Long.fromValue(object.failureCount)).unsigned = false; + else if (typeof object.failureCount === "string") + message.failureCount = parseInt(object.failureCount, 10); + else if (typeof object.failureCount === "number") + message.failureCount = object.failureCount; + else if (typeof object.failureCount === "object") + message.failureCount = new $util.LongBits(object.failureCount.low >>> 0, object.failureCount.high >>> 0).toNumber(); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {google.cloud.retail.v2alpha.ImportMetadata} message ImportMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.successCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.successCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failureCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failureCount = options.longs === String ? "0" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.successCount != null && message.hasOwnProperty("successCount")) + if (typeof message.successCount === "number") + object.successCount = options.longs === String ? String(message.successCount) : message.successCount; + else + object.successCount = options.longs === String ? $util.Long.prototype.toString.call(message.successCount) : options.longs === Number ? new $util.LongBits(message.successCount.low >>> 0, message.successCount.high >>> 0).toNumber() : message.successCount; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (typeof message.failureCount === "number") + object.failureCount = options.longs === String ? String(message.failureCount) : message.failureCount; + else + object.failureCount = options.longs === String ? $util.Long.prototype.toString.call(message.failureCount) : options.longs === Number ? new $util.LongBits(message.failureCount.low >>> 0, message.failureCount.high >>> 0).toNumber() : message.failureCount; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportMetadata"; + }; + + return ImportMetadata; + })(); + + v2alpha.ImportProductsResponse = (function() { + + /** + * Properties of an ImportProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IImportProductsResponse + * @property {Array.|null} [errorSamples] ImportProductsResponse errorSamples + * @property {google.cloud.retail.v2alpha.IImportErrorsConfig|null} [errorsConfig] ImportProductsResponse errorsConfig + */ + + /** + * Constructs a new ImportProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportProductsResponse. + * @implements IImportProductsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IImportProductsResponse=} [properties] Properties to set + */ + function ImportProductsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportProductsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportProductsResponse errorsConfig. + * @member {google.cloud.retail.v2alpha.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorsConfig = null; + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportProductsResponse} ImportProductsResponse instance + */ + ImportProductsResponse.create = function create(properties) { + return new ImportProductsResponse(properties); + }; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.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.cloud.retail.v2alpha.ImportProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportProductsResponse} ImportProductsResponse + */ + ImportProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportProductsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportProductsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.ImportProductsResponse} message ImportProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) + object.errorsConfig = null; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportProductsResponse"; + }; + + return ImportProductsResponse; + })(); + + v2alpha.ImportUserEventsResponse = (function() { + + /** + * Properties of an ImportUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IImportUserEventsResponse + * @property {Array.|null} [errorSamples] ImportUserEventsResponse errorSamples + * @property {google.cloud.retail.v2alpha.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsResponse errorsConfig + * @property {google.cloud.retail.v2alpha.IUserEventImportSummary|null} [importSummary] ImportUserEventsResponse importSummary + */ + + /** + * Constructs a new ImportUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportUserEventsResponse. + * @implements IImportUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IImportUserEventsResponse=} [properties] Properties to set + */ + function ImportUserEventsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportUserEventsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportUserEventsResponse errorsConfig. + * @member {google.cloud.retail.v2alpha.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorsConfig = null; + + /** + * ImportUserEventsResponse importSummary. + * @member {google.cloud.retail.v2alpha.IUserEventImportSummary|null|undefined} importSummary + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.importSummary = null; + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportUserEventsResponse} ImportUserEventsResponse instance + */ + ImportUserEventsResponse.create = function create(properties) { + return new ImportUserEventsResponse(properties); + }; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.importSummary != null && Object.hasOwnProperty.call(message, "importSummary")) + $root.google.cloud.retail.v2alpha.UserEventImportSummary.encode(message.importSummary, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.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.cloud.retail.v2alpha.ImportUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.importSummary = $root.google.cloud.retail.v2alpha.UserEventImportSummary.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.importSummary != null && message.hasOwnProperty("importSummary")) { + var error = $root.google.cloud.retail.v2alpha.UserEventImportSummary.verify(message.importSummary); + if (error) + return "importSummary." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportUserEventsResponse} ImportUserEventsResponse + */ + ImportUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportUserEventsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.importSummary != null) { + if (typeof object.importSummary !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportUserEventsResponse.importSummary: object expected"); + message.importSummary = $root.google.cloud.retail.v2alpha.UserEventImportSummary.fromObject(object.importSummary); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.ImportUserEventsResponse} message ImportUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.importSummary = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.importSummary != null && message.hasOwnProperty("importSummary")) + object.importSummary = $root.google.cloud.retail.v2alpha.UserEventImportSummary.toObject(message.importSummary, options); + return object; + }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportUserEventsResponse"; + }; + + return ImportUserEventsResponse; + })(); + + v2alpha.UserEventImportSummary = (function() { + + /** + * Properties of a UserEventImportSummary. + * @memberof google.cloud.retail.v2alpha + * @interface IUserEventImportSummary + * @property {number|Long|null} [joinedEventsCount] UserEventImportSummary joinedEventsCount + * @property {number|Long|null} [unjoinedEventsCount] UserEventImportSummary unjoinedEventsCount + */ + + /** + * Constructs a new UserEventImportSummary. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserEventImportSummary. + * @implements IUserEventImportSummary + * @constructor + * @param {google.cloud.retail.v2alpha.IUserEventImportSummary=} [properties] Properties to set + */ + function UserEventImportSummary(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]]; + } + + /** + * UserEventImportSummary joinedEventsCount. + * @member {number|Long} joinedEventsCount + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.joinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UserEventImportSummary unjoinedEventsCount. + * @member {number|Long} unjoinedEventsCount + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.unjoinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2alpha.IUserEventImportSummary=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UserEventImportSummary} UserEventImportSummary instance + */ + UserEventImportSummary.create = function create(properties) { + return new UserEventImportSummary(properties); + }; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventImportSummary.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2alpha.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.joinedEventsCount != null && Object.hasOwnProperty.call(message, "joinedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.joinedEventsCount); + if (message.unjoinedEventsCount != null && Object.hasOwnProperty.call(message, "unjoinedEventsCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.unjoinedEventsCount); + return writer; + }; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEventImportSummary.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2alpha.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.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.cloud.retail.v2alpha.UserEventImportSummary(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.joinedEventsCount = reader.int64(); + break; + } + case 2: { + message.unjoinedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventImportSummary message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventImportSummary.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (!$util.isInteger(message.joinedEventsCount) && !(message.joinedEventsCount && $util.isInteger(message.joinedEventsCount.low) && $util.isInteger(message.joinedEventsCount.high))) + return "joinedEventsCount: integer|Long expected"; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (!$util.isInteger(message.unjoinedEventsCount) && !(message.unjoinedEventsCount && $util.isInteger(message.unjoinedEventsCount.low) && $util.isInteger(message.unjoinedEventsCount.high))) + return "unjoinedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UserEventImportSummary} UserEventImportSummary + */ + UserEventImportSummary.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UserEventImportSummary) + return object; + var message = new $root.google.cloud.retail.v2alpha.UserEventImportSummary(); + if (object.joinedEventsCount != null) + if ($util.Long) + (message.joinedEventsCount = $util.Long.fromValue(object.joinedEventsCount)).unsigned = false; + else if (typeof object.joinedEventsCount === "string") + message.joinedEventsCount = parseInt(object.joinedEventsCount, 10); + else if (typeof object.joinedEventsCount === "number") + message.joinedEventsCount = object.joinedEventsCount; + else if (typeof object.joinedEventsCount === "object") + message.joinedEventsCount = new $util.LongBits(object.joinedEventsCount.low >>> 0, object.joinedEventsCount.high >>> 0).toNumber(); + if (object.unjoinedEventsCount != null) + if ($util.Long) + (message.unjoinedEventsCount = $util.Long.fromValue(object.unjoinedEventsCount)).unsigned = false; + else if (typeof object.unjoinedEventsCount === "string") + message.unjoinedEventsCount = parseInt(object.unjoinedEventsCount, 10); + else if (typeof object.unjoinedEventsCount === "number") + message.unjoinedEventsCount = object.unjoinedEventsCount; + else if (typeof object.unjoinedEventsCount === "object") + message.unjoinedEventsCount = new $util.LongBits(object.unjoinedEventsCount.low >>> 0, object.unjoinedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2alpha.UserEventImportSummary} message UserEventImportSummary + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventImportSummary.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.joinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.joinedEventsCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.unjoinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.unjoinedEventsCount = options.longs === String ? "0" : 0; + } + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (typeof message.joinedEventsCount === "number") + object.joinedEventsCount = options.longs === String ? String(message.joinedEventsCount) : message.joinedEventsCount; + else + object.joinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.joinedEventsCount) : options.longs === Number ? new $util.LongBits(message.joinedEventsCount.low >>> 0, message.joinedEventsCount.high >>> 0).toNumber() : message.joinedEventsCount; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (typeof message.unjoinedEventsCount === "number") + object.unjoinedEventsCount = options.longs === String ? String(message.unjoinedEventsCount) : message.unjoinedEventsCount; + else + object.unjoinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.unjoinedEventsCount) : options.longs === Number ? new $util.LongBits(message.unjoinedEventsCount.low >>> 0, message.unjoinedEventsCount.high >>> 0).toNumber() : message.unjoinedEventsCount; + return object; + }; + + /** + * Converts this UserEventImportSummary to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @instance + * @returns {Object.} JSON object + */ + UserEventImportSummary.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventImportSummary + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UserEventImportSummary + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventImportSummary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UserEventImportSummary"; + }; + + return UserEventImportSummary; + })(); + + v2alpha.ImportCompletionDataResponse = (function() { + + /** + * Properties of an ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IImportCompletionDataResponse + * @property {Array.|null} [errorSamples] ImportCompletionDataResponse errorSamples + */ + + /** + * Constructs a new ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ImportCompletionDataResponse. + * @implements IImportCompletionDataResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IImportCompletionDataResponse=} [properties] Properties to set + */ + function ImportCompletionDataResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportCompletionDataResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @instance + */ + ImportCompletionDataResponse.prototype.errorSamples = $util.emptyArray; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataResponse} ImportCompletionDataResponse instance + */ + ImportCompletionDataResponse.create = function create(properties) { + return new ImportCompletionDataResponse(properties); + }; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ImportCompletionDataResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2alpha.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.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.cloud.retail.v2alpha.ImportCompletionDataResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + return null; + }; + + /** + * Creates an ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ImportCompletionDataResponse} ImportCompletionDataResponse + */ + ImportCompletionDataResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ImportCompletionDataResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ImportCompletionDataResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2alpha.ImportCompletionDataResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ImportCompletionDataResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2alpha.ImportCompletionDataResponse} message ImportCompletionDataResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + return object; + }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ImportCompletionDataResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ImportCompletionDataResponse"; + }; + + return ImportCompletionDataResponse; + })(); + + v2alpha.Product = (function() { + + /** + * Properties of a Product. + * @memberof google.cloud.retail.v2alpha + * @interface IProduct + * @property {google.protobuf.ITimestamp|null} [expireTime] Product expireTime + * @property {google.protobuf.IDuration|null} [ttl] Product ttl + * @property {string|null} [name] Product name + * @property {string|null} [id] Product id + * @property {google.cloud.retail.v2alpha.Product.Type|null} [type] Product type + * @property {string|null} [primaryProductId] Product primaryProductId + * @property {Array.|null} [collectionMemberIds] Product collectionMemberIds + * @property {string|null} [gtin] Product gtin + * @property {Array.|null} [categories] Product categories + * @property {string|null} [title] Product title + * @property {Array.|null} [brands] Product brands + * @property {string|null} [description] Product description + * @property {string|null} [languageCode] Product languageCode + * @property {Object.|null} [attributes] Product attributes + * @property {Array.|null} [tags] Product tags + * @property {google.cloud.retail.v2alpha.IPriceInfo|null} [priceInfo] Product priceInfo + * @property {google.cloud.retail.v2alpha.IRating|null} [rating] Product rating + * @property {google.protobuf.ITimestamp|null} [availableTime] Product availableTime + * @property {google.cloud.retail.v2alpha.Product.Availability|null} [availability] Product availability + * @property {google.protobuf.IInt32Value|null} [availableQuantity] Product availableQuantity + * @property {Array.|null} [fulfillmentInfo] Product fulfillmentInfo + * @property {string|null} [uri] Product uri + * @property {Array.|null} [images] Product images + * @property {google.cloud.retail.v2alpha.IAudience|null} [audience] Product audience + * @property {google.cloud.retail.v2alpha.IColorInfo|null} [colorInfo] Product colorInfo + * @property {Array.|null} [sizes] Product sizes + * @property {Array.|null} [materials] Product materials + * @property {Array.|null} [patterns] Product patterns + * @property {Array.|null} [conditions] Product conditions + * @property {Array.|null} [promotions] Product promotions + * @property {google.protobuf.ITimestamp|null} [publishTime] Product publishTime + * @property {google.protobuf.IFieldMask|null} [retrievableFields] Product retrievableFields + * @property {Array.|null} [variants] Product variants + */ + + /** + * Constructs a new Product. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Product. + * @implements IProduct + * @constructor + * @param {google.cloud.retail.v2alpha.IProduct=} [properties] Properties to set + */ + function Product(properties) { + this.collectionMemberIds = []; + this.categories = []; + this.brands = []; + this.attributes = {}; + this.tags = []; + this.fulfillmentInfo = []; + this.images = []; + this.sizes = []; + this.materials = []; + this.patterns = []; + this.conditions = []; + this.promotions = []; + this.variants = []; + 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]]; + } + + /** + * Product expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.expireTime = null; + + /** + * Product ttl. + * @member {google.protobuf.IDuration|null|undefined} ttl + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.ttl = null; + + /** + * Product name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.name = ""; + + /** + * Product id. + * @member {string} id + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.id = ""; + + /** + * Product type. + * @member {google.cloud.retail.v2alpha.Product.Type} type + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.type = 0; + + /** + * Product primaryProductId. + * @member {string} primaryProductId + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.primaryProductId = ""; + + /** + * Product collectionMemberIds. + * @member {Array.} collectionMemberIds + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.collectionMemberIds = $util.emptyArray; + + /** + * Product gtin. + * @member {string} gtin + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.gtin = ""; + + /** + * Product categories. + * @member {Array.} categories + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.categories = $util.emptyArray; + + /** + * Product title. + * @member {string} title + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.title = ""; + + /** + * Product brands. + * @member {Array.} brands + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.brands = $util.emptyArray; + + /** + * Product description. + * @member {string} description + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.description = ""; + + /** + * Product languageCode. + * @member {string} languageCode + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.languageCode = ""; + + /** + * Product attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.attributes = $util.emptyObject; + + /** + * Product tags. + * @member {Array.} tags + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.tags = $util.emptyArray; + + /** + * Product priceInfo. + * @member {google.cloud.retail.v2alpha.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.priceInfo = null; + + /** + * Product rating. + * @member {google.cloud.retail.v2alpha.IRating|null|undefined} rating + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.rating = null; + + /** + * Product availableTime. + * @member {google.protobuf.ITimestamp|null|undefined} availableTime + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.availableTime = null; + + /** + * Product availability. + * @member {google.cloud.retail.v2alpha.Product.Availability} availability + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.availability = 0; + + /** + * Product availableQuantity. + * @member {google.protobuf.IInt32Value|null|undefined} availableQuantity + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.availableQuantity = null; + + /** + * Product fulfillmentInfo. + * @member {Array.} fulfillmentInfo + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.fulfillmentInfo = $util.emptyArray; + + /** + * Product uri. + * @member {string} uri + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.uri = ""; + + /** + * Product images. + * @member {Array.} images + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.images = $util.emptyArray; + + /** + * Product audience. + * @member {google.cloud.retail.v2alpha.IAudience|null|undefined} audience + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.audience = null; + + /** + * Product colorInfo. + * @member {google.cloud.retail.v2alpha.IColorInfo|null|undefined} colorInfo + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.colorInfo = null; + + /** + * Product sizes. + * @member {Array.} sizes + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.sizes = $util.emptyArray; + + /** + * Product materials. + * @member {Array.} materials + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.materials = $util.emptyArray; + + /** + * Product patterns. + * @member {Array.} patterns + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.patterns = $util.emptyArray; + + /** + * Product conditions. + * @member {Array.} conditions + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.conditions = $util.emptyArray; + + /** + * Product promotions. + * @member {Array.} promotions + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.promotions = $util.emptyArray; + + /** + * Product publishTime. + * @member {google.protobuf.ITimestamp|null|undefined} publishTime + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.publishTime = null; + + /** + * Product retrievableFields. + * @member {google.protobuf.IFieldMask|null|undefined} retrievableFields + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.retrievableFields = null; + + /** + * Product variants. + * @member {Array.} variants + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Product.prototype.variants = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Product expiration. + * @member {"expireTime"|"ttl"|undefined} expiration + * @memberof google.cloud.retail.v2alpha.Product + * @instance + */ + Object.defineProperty(Product.prototype, "expiration", { + get: $util.oneOfGetter($oneOfFields = ["expireTime", "ttl"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Product instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {google.cloud.retail.v2alpha.IProduct=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Product} Product instance + */ + Product.create = function create(properties) { + return new Product(properties); + }; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2alpha.Product.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {google.cloud.retail.v2alpha.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.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.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.primaryProductId != null && Object.hasOwnProperty.call(message, "primaryProductId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.primaryProductId); + if (message.collectionMemberIds != null && message.collectionMemberIds.length) + for (var i = 0; i < message.collectionMemberIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.collectionMemberIds[i]); + if (message.gtin != null && Object.hasOwnProperty.call(message, "gtin")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.gtin); + if (message.categories != null && message.categories.length) + for (var i = 0; i < message.categories.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.categories[i]); + if (message.title != null && Object.hasOwnProperty.call(message, "title")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.title); + if (message.brands != null && message.brands.length) + for (var i = 0; i < message.brands.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.brands[i]); + if (message.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.description); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.languageCode); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 12, wireType 2 =*/98).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2alpha.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.tags != null && message.tags.length) + for (var i = 0; i < message.tags.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.tags[i]); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2alpha.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.rating != null && Object.hasOwnProperty.call(message, "rating")) + $root.google.cloud.retail.v2alpha.Rating.encode(message.rating, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.ttl != null && Object.hasOwnProperty.call(message, "ttl")) + $root.google.protobuf.Duration.encode(message.ttl, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.availableTime != null && Object.hasOwnProperty.call(message, "availableTime")) + $root.google.protobuf.Timestamp.encode(message.availableTime, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.availability != null && Object.hasOwnProperty.call(message, "availability")) + writer.uint32(/* id 19, wireType 0 =*/152).int32(message.availability); + if (message.availableQuantity != null && Object.hasOwnProperty.call(message, "availableQuantity")) + $root.google.protobuf.Int32Value.encode(message.availableQuantity, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.fulfillmentInfo != null && message.fulfillmentInfo.length) + for (var i = 0; i < message.fulfillmentInfo.length; ++i) + $root.google.cloud.retail.v2alpha.FulfillmentInfo.encode(message.fulfillmentInfo[i], writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 22, wireType 2 =*/178).string(message.uri); + if (message.images != null && message.images.length) + for (var i = 0; i < message.images.length; ++i) + $root.google.cloud.retail.v2alpha.Image.encode(message.images[i], writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + if (message.audience != null && Object.hasOwnProperty.call(message, "audience")) + $root.google.cloud.retail.v2alpha.Audience.encode(message.audience, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); + if (message.colorInfo != null && Object.hasOwnProperty.call(message, "colorInfo")) + $root.google.cloud.retail.v2alpha.ColorInfo.encode(message.colorInfo, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim(); + if (message.sizes != null && message.sizes.length) + for (var i = 0; i < message.sizes.length; ++i) + writer.uint32(/* id 26, wireType 2 =*/210).string(message.sizes[i]); + if (message.materials != null && message.materials.length) + for (var i = 0; i < message.materials.length; ++i) + writer.uint32(/* id 27, wireType 2 =*/218).string(message.materials[i]); + if (message.patterns != null && message.patterns.length) + for (var i = 0; i < message.patterns.length; ++i) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.patterns[i]); + if (message.conditions != null && message.conditions.length) + for (var i = 0; i < message.conditions.length; ++i) + writer.uint32(/* id 29, wireType 2 =*/234).string(message.conditions[i]); + if (message.retrievableFields != null && Object.hasOwnProperty.call(message, "retrievableFields")) + $root.google.protobuf.FieldMask.encode(message.retrievableFields, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim(); + if (message.variants != null && message.variants.length) + for (var i = 0; i < message.variants.length; ++i) + $root.google.cloud.retail.v2alpha.Product.encode(message.variants[i], writer.uint32(/* id 31, wireType 2 =*/250).fork()).ldelim(); + if (message.publishTime != null && Object.hasOwnProperty.call(message, "publishTime")) + $root.google.protobuf.Timestamp.encode(message.publishTime, writer.uint32(/* id 33, wireType 2 =*/266).fork()).ldelim(); + if (message.promotions != null && message.promotions.length) + for (var i = 0; i < message.promotions.length; ++i) + $root.google.cloud.retail.v2alpha.Promotion.encode(message.promotions[i], writer.uint32(/* id 34, wireType 2 =*/274).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Product.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {google.cloud.retail.v2alpha.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Product message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.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.cloud.retail.v2alpha.Product(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 16: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 17: { + message.ttl = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.id = reader.string(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.primaryProductId = reader.string(); + break; + } + case 5: { + if (!(message.collectionMemberIds && message.collectionMemberIds.length)) + message.collectionMemberIds = []; + message.collectionMemberIds.push(reader.string()); + break; + } + case 6: { + message.gtin = reader.string(); + break; + } + case 7: { + if (!(message.categories && message.categories.length)) + message.categories = []; + message.categories.push(reader.string()); + break; + } + case 8: { + message.title = reader.string(); + break; + } + case 9: { + if (!(message.brands && message.brands.length)) + message.brands = []; + message.brands.push(reader.string()); + break; + } + case 10: { + message.description = reader.string(); + break; + } + case 11: { + message.languageCode = reader.string(); + break; + } + case 12: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2alpha.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 13: { + if (!(message.tags && message.tags.length)) + message.tags = []; + message.tags.push(reader.string()); + break; + } + case 14: { + message.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 15: { + message.rating = $root.google.cloud.retail.v2alpha.Rating.decode(reader, reader.uint32()); + break; + } + case 18: { + message.availableTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 19: { + message.availability = reader.int32(); + break; + } + case 20: { + message.availableQuantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + case 21: { + if (!(message.fulfillmentInfo && message.fulfillmentInfo.length)) + message.fulfillmentInfo = []; + message.fulfillmentInfo.push($root.google.cloud.retail.v2alpha.FulfillmentInfo.decode(reader, reader.uint32())); + break; + } + case 22: { + message.uri = reader.string(); + break; + } + case 23: { + if (!(message.images && message.images.length)) + message.images = []; + message.images.push($root.google.cloud.retail.v2alpha.Image.decode(reader, reader.uint32())); + break; + } + case 24: { + message.audience = $root.google.cloud.retail.v2alpha.Audience.decode(reader, reader.uint32()); + break; + } + case 25: { + message.colorInfo = $root.google.cloud.retail.v2alpha.ColorInfo.decode(reader, reader.uint32()); + break; + } + case 26: { + if (!(message.sizes && message.sizes.length)) + message.sizes = []; + message.sizes.push(reader.string()); + break; + } + case 27: { + if (!(message.materials && message.materials.length)) + message.materials = []; + message.materials.push(reader.string()); + break; + } + case 28: { + if (!(message.patterns && message.patterns.length)) + message.patterns = []; + message.patterns.push(reader.string()); + break; + } + case 29: { + if (!(message.conditions && message.conditions.length)) + message.conditions = []; + message.conditions.push(reader.string()); + break; + } + case 34: { + if (!(message.promotions && message.promotions.length)) + message.promotions = []; + message.promotions.push($root.google.cloud.retail.v2alpha.Promotion.decode(reader, reader.uint32())); + break; + } + case 33: { + message.publishTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 30: { + message.retrievableFields = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 31: { + if (!(message.variants && message.variants.length)) + message.variants = []; + message.variants.push($root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Product message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Product.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + properties.expiration = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + if (properties.expiration === 1) + return "expiration: multiple values"; + properties.expiration = 1; + { + var error = $root.google.protobuf.Duration.verify(message.ttl); + if (error) + return "ttl." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + if (!$util.isString(message.primaryProductId)) + return "primaryProductId: string expected"; + if (message.collectionMemberIds != null && message.hasOwnProperty("collectionMemberIds")) { + if (!Array.isArray(message.collectionMemberIds)) + return "collectionMemberIds: array expected"; + for (var i = 0; i < message.collectionMemberIds.length; ++i) + if (!$util.isString(message.collectionMemberIds[i])) + return "collectionMemberIds: string[] expected"; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + if (!$util.isString(message.gtin)) + return "gtin: string expected"; + if (message.categories != null && message.hasOwnProperty("categories")) { + if (!Array.isArray(message.categories)) + return "categories: array expected"; + for (var i = 0; i < message.categories.length; ++i) + if (!$util.isString(message.categories[i])) + return "categories: string[] expected"; + } + if (message.title != null && message.hasOwnProperty("title")) + if (!$util.isString(message.title)) + return "title: string expected"; + if (message.brands != null && message.hasOwnProperty("brands")) { + if (!Array.isArray(message.brands)) + return "brands: array expected"; + for (var i = 0; i < message.brands.length; ++i) + if (!$util.isString(message.brands[i])) + return "brands: string[] expected"; + } + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.tags != null && message.hasOwnProperty("tags")) { + if (!Array.isArray(message.tags)) + return "tags: array expected"; + for (var i = 0; i < message.tags.length; ++i) + if (!$util.isString(message.tags[i])) + return "tags: string[] expected"; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2alpha.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.rating != null && message.hasOwnProperty("rating")) { + var error = $root.google.cloud.retail.v2alpha.Rating.verify(message.rating); + if (error) + return "rating." + error; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.availableTime); + if (error) + return "availableTime." + error; + } + if (message.availability != null && message.hasOwnProperty("availability")) + switch (message.availability) { + default: + return "availability: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.availableQuantity); + if (error) + return "availableQuantity." + error; + } + if (message.fulfillmentInfo != null && message.hasOwnProperty("fulfillmentInfo")) { + if (!Array.isArray(message.fulfillmentInfo)) + return "fulfillmentInfo: array expected"; + for (var i = 0; i < message.fulfillmentInfo.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.FulfillmentInfo.verify(message.fulfillmentInfo[i]); + if (error) + return "fulfillmentInfo." + error; + } + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.images != null && message.hasOwnProperty("images")) { + if (!Array.isArray(message.images)) + return "images: array expected"; + for (var i = 0; i < message.images.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Image.verify(message.images[i]); + if (error) + return "images." + error; + } + } + if (message.audience != null && message.hasOwnProperty("audience")) { + var error = $root.google.cloud.retail.v2alpha.Audience.verify(message.audience); + if (error) + return "audience." + error; + } + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) { + var error = $root.google.cloud.retail.v2alpha.ColorInfo.verify(message.colorInfo); + if (error) + return "colorInfo." + error; + } + if (message.sizes != null && message.hasOwnProperty("sizes")) { + if (!Array.isArray(message.sizes)) + return "sizes: array expected"; + for (var i = 0; i < message.sizes.length; ++i) + if (!$util.isString(message.sizes[i])) + return "sizes: string[] expected"; + } + if (message.materials != null && message.hasOwnProperty("materials")) { + if (!Array.isArray(message.materials)) + return "materials: array expected"; + for (var i = 0; i < message.materials.length; ++i) + if (!$util.isString(message.materials[i])) + return "materials: string[] expected"; + } + if (message.patterns != null && message.hasOwnProperty("patterns")) { + if (!Array.isArray(message.patterns)) + return "patterns: array expected"; + for (var i = 0; i < message.patterns.length; ++i) + if (!$util.isString(message.patterns[i])) + return "patterns: string[] expected"; + } + if (message.conditions != null && message.hasOwnProperty("conditions")) { + if (!Array.isArray(message.conditions)) + return "conditions: array expected"; + for (var i = 0; i < message.conditions.length; ++i) + if (!$util.isString(message.conditions[i])) + return "conditions: string[] expected"; + } + if (message.promotions != null && message.hasOwnProperty("promotions")) { + if (!Array.isArray(message.promotions)) + return "promotions: array expected"; + for (var i = 0; i < message.promotions.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Promotion.verify(message.promotions[i]); + if (error) + return "promotions." + error; + } + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.publishTime); + if (error) + return "publishTime." + error; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) { + var error = $root.google.protobuf.FieldMask.verify(message.retrievableFields); + if (error) + return "retrievableFields." + error; + } + if (message.variants != null && message.hasOwnProperty("variants")) { + if (!Array.isArray(message.variants)) + return "variants: array expected"; + for (var i = 0; i < message.variants.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.variants[i]); + if (error) + return "variants." + error; + } + } + return null; + }; + + /** + * Creates a Product message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Product} Product + */ + Product.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Product) + return object; + var message = new $root.google.cloud.retail.v2alpha.Product(); + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.ttl != null) { + if (typeof object.ttl !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.ttl: object expected"); + message.ttl = $root.google.protobuf.Duration.fromObject(object.ttl); + } + if (object.name != null) + message.name = String(object.name); + if (object.id != null) + message.id = String(object.id); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "PRIMARY": + case 1: + message.type = 1; + break; + case "VARIANT": + case 2: + message.type = 2; + break; + case "COLLECTION": + case 3: + message.type = 3; + break; + } + if (object.primaryProductId != null) + message.primaryProductId = String(object.primaryProductId); + if (object.collectionMemberIds) { + if (!Array.isArray(object.collectionMemberIds)) + throw TypeError(".google.cloud.retail.v2alpha.Product.collectionMemberIds: array expected"); + message.collectionMemberIds = []; + for (var i = 0; i < object.collectionMemberIds.length; ++i) + message.collectionMemberIds[i] = String(object.collectionMemberIds[i]); + } + if (object.gtin != null) + message.gtin = String(object.gtin); + if (object.categories) { + if (!Array.isArray(object.categories)) + throw TypeError(".google.cloud.retail.v2alpha.Product.categories: array expected"); + message.categories = []; + for (var i = 0; i < object.categories.length; ++i) + message.categories[i] = String(object.categories[i]); + } + if (object.title != null) + message.title = String(object.title); + if (object.brands) { + if (!Array.isArray(object.brands)) + throw TypeError(".google.cloud.retail.v2alpha.Product.brands: array expected"); + message.brands = []; + for (var i = 0; i < object.brands.length; ++i) + message.brands[i] = String(object.brands[i]); + } + if (object.description != null) + message.description = String(object.description); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2alpha.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.tags) { + if (!Array.isArray(object.tags)) + throw TypeError(".google.cloud.retail.v2alpha.Product.tags: array expected"); + message.tags = []; + for (var i = 0; i < object.tags.length; ++i) + message.tags[i] = String(object.tags[i]); + } + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.fromObject(object.priceInfo); + } + if (object.rating != null) { + if (typeof object.rating !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.rating: object expected"); + message.rating = $root.google.cloud.retail.v2alpha.Rating.fromObject(object.rating); + } + if (object.availableTime != null) { + if (typeof object.availableTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.availableTime: object expected"); + message.availableTime = $root.google.protobuf.Timestamp.fromObject(object.availableTime); + } + switch (object.availability) { + default: + if (typeof object.availability === "number") { + message.availability = object.availability; + break; + } + break; + case "AVAILABILITY_UNSPECIFIED": + case 0: + message.availability = 0; + break; + case "IN_STOCK": + case 1: + message.availability = 1; + break; + case "OUT_OF_STOCK": + case 2: + message.availability = 2; + break; + case "PREORDER": + case 3: + message.availability = 3; + break; + case "BACKORDER": + case 4: + message.availability = 4; + break; + } + if (object.availableQuantity != null) { + if (typeof object.availableQuantity !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.availableQuantity: object expected"); + message.availableQuantity = $root.google.protobuf.Int32Value.fromObject(object.availableQuantity); + } + if (object.fulfillmentInfo) { + if (!Array.isArray(object.fulfillmentInfo)) + throw TypeError(".google.cloud.retail.v2alpha.Product.fulfillmentInfo: array expected"); + message.fulfillmentInfo = []; + for (var i = 0; i < object.fulfillmentInfo.length; ++i) { + if (typeof object.fulfillmentInfo[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.fulfillmentInfo: object expected"); + message.fulfillmentInfo[i] = $root.google.cloud.retail.v2alpha.FulfillmentInfo.fromObject(object.fulfillmentInfo[i]); + } + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.images) { + if (!Array.isArray(object.images)) + throw TypeError(".google.cloud.retail.v2alpha.Product.images: array expected"); + message.images = []; + for (var i = 0; i < object.images.length; ++i) { + if (typeof object.images[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.images: object expected"); + message.images[i] = $root.google.cloud.retail.v2alpha.Image.fromObject(object.images[i]); + } + } + if (object.audience != null) { + if (typeof object.audience !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.audience: object expected"); + message.audience = $root.google.cloud.retail.v2alpha.Audience.fromObject(object.audience); + } + if (object.colorInfo != null) { + if (typeof object.colorInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.colorInfo: object expected"); + message.colorInfo = $root.google.cloud.retail.v2alpha.ColorInfo.fromObject(object.colorInfo); + } + if (object.sizes) { + if (!Array.isArray(object.sizes)) + throw TypeError(".google.cloud.retail.v2alpha.Product.sizes: array expected"); + message.sizes = []; + for (var i = 0; i < object.sizes.length; ++i) + message.sizes[i] = String(object.sizes[i]); + } + if (object.materials) { + if (!Array.isArray(object.materials)) + throw TypeError(".google.cloud.retail.v2alpha.Product.materials: array expected"); + message.materials = []; + for (var i = 0; i < object.materials.length; ++i) + message.materials[i] = String(object.materials[i]); + } + if (object.patterns) { + if (!Array.isArray(object.patterns)) + throw TypeError(".google.cloud.retail.v2alpha.Product.patterns: array expected"); + message.patterns = []; + for (var i = 0; i < object.patterns.length; ++i) + message.patterns[i] = String(object.patterns[i]); + } + if (object.conditions) { + if (!Array.isArray(object.conditions)) + throw TypeError(".google.cloud.retail.v2alpha.Product.conditions: array expected"); + message.conditions = []; + for (var i = 0; i < object.conditions.length; ++i) + message.conditions[i] = String(object.conditions[i]); + } + if (object.promotions) { + if (!Array.isArray(object.promotions)) + throw TypeError(".google.cloud.retail.v2alpha.Product.promotions: array expected"); + message.promotions = []; + for (var i = 0; i < object.promotions.length; ++i) { + if (typeof object.promotions[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.promotions: object expected"); + message.promotions[i] = $root.google.cloud.retail.v2alpha.Promotion.fromObject(object.promotions[i]); + } + } + if (object.publishTime != null) { + if (typeof object.publishTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.publishTime: object expected"); + message.publishTime = $root.google.protobuf.Timestamp.fromObject(object.publishTime); + } + if (object.retrievableFields != null) { + if (typeof object.retrievableFields !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.retrievableFields: object expected"); + message.retrievableFields = $root.google.protobuf.FieldMask.fromObject(object.retrievableFields); + } + if (object.variants) { + if (!Array.isArray(object.variants)) + throw TypeError(".google.cloud.retail.v2alpha.Product.variants: array expected"); + message.variants = []; + for (var i = 0; i < object.variants.length; ++i) { + if (typeof object.variants[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Product.variants: object expected"); + message.variants[i] = $root.google.cloud.retail.v2alpha.Product.fromObject(object.variants[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {google.cloud.retail.v2alpha.Product} message Product + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Product.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.collectionMemberIds = []; + object.categories = []; + object.brands = []; + object.tags = []; + object.fulfillmentInfo = []; + object.images = []; + object.sizes = []; + object.materials = []; + object.patterns = []; + object.conditions = []; + object.variants = []; + object.promotions = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.name = ""; + object.id = ""; + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + object.primaryProductId = ""; + object.gtin = ""; + object.title = ""; + object.description = ""; + object.languageCode = ""; + object.priceInfo = null; + object.rating = null; + object.availableTime = null; + object.availability = options.enums === String ? "AVAILABILITY_UNSPECIFIED" : 0; + object.availableQuantity = null; + object.uri = ""; + object.audience = null; + object.colorInfo = null; + object.retrievableFields = null; + object.publishTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2alpha.Product.Type[message.type] === undefined ? message.type : $root.google.cloud.retail.v2alpha.Product.Type[message.type] : message.type; + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + object.primaryProductId = message.primaryProductId; + if (message.collectionMemberIds && message.collectionMemberIds.length) { + object.collectionMemberIds = []; + for (var j = 0; j < message.collectionMemberIds.length; ++j) + object.collectionMemberIds[j] = message.collectionMemberIds[j]; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + object.gtin = message.gtin; + if (message.categories && message.categories.length) { + object.categories = []; + for (var j = 0; j < message.categories.length; ++j) + object.categories[j] = message.categories[j]; + } + if (message.title != null && message.hasOwnProperty("title")) + object.title = message.title; + if (message.brands && message.brands.length) { + object.brands = []; + for (var j = 0; j < message.brands.length; ++j) + object.brands[j] = message.brands[j]; + } + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2alpha.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.tags && message.tags.length) { + object.tags = []; + for (var j = 0; j < message.tags.length; ++j) + object.tags[j] = message.tags[j]; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2alpha.PriceInfo.toObject(message.priceInfo, options); + if (message.rating != null && message.hasOwnProperty("rating")) + object.rating = $root.google.cloud.retail.v2alpha.Rating.toObject(message.rating, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (options.oneofs) + object.expiration = "expireTime"; + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + object.ttl = $root.google.protobuf.Duration.toObject(message.ttl, options); + if (options.oneofs) + object.expiration = "ttl"; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) + object.availableTime = $root.google.protobuf.Timestamp.toObject(message.availableTime, options); + if (message.availability != null && message.hasOwnProperty("availability")) + object.availability = options.enums === String ? $root.google.cloud.retail.v2alpha.Product.Availability[message.availability] === undefined ? message.availability : $root.google.cloud.retail.v2alpha.Product.Availability[message.availability] : message.availability; + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) + object.availableQuantity = $root.google.protobuf.Int32Value.toObject(message.availableQuantity, options); + if (message.fulfillmentInfo && message.fulfillmentInfo.length) { + object.fulfillmentInfo = []; + for (var j = 0; j < message.fulfillmentInfo.length; ++j) + object.fulfillmentInfo[j] = $root.google.cloud.retail.v2alpha.FulfillmentInfo.toObject(message.fulfillmentInfo[j], options); + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.images && message.images.length) { + object.images = []; + for (var j = 0; j < message.images.length; ++j) + object.images[j] = $root.google.cloud.retail.v2alpha.Image.toObject(message.images[j], options); + } + if (message.audience != null && message.hasOwnProperty("audience")) + object.audience = $root.google.cloud.retail.v2alpha.Audience.toObject(message.audience, options); + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) + object.colorInfo = $root.google.cloud.retail.v2alpha.ColorInfo.toObject(message.colorInfo, options); + if (message.sizes && message.sizes.length) { + object.sizes = []; + for (var j = 0; j < message.sizes.length; ++j) + object.sizes[j] = message.sizes[j]; + } + if (message.materials && message.materials.length) { + object.materials = []; + for (var j = 0; j < message.materials.length; ++j) + object.materials[j] = message.materials[j]; + } + if (message.patterns && message.patterns.length) { + object.patterns = []; + for (var j = 0; j < message.patterns.length; ++j) + object.patterns[j] = message.patterns[j]; + } + if (message.conditions && message.conditions.length) { + object.conditions = []; + for (var j = 0; j < message.conditions.length; ++j) + object.conditions[j] = message.conditions[j]; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) + object.retrievableFields = $root.google.protobuf.FieldMask.toObject(message.retrievableFields, options); + if (message.variants && message.variants.length) { + object.variants = []; + for (var j = 0; j < message.variants.length; ++j) + object.variants[j] = $root.google.cloud.retail.v2alpha.Product.toObject(message.variants[j], options); + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) + object.publishTime = $root.google.protobuf.Timestamp.toObject(message.publishTime, options); + if (message.promotions && message.promotions.length) { + object.promotions = []; + for (var j = 0; j < message.promotions.length; ++j) + object.promotions[j] = $root.google.cloud.retail.v2alpha.Promotion.toObject(message.promotions[j], options); + } + return object; + }; + + /** + * Converts this Product to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Product + * @instance + * @returns {Object.} JSON object + */ + Product.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Product + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Product + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Product.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Product"; + }; + + /** + * Type enum. + * @name google.cloud.retail.v2alpha.Product.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} PRIMARY=1 PRIMARY value + * @property {number} VARIANT=2 VARIANT value + * @property {number} COLLECTION=3 COLLECTION value + */ + Product.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRIMARY"] = 1; + values[valuesById[2] = "VARIANT"] = 2; + values[valuesById[3] = "COLLECTION"] = 3; + return values; + })(); + + /** + * Availability enum. + * @name google.cloud.retail.v2alpha.Product.Availability + * @enum {number} + * @property {number} AVAILABILITY_UNSPECIFIED=0 AVAILABILITY_UNSPECIFIED value + * @property {number} IN_STOCK=1 IN_STOCK value + * @property {number} OUT_OF_STOCK=2 OUT_OF_STOCK value + * @property {number} PREORDER=3 PREORDER value + * @property {number} BACKORDER=4 BACKORDER value + */ + Product.Availability = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "AVAILABILITY_UNSPECIFIED"] = 0; + values[valuesById[1] = "IN_STOCK"] = 1; + values[valuesById[2] = "OUT_OF_STOCK"] = 2; + values[valuesById[3] = "PREORDER"] = 3; + values[valuesById[4] = "BACKORDER"] = 4; + return values; + })(); + + return Product; + })(); + + v2alpha.Promotion = (function() { + + /** + * Properties of a Promotion. + * @memberof google.cloud.retail.v2alpha + * @interface IPromotion + * @property {string|null} [promotionId] Promotion promotionId + */ + + /** + * Constructs a new Promotion. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Promotion. + * @implements IPromotion + * @constructor + * @param {google.cloud.retail.v2alpha.IPromotion=} [properties] Properties to set + */ + function Promotion(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]]; + } + + /** + * Promotion promotionId. + * @member {string} promotionId + * @memberof google.cloud.retail.v2alpha.Promotion + * @instance + */ + Promotion.prototype.promotionId = ""; + + /** + * Creates a new Promotion instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {google.cloud.retail.v2alpha.IPromotion=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Promotion} Promotion instance + */ + Promotion.create = function create(properties) { + return new Promotion(properties); + }; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2alpha.Promotion.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {google.cloud.retail.v2alpha.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.promotionId != null && Object.hasOwnProperty.call(message, "promotionId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.promotionId); + return writer; + }; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Promotion.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {google.cloud.retail.v2alpha.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.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.cloud.retail.v2alpha.Promotion(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.promotionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Promotion message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Promotion.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + if (!$util.isString(message.promotionId)) + return "promotionId: string expected"; + return null; + }; + + /** + * Creates a Promotion message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Promotion} Promotion + */ + Promotion.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Promotion) + return object; + var message = new $root.google.cloud.retail.v2alpha.Promotion(); + if (object.promotionId != null) + message.promotionId = String(object.promotionId); + return message; + }; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {google.cloud.retail.v2alpha.Promotion} message Promotion + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Promotion.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.promotionId = ""; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + object.promotionId = message.promotionId; + return object; + }; + + /** + * Converts this Promotion to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Promotion + * @instance + * @returns {Object.} JSON object + */ + Promotion.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Promotion + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Promotion + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Promotion.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Promotion"; + }; + + return Promotion; + })(); + + v2alpha.UserEvent = (function() { + + /** + * Properties of a UserEvent. + * @memberof google.cloud.retail.v2alpha + * @interface IUserEvent + * @property {string|null} [eventType] UserEvent eventType + * @property {string|null} [visitorId] UserEvent visitorId + * @property {string|null} [sessionId] UserEvent sessionId + * @property {google.protobuf.ITimestamp|null} [eventTime] UserEvent eventTime + * @property {Array.|null} [experimentIds] UserEvent experimentIds + * @property {string|null} [attributionToken] UserEvent attributionToken + * @property {Array.|null} [productDetails] UserEvent productDetails + * @property {google.cloud.retail.v2alpha.ICompletionDetail|null} [completionDetail] UserEvent completionDetail + * @property {Object.|null} [attributes] UserEvent attributes + * @property {string|null} [cartId] UserEvent cartId + * @property {google.cloud.retail.v2alpha.IPurchaseTransaction|null} [purchaseTransaction] UserEvent purchaseTransaction + * @property {string|null} [searchQuery] UserEvent searchQuery + * @property {string|null} [filter] UserEvent filter + * @property {string|null} [orderBy] UserEvent orderBy + * @property {number|null} [offset] UserEvent offset + * @property {Array.|null} [pageCategories] UserEvent pageCategories + * @property {google.cloud.retail.v2alpha.IUserInfo|null} [userInfo] UserEvent userInfo + * @property {string|null} [uri] UserEvent uri + * @property {string|null} [referrerUri] UserEvent referrerUri + * @property {string|null} [pageViewId] UserEvent pageViewId + */ + + /** + * Constructs a new UserEvent. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserEvent. + * @implements IUserEvent + * @constructor + * @param {google.cloud.retail.v2alpha.IUserEvent=} [properties] Properties to set + */ + function UserEvent(properties) { + this.experimentIds = []; + this.productDetails = []; + this.attributes = {}; + this.pageCategories = []; + 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]]; + } + + /** + * UserEvent eventType. + * @member {string} eventType + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.eventType = ""; + + /** + * UserEvent visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.visitorId = ""; + + /** + * UserEvent sessionId. + * @member {string} sessionId + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.sessionId = ""; + + /** + * UserEvent eventTime. + * @member {google.protobuf.ITimestamp|null|undefined} eventTime + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.eventTime = null; + + /** + * UserEvent experimentIds. + * @member {Array.} experimentIds + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.experimentIds = $util.emptyArray; + + /** + * UserEvent attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.attributionToken = ""; + + /** + * UserEvent productDetails. + * @member {Array.} productDetails + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.productDetails = $util.emptyArray; + + /** + * UserEvent completionDetail. + * @member {google.cloud.retail.v2alpha.ICompletionDetail|null|undefined} completionDetail + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.completionDetail = null; + + /** + * UserEvent attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.attributes = $util.emptyObject; + + /** + * UserEvent cartId. + * @member {string} cartId + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.cartId = ""; + + /** + * UserEvent purchaseTransaction. + * @member {google.cloud.retail.v2alpha.IPurchaseTransaction|null|undefined} purchaseTransaction + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.purchaseTransaction = null; + + /** + * UserEvent searchQuery. + * @member {string} searchQuery + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.searchQuery = ""; + + /** + * UserEvent filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.filter = ""; + + /** + * UserEvent orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.orderBy = ""; + + /** + * UserEvent offset. + * @member {number} offset + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.offset = 0; + + /** + * UserEvent pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.pageCategories = $util.emptyArray; + + /** + * UserEvent userInfo. + * @member {google.cloud.retail.v2alpha.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.userInfo = null; + + /** + * UserEvent uri. + * @member {string} uri + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.uri = ""; + + /** + * UserEvent referrerUri. + * @member {string} referrerUri + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.referrerUri = ""; + + /** + * UserEvent pageViewId. + * @member {string} pageViewId + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + */ + UserEvent.prototype.pageViewId = ""; + + /** + * Creates a new UserEvent instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {google.cloud.retail.v2alpha.IUserEvent=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UserEvent} UserEvent instance + */ + UserEvent.create = function create(properties) { + return new UserEvent(properties); + }; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2alpha.UserEvent.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {google.cloud.retail.v2alpha.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.eventType != null && Object.hasOwnProperty.call(message, "eventType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.eventType); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.visitorId); + if (message.eventTime != null && Object.hasOwnProperty.call(message, "eventTime")) + $root.google.protobuf.Timestamp.encode(message.eventTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.experimentIds != null && message.experimentIds.length) + for (var i = 0; i < message.experimentIds.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.experimentIds[i]); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.productDetails != null && message.productDetails.length) + for (var i = 0; i < message.productDetails.length; ++i) + $root.google.cloud.retail.v2alpha.ProductDetail.encode(message.productDetails[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2alpha.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.cartId != null && Object.hasOwnProperty.call(message, "cartId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.cartId); + if (message.purchaseTransaction != null && Object.hasOwnProperty.call(message, "purchaseTransaction")) + $root.google.cloud.retail.v2alpha.PurchaseTransaction.encode(message.purchaseTransaction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.searchQuery != null && Object.hasOwnProperty.call(message, "searchQuery")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.searchQuery); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.pageCategories[i]); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2alpha.UserInfo.encode(message.userInfo, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.uri); + if (message.referrerUri != null && Object.hasOwnProperty.call(message, "referrerUri")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.referrerUri); + if (message.pageViewId != null && Object.hasOwnProperty.call(message, "pageViewId")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.pageViewId); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.orderBy); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 18, wireType 0 =*/144).int32(message.offset); + if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId")) + writer.uint32(/* id 21, wireType 2 =*/170).string(message.sessionId); + if (message.completionDetail != null && Object.hasOwnProperty.call(message, "completionDetail")) + $root.google.cloud.retail.v2alpha.CompletionDetail.encode(message.completionDetail, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UserEvent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {google.cloud.retail.v2alpha.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.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.cloud.retail.v2alpha.UserEvent(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.eventType = reader.string(); + break; + } + case 2: { + message.visitorId = reader.string(); + break; + } + case 21: { + message.sessionId = reader.string(); + break; + } + case 3: { + message.eventTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.experimentIds && message.experimentIds.length)) + message.experimentIds = []; + message.experimentIds.push(reader.string()); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + if (!(message.productDetails && message.productDetails.length)) + message.productDetails = []; + message.productDetails.push($root.google.cloud.retail.v2alpha.ProductDetail.decode(reader, reader.uint32())); + break; + } + case 22: { + message.completionDetail = $root.google.cloud.retail.v2alpha.CompletionDetail.decode(reader, reader.uint32()); + break; + } + case 7: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2alpha.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 8: { + message.cartId = reader.string(); + break; + } + case 9: { + message.purchaseTransaction = $root.google.cloud.retail.v2alpha.PurchaseTransaction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.searchQuery = reader.string(); + break; + } + case 16: { + message.filter = reader.string(); + break; + } + case 17: { + message.orderBy = reader.string(); + break; + } + case 18: { + message.offset = reader.int32(); + break; + } + case 11: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 12: { + message.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.decode(reader, reader.uint32()); + break; + } + case 13: { + message.uri = reader.string(); + break; + } + case 14: { + message.referrerUri = reader.string(); + break; + } + case 15: { + message.pageViewId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEvent message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEvent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.eventType != null && message.hasOwnProperty("eventType")) + if (!$util.isString(message.eventType)) + return "eventType: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + if (!$util.isString(message.sessionId)) + return "sessionId: string expected"; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.eventTime); + if (error) + return "eventTime." + error; + } + if (message.experimentIds != null && message.hasOwnProperty("experimentIds")) { + if (!Array.isArray(message.experimentIds)) + return "experimentIds: array expected"; + for (var i = 0; i < message.experimentIds.length; ++i) + if (!$util.isString(message.experimentIds[i])) + return "experimentIds: string[] expected"; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.productDetails != null && message.hasOwnProperty("productDetails")) { + if (!Array.isArray(message.productDetails)) + return "productDetails: array expected"; + for (var i = 0; i < message.productDetails.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.ProductDetail.verify(message.productDetails[i]); + if (error) + return "productDetails." + error; + } + } + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) { + var error = $root.google.cloud.retail.v2alpha.CompletionDetail.verify(message.completionDetail); + if (error) + return "completionDetail." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + if (!$util.isString(message.cartId)) + return "cartId: string expected"; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) { + var error = $root.google.cloud.retail.v2alpha.PurchaseTransaction.verify(message.purchaseTransaction); + if (error) + return "purchaseTransaction." + error; + } + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + if (!$util.isString(message.searchQuery)) + return "searchQuery: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2alpha.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + if (!$util.isString(message.referrerUri)) + return "referrerUri: string expected"; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + if (!$util.isString(message.pageViewId)) + return "pageViewId: string expected"; + return null; + }; + + /** + * Creates a UserEvent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UserEvent} UserEvent + */ + UserEvent.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UserEvent) + return object; + var message = new $root.google.cloud.retail.v2alpha.UserEvent(); + if (object.eventType != null) + message.eventType = String(object.eventType); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.sessionId != null) + message.sessionId = String(object.sessionId); + if (object.eventTime != null) { + if (typeof object.eventTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.eventTime: object expected"); + message.eventTime = $root.google.protobuf.Timestamp.fromObject(object.eventTime); + } + if (object.experimentIds) { + if (!Array.isArray(object.experimentIds)) + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.experimentIds: array expected"); + message.experimentIds = []; + for (var i = 0; i < object.experimentIds.length; ++i) + message.experimentIds[i] = String(object.experimentIds[i]); + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.productDetails) { + if (!Array.isArray(object.productDetails)) + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.productDetails: array expected"); + message.productDetails = []; + for (var i = 0; i < object.productDetails.length; ++i) { + if (typeof object.productDetails[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.productDetails: object expected"); + message.productDetails[i] = $root.google.cloud.retail.v2alpha.ProductDetail.fromObject(object.productDetails[i]); + } + } + if (object.completionDetail != null) { + if (typeof object.completionDetail !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.completionDetail: object expected"); + message.completionDetail = $root.google.cloud.retail.v2alpha.CompletionDetail.fromObject(object.completionDetail); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2alpha.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.cartId != null) + message.cartId = String(object.cartId); + if (object.purchaseTransaction != null) { + if (typeof object.purchaseTransaction !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.purchaseTransaction: object expected"); + message.purchaseTransaction = $root.google.cloud.retail.v2alpha.PurchaseTransaction.fromObject(object.purchaseTransaction); + } + if (object.searchQuery != null) + message.searchQuery = String(object.searchQuery); + if (object.filter != null) + message.filter = String(object.filter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UserEvent.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.fromObject(object.userInfo); + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.referrerUri != null) + message.referrerUri = String(object.referrerUri); + if (object.pageViewId != null) + message.pageViewId = String(object.pageViewId); + return message; + }; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {google.cloud.retail.v2alpha.UserEvent} message UserEvent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEvent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.experimentIds = []; + object.productDetails = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.eventType = ""; + object.visitorId = ""; + object.eventTime = null; + object.attributionToken = ""; + object.cartId = ""; + object.purchaseTransaction = null; + object.searchQuery = ""; + object.userInfo = null; + object.uri = ""; + object.referrerUri = ""; + object.pageViewId = ""; + object.filter = ""; + object.orderBy = ""; + object.offset = 0; + object.sessionId = ""; + object.completionDetail = null; + } + if (message.eventType != null && message.hasOwnProperty("eventType")) + object.eventType = message.eventType; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) + object.eventTime = $root.google.protobuf.Timestamp.toObject(message.eventTime, options); + if (message.experimentIds && message.experimentIds.length) { + object.experimentIds = []; + for (var j = 0; j < message.experimentIds.length; ++j) + object.experimentIds[j] = message.experimentIds[j]; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.productDetails && message.productDetails.length) { + object.productDetails = []; + for (var j = 0; j < message.productDetails.length; ++j) + object.productDetails[j] = $root.google.cloud.retail.v2alpha.ProductDetail.toObject(message.productDetails[j], options); + } + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2alpha.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + object.cartId = message.cartId; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) + object.purchaseTransaction = $root.google.cloud.retail.v2alpha.PurchaseTransaction.toObject(message.purchaseTransaction, options); + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + object.searchQuery = message.searchQuery; + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.toObject(message.userInfo, options); + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + object.referrerUri = message.referrerUri; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + object.pageViewId = message.pageViewId; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + object.sessionId = message.sessionId; + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) + object.completionDetail = $root.google.cloud.retail.v2alpha.CompletionDetail.toObject(message.completionDetail, options); + return object; + }; + + /** + * Converts this UserEvent to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UserEvent + * @instance + * @returns {Object.} JSON object + */ + UserEvent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEvent + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UserEvent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UserEvent"; + }; + + return UserEvent; + })(); + + v2alpha.ProductDetail = (function() { + + /** + * Properties of a ProductDetail. + * @memberof google.cloud.retail.v2alpha + * @interface IProductDetail + * @property {google.cloud.retail.v2alpha.IProduct|null} [product] ProductDetail product + * @property {google.protobuf.IInt32Value|null} [quantity] ProductDetail quantity + */ + + /** + * Constructs a new ProductDetail. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ProductDetail. + * @implements IProductDetail + * @constructor + * @param {google.cloud.retail.v2alpha.IProductDetail=} [properties] Properties to set + */ + function ProductDetail(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]]; + } + + /** + * ProductDetail product. + * @member {google.cloud.retail.v2alpha.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @instance + */ + ProductDetail.prototype.product = null; + + /** + * ProductDetail quantity. + * @member {google.protobuf.IInt32Value|null|undefined} quantity + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @instance + */ + ProductDetail.prototype.quantity = null; + + /** + * Creates a new ProductDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {google.cloud.retail.v2alpha.IProductDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ProductDetail} ProductDetail instance + */ + ProductDetail.create = function create(properties) { + return new ProductDetail(properties); + }; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2alpha.ProductDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {google.cloud.retail.v2alpha.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2alpha.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.quantity != null && Object.hasOwnProperty.call(message, "quantity")) + $root.google.protobuf.Int32Value.encode(message.quantity, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ProductDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {google.cloud.retail.v2alpha.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.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.cloud.retail.v2alpha.ProductDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.quantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductDetail message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.quantity != null && message.hasOwnProperty("quantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.quantity); + if (error) + return "quantity." + error; + } + return null; + }; + + /** + * Creates a ProductDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ProductDetail} ProductDetail + */ + ProductDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ProductDetail) + return object; + var message = new $root.google.cloud.retail.v2alpha.ProductDetail(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductDetail.product: object expected"); + message.product = $root.google.cloud.retail.v2alpha.Product.fromObject(object.product); + } + if (object.quantity != null) { + if (typeof object.quantity !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ProductDetail.quantity: object expected"); + message.quantity = $root.google.protobuf.Int32Value.fromObject(object.quantity); + } + return message; + }; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {google.cloud.retail.v2alpha.ProductDetail} message ProductDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.quantity = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2alpha.Product.toObject(message.product, options); + if (message.quantity != null && message.hasOwnProperty("quantity")) + object.quantity = $root.google.protobuf.Int32Value.toObject(message.quantity, options); + return object; + }; + + /** + * Converts this ProductDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @instance + * @returns {Object.} JSON object + */ + ProductDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ProductDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ProductDetail"; + }; + + return ProductDetail; + })(); + + v2alpha.CompletionDetail = (function() { + + /** + * Properties of a CompletionDetail. + * @memberof google.cloud.retail.v2alpha + * @interface ICompletionDetail + * @property {string|null} [completionAttributionToken] CompletionDetail completionAttributionToken + * @property {string|null} [selectedSuggestion] CompletionDetail selectedSuggestion + * @property {number|null} [selectedPosition] CompletionDetail selectedPosition + */ + + /** + * Constructs a new CompletionDetail. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompletionDetail. + * @implements ICompletionDetail + * @constructor + * @param {google.cloud.retail.v2alpha.ICompletionDetail=} [properties] Properties to set + */ + function CompletionDetail(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]]; + } + + /** + * CompletionDetail completionAttributionToken. + * @member {string} completionAttributionToken + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @instance + */ + CompletionDetail.prototype.completionAttributionToken = ""; + + /** + * CompletionDetail selectedSuggestion. + * @member {string} selectedSuggestion + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedSuggestion = ""; + + /** + * CompletionDetail selectedPosition. + * @member {number} selectedPosition + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedPosition = 0; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompletionDetail} CompletionDetail instance + */ + CompletionDetail.create = function create(properties) { + return new CompletionDetail(properties); + }; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionAttributionToken != null && Object.hasOwnProperty.call(message, "completionAttributionToken")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.completionAttributionToken); + if (message.selectedSuggestion != null && Object.hasOwnProperty.call(message, "selectedSuggestion")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.selectedSuggestion); + if (message.selectedPosition != null && Object.hasOwnProperty.call(message, "selectedPosition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.selectedPosition); + return writer; + }; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompletionDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {google.cloud.retail.v2alpha.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.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.cloud.retail.v2alpha.CompletionDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionAttributionToken = reader.string(); + break; + } + case 2: { + message.selectedSuggestion = reader.string(); + break; + } + case 3: { + message.selectedPosition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDetail message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + if (!$util.isString(message.completionAttributionToken)) + return "completionAttributionToken: string expected"; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + if (!$util.isString(message.selectedSuggestion)) + return "selectedSuggestion: string expected"; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + if (!$util.isInteger(message.selectedPosition)) + return "selectedPosition: integer expected"; + return null; + }; + + /** + * Creates a CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompletionDetail} CompletionDetail + */ + CompletionDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompletionDetail) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompletionDetail(); + if (object.completionAttributionToken != null) + message.completionAttributionToken = String(object.completionAttributionToken); + if (object.selectedSuggestion != null) + message.selectedSuggestion = String(object.selectedSuggestion); + if (object.selectedPosition != null) + message.selectedPosition = object.selectedPosition | 0; + return message; + }; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {google.cloud.retail.v2alpha.CompletionDetail} message CompletionDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionAttributionToken = ""; + object.selectedSuggestion = ""; + object.selectedPosition = 0; + } + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + object.completionAttributionToken = message.completionAttributionToken; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + object.selectedSuggestion = message.selectedSuggestion; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + object.selectedPosition = message.selectedPosition; + return object; + }; + + /** + * Converts this CompletionDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @instance + * @returns {Object.} JSON object + */ + CompletionDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompletionDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompletionDetail"; + }; + + return CompletionDetail; + })(); + + v2alpha.PurchaseTransaction = (function() { + + /** + * Properties of a PurchaseTransaction. + * @memberof google.cloud.retail.v2alpha + * @interface IPurchaseTransaction + * @property {string|null} [id] PurchaseTransaction id + * @property {number|null} [revenue] PurchaseTransaction revenue + * @property {number|null} [tax] PurchaseTransaction tax + * @property {number|null} [cost] PurchaseTransaction cost + * @property {string|null} [currencyCode] PurchaseTransaction currencyCode + */ + + /** + * Constructs a new PurchaseTransaction. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurchaseTransaction. + * @implements IPurchaseTransaction + * @constructor + * @param {google.cloud.retail.v2alpha.IPurchaseTransaction=} [properties] Properties to set + */ + function PurchaseTransaction(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]]; + } + + /** + * PurchaseTransaction id. + * @member {string} id + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.id = ""; + + /** + * PurchaseTransaction revenue. + * @member {number} revenue + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.revenue = 0; + + /** + * PurchaseTransaction tax. + * @member {number} tax + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.tax = 0; + + /** + * PurchaseTransaction cost. + * @member {number} cost + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.cost = 0; + + /** + * PurchaseTransaction currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.currencyCode = ""; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2alpha.IPurchaseTransaction=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurchaseTransaction} PurchaseTransaction instance + */ + PurchaseTransaction.create = function create(properties) { + return new PurchaseTransaction(properties); + }; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2alpha.PurchaseTransaction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2alpha.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.revenue != null && Object.hasOwnProperty.call(message, "revenue")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.revenue); + if (message.tax != null && Object.hasOwnProperty.call(message, "tax")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.tax); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.currencyCode); + return writer; + }; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurchaseTransaction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2alpha.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.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.cloud.retail.v2alpha.PurchaseTransaction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.revenue = reader.float(); + break; + } + case 3: { + message.tax = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.currencyCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurchaseTransaction message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurchaseTransaction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.revenue != null && message.hasOwnProperty("revenue")) + if (typeof message.revenue !== "number") + return "revenue: number expected"; + if (message.tax != null && message.hasOwnProperty("tax")) + if (typeof message.tax !== "number") + return "tax: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + return null; + }; + + /** + * Creates a PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurchaseTransaction} PurchaseTransaction + */ + PurchaseTransaction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurchaseTransaction) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurchaseTransaction(); + if (object.id != null) + message.id = String(object.id); + if (object.revenue != null) + message.revenue = Number(object.revenue); + if (object.tax != null) + message.tax = Number(object.tax); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + return message; + }; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2alpha.PurchaseTransaction} message PurchaseTransaction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurchaseTransaction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.revenue = 0; + object.tax = 0; + object.cost = 0; + object.currencyCode = ""; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.revenue != null && message.hasOwnProperty("revenue")) + object.revenue = options.json && !isFinite(message.revenue) ? String(message.revenue) : message.revenue; + if (message.tax != null && message.hasOwnProperty("tax")) + object.tax = options.json && !isFinite(message.tax) ? String(message.tax) : message.tax; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + return object; + }; + + /** + * Converts this PurchaseTransaction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @instance + * @returns {Object.} JSON object + */ + PurchaseTransaction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurchaseTransaction + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurchaseTransaction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurchaseTransaction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurchaseTransaction"; + }; + + return PurchaseTransaction; + })(); + + v2alpha.CatalogService = (function() { + + /** + * Constructs a new CatalogService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CatalogService + * @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 CatalogService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CatalogService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CatalogService; + + /** + * Creates new CatalogService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.CatalogService + * @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 {CatalogService} RPC service. Useful where requests and/or responses are streamed. + */ + CatalogService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|listCatalogs}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef ListCatalogsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ListCatalogsResponse} [response] ListCatalogsResponse + */ + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.ListCatalogsCallback} callback Node-style callback called with the error, if any, and ListCatalogsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.listCatalogs = function listCatalogs(request, callback) { + return this.rpcCall(listCatalogs, $root.google.cloud.retail.v2alpha.ListCatalogsRequest, $root.google.cloud.retail.v2alpha.ListCatalogsResponse, request, callback); + }, "name", { value: "ListCatalogs" }); + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateCatalog}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef UpdateCatalogCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Catalog} [response] Catalog + */ + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.UpdateCatalogCallback} callback Node-style callback called with the error, if any, and Catalog + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCatalog = function updateCatalog(request, callback) { + return this.rpcCall(updateCatalog, $root.google.cloud.retail.v2alpha.UpdateCatalogRequest, $root.google.cloud.retail.v2alpha.Catalog, request, callback); + }, "name", { value: "UpdateCatalog" }); + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|setDefaultBranch}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef SetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.SetDefaultBranchCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.setDefaultBranch = function setDefaultBranch(request, callback) { + return this.rpcCall(setDefaultBranch, $root.google.cloud.retail.v2alpha.SetDefaultBranchRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "SetDefaultBranch" }); + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getDefaultBranch}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef GetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.GetDefaultBranchResponse} [response] GetDefaultBranchResponse + */ + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.GetDefaultBranchCallback} callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getDefaultBranch = function getDefaultBranch(request, callback) { + return this.rpcCall(getDefaultBranch, $root.google.cloud.retail.v2alpha.GetDefaultBranchRequest, $root.google.cloud.retail.v2alpha.GetDefaultBranchResponse, request, callback); + }, "name", { value: "GetDefaultBranch" }); + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getCompletionConfig}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef GetCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.GetCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getCompletionConfig = function getCompletionConfig(request, callback) { + return this.rpcCall(getCompletionConfig, $root.google.cloud.retail.v2alpha.GetCompletionConfigRequest, $root.google.cloud.retail.v2alpha.CompletionConfig, request, callback); + }, "name", { value: "GetCompletionConfig" }); + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateCompletionConfig}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef UpdateCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCompletionConfig = function updateCompletionConfig(request, callback) { + return this.rpcCall(updateCompletionConfig, $root.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest, $root.google.cloud.retail.v2alpha.CompletionConfig, request, callback); + }, "name", { value: "UpdateCompletionConfig" }); + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|getAttributesConfig}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef GetAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.GetAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getAttributesConfig = function getAttributesConfig(request, callback) { + return this.rpcCall(getAttributesConfig, $root.google.cloud.retail.v2alpha.GetAttributesConfigRequest, $root.google.cloud.retail.v2alpha.AttributesConfig, request, callback); + }, "name", { value: "GetAttributesConfig" }); + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|updateAttributesConfig}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef UpdateAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateAttributesConfig = function updateAttributesConfig(request, callback) { + return this.rpcCall(updateAttributesConfig, $root.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest, $root.google.cloud.retail.v2alpha.AttributesConfig, request, callback); + }, "name", { value: "UpdateAttributesConfig" }); + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|addCatalogAttribute}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef AddCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.AddCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.addCatalogAttribute = function addCatalogAttribute(request, callback) { + return this.rpcCall(addCatalogAttribute, $root.google.cloud.retail.v2alpha.AddCatalogAttributeRequest, $root.google.cloud.retail.v2alpha.AttributesConfig, request, callback); + }, "name", { value: "AddCatalogAttribute" }); + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|removeCatalogAttribute}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef RemoveCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.removeCatalogAttribute = function removeCatalogAttribute(request, callback) { + return this.rpcCall(removeCatalogAttribute, $root.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest, $root.google.cloud.retail.v2alpha.AttributesConfig, request, callback); + }, "name", { value: "RemoveCatalogAttribute" }); + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CatalogService|replaceCatalogAttribute}. + * @memberof google.cloud.retail.v2alpha.CatalogService + * @typedef ReplaceCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.replaceCatalogAttribute = function replaceCatalogAttribute(request, callback) { + return this.rpcCall(replaceCatalogAttribute, $root.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest, $root.google.cloud.retail.v2alpha.AttributesConfig, request, callback); + }, "name", { value: "ReplaceCatalogAttribute" }); + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2alpha.CatalogService + * @instance + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CatalogService; + })(); + + v2alpha.ListCatalogsRequest = (function() { + + /** + * Properties of a ListCatalogsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IListCatalogsRequest + * @property {string|null} [parent] ListCatalogsRequest parent + * @property {number|null} [pageSize] ListCatalogsRequest pageSize + * @property {string|null} [pageToken] ListCatalogsRequest pageToken + */ + + /** + * Constructs a new ListCatalogsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListCatalogsRequest. + * @implements IListCatalogsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest=} [properties] Properties to set + */ + function ListCatalogsRequest(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]]; + } + + /** + * ListCatalogsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.parent = ""; + + /** + * ListCatalogsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageSize = 0; + + /** + * ListCatalogsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListCatalogsRequest} ListCatalogsRequest instance + */ + ListCatalogsRequest.create = function create(properties) { + return new ListCatalogsRequest(properties); + }; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.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.cloud.retail.v2alpha.ListCatalogsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListCatalogsRequest} ListCatalogsRequest + */ + ListCatalogsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListCatalogsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListCatalogsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListCatalogsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2alpha.ListCatalogsRequest} message ListCatalogsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListCatalogsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListCatalogsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListCatalogsRequest"; + }; + + return ListCatalogsRequest; + })(); + + v2alpha.ListCatalogsResponse = (function() { + + /** + * Properties of a ListCatalogsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IListCatalogsResponse + * @property {Array.|null} [catalogs] ListCatalogsResponse catalogs + * @property {string|null} [nextPageToken] ListCatalogsResponse nextPageToken + */ + + /** + * Constructs a new ListCatalogsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListCatalogsResponse. + * @implements IListCatalogsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IListCatalogsResponse=} [properties] Properties to set + */ + function ListCatalogsResponse(properties) { + this.catalogs = []; + 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]]; + } + + /** + * ListCatalogsResponse catalogs. + * @member {Array.} catalogs + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.catalogs = $util.emptyArray; + + /** + * ListCatalogsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListCatalogsResponse} ListCatalogsResponse instance + */ + ListCatalogsResponse.create = function create(properties) { + return new ListCatalogsResponse(properties); + }; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalogs != null && message.catalogs.length) + for (var i = 0; i < message.catalogs.length; ++i) + $root.google.cloud.retail.v2alpha.Catalog.encode(message.catalogs[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 ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListCatalogsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.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.cloud.retail.v2alpha.ListCatalogsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.catalogs && message.catalogs.length)) + message.catalogs = []; + message.catalogs.push($root.google.cloud.retail.v2alpha.Catalog.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalogs != null && message.hasOwnProperty("catalogs")) { + if (!Array.isArray(message.catalogs)) + return "catalogs: array expected"; + for (var i = 0; i < message.catalogs.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Catalog.verify(message.catalogs[i]); + if (error) + return "catalogs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListCatalogsResponse} ListCatalogsResponse + */ + ListCatalogsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListCatalogsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListCatalogsResponse(); + if (object.catalogs) { + if (!Array.isArray(object.catalogs)) + throw TypeError(".google.cloud.retail.v2alpha.ListCatalogsResponse.catalogs: array expected"); + message.catalogs = []; + for (var i = 0; i < object.catalogs.length; ++i) { + if (typeof object.catalogs[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListCatalogsResponse.catalogs: object expected"); + message.catalogs[i] = $root.google.cloud.retail.v2alpha.Catalog.fromObject(object.catalogs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2alpha.ListCatalogsResponse} message ListCatalogsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.catalogs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.catalogs && message.catalogs.length) { + object.catalogs = []; + for (var j = 0; j < message.catalogs.length; ++j) + object.catalogs[j] = $root.google.cloud.retail.v2alpha.Catalog.toObject(message.catalogs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListCatalogsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListCatalogsResponse"; + }; + + return ListCatalogsResponse; + })(); + + v2alpha.UpdateCatalogRequest = (function() { + + /** + * Properties of an UpdateCatalogRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateCatalogRequest + * @property {google.cloud.retail.v2alpha.ICatalog|null} [catalog] UpdateCatalogRequest catalog + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCatalogRequest updateMask + */ + + /** + * Constructs a new UpdateCatalogRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateCatalogRequest. + * @implements IUpdateCatalogRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest=} [properties] Properties to set + */ + function UpdateCatalogRequest(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]]; + } + + /** + * UpdateCatalogRequest catalog. + * @member {google.cloud.retail.v2alpha.ICatalog|null|undefined} catalog + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.catalog = null; + + /** + * UpdateCatalogRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateCatalogRequest} UpdateCatalogRequest instance + */ + UpdateCatalogRequest.create = function create(properties) { + return new UpdateCatalogRequest(properties); + }; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCatalogRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + $root.google.cloud.retail.v2alpha.Catalog.encode(message.catalog, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCatalogRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.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.cloud.retail.v2alpha.UpdateCatalogRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = $root.google.cloud.retail.v2alpha.Catalog.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCatalogRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCatalogRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) { + var error = $root.google.cloud.retail.v2alpha.Catalog.verify(message.catalog); + if (error) + return "catalog." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateCatalogRequest} UpdateCatalogRequest + */ + UpdateCatalogRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateCatalogRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateCatalogRequest(); + if (object.catalog != null) { + if (typeof object.catalog !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateCatalogRequest.catalog: object expected"); + message.catalog = $root.google.cloud.retail.v2alpha.Catalog.fromObject(object.catalog); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateCatalogRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateCatalogRequest} message UpdateCatalogRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCatalogRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = null; + object.updateMask = null; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = $root.google.cloud.retail.v2alpha.Catalog.toObject(message.catalog, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCatalogRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateCatalogRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCatalogRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateCatalogRequest"; + }; + + return UpdateCatalogRequest; + })(); + + v2alpha.SetDefaultBranchRequest = (function() { + + /** + * Properties of a SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ISetDefaultBranchRequest + * @property {string|null} [catalog] SetDefaultBranchRequest catalog + * @property {string|null} [branchId] SetDefaultBranchRequest branchId + * @property {string|null} [note] SetDefaultBranchRequest note + * @property {boolean|null} [force] SetDefaultBranchRequest force + */ + + /** + * Constructs a new SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SetDefaultBranchRequest. + * @implements ISetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest=} [properties] Properties to set + */ + function SetDefaultBranchRequest(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]]; + } + + /** + * SetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.catalog = ""; + + /** + * SetDefaultBranchRequest branchId. + * @member {string} branchId + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.branchId = ""; + + /** + * SetDefaultBranchRequest note. + * @member {string} note + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.note = ""; + + /** + * SetDefaultBranchRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.force = false; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SetDefaultBranchRequest} SetDefaultBranchRequest instance + */ + SetDefaultBranchRequest.create = function create(properties) { + return new SetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.branchId != null && Object.hasOwnProperty.call(message, "branchId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branchId); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.force); + return writer; + }; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.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.cloud.retail.v2alpha.SetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.branchId = reader.string(); + break; + } + case 3: { + message.note = reader.string(); + break; + } + case 4: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.branchId != null && message.hasOwnProperty("branchId")) + if (!$util.isString(message.branchId)) + return "branchId: string expected"; + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SetDefaultBranchRequest} SetDefaultBranchRequest + */ + SetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.SetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.branchId != null) + message.branchId = String(object.branchId); + if (object.note != null) + message.note = String(object.note); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.SetDefaultBranchRequest} message SetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = ""; + object.branchId = ""; + object.note = ""; + object.force = false; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.branchId != null && message.hasOwnProperty("branchId")) + object.branchId = message.branchId; + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + SetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SetDefaultBranchRequest"; + }; + + return SetDefaultBranchRequest; + })(); + + v2alpha.GetDefaultBranchRequest = (function() { + + /** + * Properties of a GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetDefaultBranchRequest + * @property {string|null} [catalog] GetDefaultBranchRequest catalog + */ + + /** + * Constructs a new GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetDefaultBranchRequest. + * @implements IGetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest=} [properties] Properties to set + */ + function GetDefaultBranchRequest(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]]; + } + + /** + * GetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @instance + */ + GetDefaultBranchRequest.prototype.catalog = ""; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchRequest} GetDefaultBranchRequest instance + */ + GetDefaultBranchRequest.create = function create(properties) { + return new GetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.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.cloud.retail.v2alpha.GetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchRequest} GetDefaultBranchRequest + */ + GetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2alpha.GetDefaultBranchRequest} message GetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.catalog = ""; + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + return object; + }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetDefaultBranchRequest"; + }; + + return GetDefaultBranchRequest; + })(); + + v2alpha.GetDefaultBranchResponse = (function() { + + /** + * Properties of a GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IGetDefaultBranchResponse + * @property {string|null} [branch] GetDefaultBranchResponse branch + * @property {google.protobuf.ITimestamp|null} [setTime] GetDefaultBranchResponse setTime + * @property {string|null} [note] GetDefaultBranchResponse note + */ + + /** + * Constructs a new GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetDefaultBranchResponse. + * @implements IGetDefaultBranchResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchResponse=} [properties] Properties to set + */ + function GetDefaultBranchResponse(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]]; + } + + /** + * GetDefaultBranchResponse branch. + * @member {string} branch + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.branch = ""; + + /** + * GetDefaultBranchResponse setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.setTime = null; + + /** + * GetDefaultBranchResponse note. + * @member {string} note + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.note = ""; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchResponse} GetDefaultBranchResponse instance + */ + GetDefaultBranchResponse.create = function create(properties) { + return new GetDefaultBranchResponse(properties); + }; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.branch); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2alpha.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.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.cloud.retail.v2alpha.GetDefaultBranchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.branch = reader.string(); + break; + } + case 2: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.note = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetDefaultBranchResponse} GetDefaultBranchResponse + */ + GetDefaultBranchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetDefaultBranchResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetDefaultBranchResponse(); + if (object.branch != null) + message.branch = String(object.branch); + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.GetDefaultBranchResponse.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.note != null) + message.note = String(object.note); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2alpha.GetDefaultBranchResponse} message GetDefaultBranchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.branch = ""; + object.setTime = null; + object.note = ""; + } + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + return object; + }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetDefaultBranchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetDefaultBranchResponse"; + }; + + return GetDefaultBranchResponse; + })(); + + v2alpha.GetCompletionConfigRequest = (function() { + + /** + * Properties of a GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetCompletionConfigRequest + * @property {string|null} [name] GetCompletionConfigRequest name + */ + + /** + * Constructs a new GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetCompletionConfigRequest. + * @implements IGetCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest=} [properties] Properties to set + */ + function GetCompletionConfigRequest(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]]; + } + + /** + * GetCompletionConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @instance + */ + GetCompletionConfigRequest.prototype.name = ""; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetCompletionConfigRequest} GetCompletionConfigRequest instance + */ + GetCompletionConfigRequest.create = function create(properties) { + return new GetCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.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.cloud.retail.v2alpha.GetCompletionConfigRequest(); + 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 GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetCompletionConfigRequest} GetCompletionConfigRequest + */ + GetCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetCompletionConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.GetCompletionConfigRequest} message GetCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetCompletionConfigRequest"; + }; + + return GetCompletionConfigRequest; + })(); + + v2alpha.UpdateCompletionConfigRequest = (function() { + + /** + * Properties of an UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateCompletionConfigRequest + * @property {google.cloud.retail.v2alpha.ICompletionConfig|null} [completionConfig] UpdateCompletionConfigRequest completionConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCompletionConfigRequest updateMask + */ + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateCompletionConfigRequest. + * @implements IUpdateCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest=} [properties] Properties to set + */ + function UpdateCompletionConfigRequest(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]]; + } + + /** + * UpdateCompletionConfigRequest completionConfig. + * @member {google.cloud.retail.v2alpha.ICompletionConfig|null|undefined} completionConfig + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.completionConfig = null; + + /** + * UpdateCompletionConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest instance + */ + UpdateCompletionConfigRequest.create = function create(properties) { + return new UpdateCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionConfig != null && Object.hasOwnProperty.call(message, "completionConfig")) + $root.google.cloud.retail.v2alpha.CompletionConfig.encode(message.completionConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.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.cloud.retail.v2alpha.UpdateCompletionConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionConfig = $root.google.cloud.retail.v2alpha.CompletionConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCompletionConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) { + var error = $root.google.cloud.retail.v2alpha.CompletionConfig.verify(message.completionConfig); + if (error) + return "completionConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + */ + UpdateCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest(); + if (object.completionConfig != null) { + if (typeof object.completionConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.completionConfig: object expected"); + message.completionConfig = $root.google.cloud.retail.v2alpha.CompletionConfig.fromObject(object.completionConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateCompletionConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateCompletionConfigRequest} message UpdateCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCompletionConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionConfig = null; + object.updateMask = null; + } + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) + object.completionConfig = $root.google.cloud.retail.v2alpha.CompletionConfig.toObject(message.completionConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateCompletionConfigRequest"; + }; + + return UpdateCompletionConfigRequest; + })(); + + v2alpha.GetAttributesConfigRequest = (function() { + + /** + * Properties of a GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetAttributesConfigRequest + * @property {string|null} [name] GetAttributesConfigRequest name + */ + + /** + * Constructs a new GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetAttributesConfigRequest. + * @implements IGetAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest=} [properties] Properties to set + */ + function GetAttributesConfigRequest(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]]; + } + + /** + * GetAttributesConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @instance + */ + GetAttributesConfigRequest.prototype.name = ""; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetAttributesConfigRequest} GetAttributesConfigRequest instance + */ + GetAttributesConfigRequest.create = function create(properties) { + return new GetAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.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.cloud.retail.v2alpha.GetAttributesConfigRequest(); + 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 GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetAttributesConfigRequest} GetAttributesConfigRequest + */ + GetAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetAttributesConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.GetAttributesConfigRequest} message GetAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetAttributesConfigRequest"; + }; + + return GetAttributesConfigRequest; + })(); + + v2alpha.UpdateAttributesConfigRequest = (function() { + + /** + * Properties of an UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateAttributesConfigRequest + * @property {google.cloud.retail.v2alpha.IAttributesConfig|null} [attributesConfig] UpdateAttributesConfigRequest attributesConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateAttributesConfigRequest updateMask + */ + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateAttributesConfigRequest. + * @implements IUpdateAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest=} [properties] Properties to set + */ + function UpdateAttributesConfigRequest(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]]; + } + + /** + * UpdateAttributesConfigRequest attributesConfig. + * @member {google.cloud.retail.v2alpha.IAttributesConfig|null|undefined} attributesConfig + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.attributesConfig = null; + + /** + * UpdateAttributesConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest instance + */ + UpdateAttributesConfigRequest.create = function create(properties) { + return new UpdateAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + $root.google.cloud.retail.v2alpha.AttributesConfig.encode(message.attributesConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.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.cloud.retail.v2alpha.UpdateAttributesConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = $root.google.cloud.retail.v2alpha.AttributesConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateAttributesConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) { + var error = $root.google.cloud.retail.v2alpha.AttributesConfig.verify(message.attributesConfig); + if (error) + return "attributesConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + */ + UpdateAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest(); + if (object.attributesConfig != null) { + if (typeof object.attributesConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.attributesConfig: object expected"); + message.attributesConfig = $root.google.cloud.retail.v2alpha.AttributesConfig.fromObject(object.attributesConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateAttributesConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateAttributesConfigRequest} message UpdateAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateAttributesConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = $root.google.cloud.retail.v2alpha.AttributesConfig.toObject(message.attributesConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateAttributesConfigRequest"; + }; + + return UpdateAttributesConfigRequest; + })(); + + v2alpha.AddCatalogAttributeRequest = (function() { + + /** + * Properties of an AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IAddCatalogAttributeRequest + * @property {string|null} [attributesConfig] AddCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2alpha.ICatalogAttribute|null} [catalogAttribute] AddCatalogAttributeRequest catalogAttribute + */ + + /** + * Constructs a new AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddCatalogAttributeRequest. + * @implements IAddCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest=} [properties] Properties to set + */ + function AddCatalogAttributeRequest(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]]; + } + + /** + * AddCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * AddCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2alpha.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddCatalogAttributeRequest} AddCatalogAttributeRequest instance + */ + AddCatalogAttributeRequest.create = function create(properties) { + return new AddCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2alpha.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.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.cloud.retail.v2alpha.AddCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2alpha.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + return null; + }; + + /** + * Creates an AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddCatalogAttributeRequest} AddCatalogAttributeRequest + */ + AddCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.AddCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AddCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.fromObject(object.catalogAttribute); + } + return message; + }; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.AddCatalogAttributeRequest} message AddCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.toObject(message.catalogAttribute, options); + return object; + }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + AddCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddCatalogAttributeRequest"; + }; + + return AddCatalogAttributeRequest; + })(); + + v2alpha.RemoveCatalogAttributeRequest = (function() { + + /** + * Properties of a RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveCatalogAttributeRequest + * @property {string|null} [attributesConfig] RemoveCatalogAttributeRequest attributesConfig + * @property {string|null} [key] RemoveCatalogAttributeRequest key + */ + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveCatalogAttributeRequest. + * @implements IRemoveCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest=} [properties] Properties to set + */ + function RemoveCatalogAttributeRequest(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]]; + } + + /** + * RemoveCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * RemoveCatalogAttributeRequest key. + * @member {string} key + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.key = ""; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest instance + */ + RemoveCatalogAttributeRequest.create = function create(properties) { + return new RemoveCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.key); + return writer; + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.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.cloud.retail.v2alpha.RemoveCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.key = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + return null; + }; + + /** + * Creates a RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + */ + RemoveCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.key != null) + message.key = String(object.key); + return message; + }; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.key = ""; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + return object; + }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest"; + }; + + return RemoveCatalogAttributeRequest; + })(); + + v2alpha.ReplaceCatalogAttributeRequest = (function() { + + /** + * Properties of a ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IReplaceCatalogAttributeRequest + * @property {string|null} [attributesConfig] ReplaceCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2alpha.ICatalogAttribute|null} [catalogAttribute] ReplaceCatalogAttributeRequest catalogAttribute + * @property {google.protobuf.IFieldMask|null} [updateMask] ReplaceCatalogAttributeRequest updateMask + */ + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ReplaceCatalogAttributeRequest. + * @implements IReplaceCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest=} [properties] Properties to set + */ + function ReplaceCatalogAttributeRequest(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]]; + } + + /** + * ReplaceCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * ReplaceCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2alpha.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * ReplaceCatalogAttributeRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.updateMask = null; + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest instance + */ + ReplaceCatalogAttributeRequest.create = function create(properties) { + return new ReplaceCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2alpha.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.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.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + case 3: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplaceCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplaceCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2alpha.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates a ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + */ + ReplaceCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.fromObject(object.catalogAttribute); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplaceCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2alpha.CatalogAttribute.toObject(message.catalogAttribute, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + ReplaceCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplaceCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest"; + }; + + return ReplaceCatalogAttributeRequest; + })(); + + v2alpha.CompletionService = (function() { + + /** + * Constructs a new CompletionService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompletionService + * @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 CompletionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CompletionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CompletionService; + + /** + * Creates new CompletionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.CompletionService + * @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 {CompletionService} RPC service. Useful where requests and/or responses are streamed. + */ + CompletionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CompletionService|completeQuery}. + * @memberof google.cloud.retail.v2alpha.CompletionService + * @typedef CompleteQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse} [response] CompleteQueryResponse + */ + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2alpha.CompletionService + * @instance + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @param {google.cloud.retail.v2alpha.CompletionService.CompleteQueryCallback} callback Node-style callback called with the error, if any, and CompleteQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.completeQuery = function completeQuery(request, callback) { + return this.rpcCall(completeQuery, $root.google.cloud.retail.v2alpha.CompleteQueryRequest, $root.google.cloud.retail.v2alpha.CompleteQueryResponse, request, callback); + }, "name", { value: "CompleteQuery" }); + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2alpha.CompletionService + * @instance + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.CompletionService|importCompletionData}. + * @memberof google.cloud.retail.v2alpha.CompletionService + * @typedef ImportCompletionDataCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2alpha.CompletionService + * @instance + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @param {google.cloud.retail.v2alpha.CompletionService.ImportCompletionDataCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.importCompletionData = function importCompletionData(request, callback) { + return this.rpcCall(importCompletionData, $root.google.cloud.retail.v2alpha.ImportCompletionDataRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportCompletionData" }); + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2alpha.CompletionService + * @instance + * @param {google.cloud.retail.v2alpha.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CompletionService; + })(); + + v2alpha.CompleteQueryRequest = (function() { + + /** + * Properties of a CompleteQueryRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICompleteQueryRequest + * @property {string|null} [catalog] CompleteQueryRequest catalog + * @property {string|null} [query] CompleteQueryRequest query + * @property {string|null} [visitorId] CompleteQueryRequest visitorId + * @property {Array.|null} [languageCodes] CompleteQueryRequest languageCodes + * @property {string|null} [deviceType] CompleteQueryRequest deviceType + * @property {string|null} [dataset] CompleteQueryRequest dataset + * @property {number|null} [maxSuggestions] CompleteQueryRequest maxSuggestions + */ + + /** + * Constructs a new CompleteQueryRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompleteQueryRequest. + * @implements ICompleteQueryRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest=} [properties] Properties to set + */ + function CompleteQueryRequest(properties) { + this.languageCodes = []; + 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]]; + } + + /** + * CompleteQueryRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.catalog = ""; + + /** + * CompleteQueryRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.query = ""; + + /** + * CompleteQueryRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.visitorId = ""; + + /** + * CompleteQueryRequest languageCodes. + * @member {Array.} languageCodes + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.languageCodes = $util.emptyArray; + + /** + * CompleteQueryRequest deviceType. + * @member {string} deviceType + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.deviceType = ""; + + /** + * CompleteQueryRequest dataset. + * @member {string} dataset + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.dataset = ""; + + /** + * CompleteQueryRequest maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.maxSuggestions = 0; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompleteQueryRequest} CompleteQueryRequest instance + */ + CompleteQueryRequest.create = function create(properties) { + return new CompleteQueryRequest(properties); + }; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.query); + if (message.languageCodes != null && message.languageCodes.length) + for (var i = 0; i < message.languageCodes.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.languageCodes[i]); + if (message.deviceType != null && Object.hasOwnProperty.call(message, "deviceType")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.deviceType); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.maxSuggestions); + if (message.dataset != null && Object.hasOwnProperty.call(message, "dataset")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.dataset); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.visitorId); + return writer; + }; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.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.cloud.retail.v2alpha.CompleteQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.query = reader.string(); + break; + } + case 7: { + message.visitorId = reader.string(); + break; + } + case 3: { + if (!(message.languageCodes && message.languageCodes.length)) + message.languageCodes = []; + message.languageCodes.push(reader.string()); + break; + } + case 4: { + message.deviceType = reader.string(); + break; + } + case 6: { + message.dataset = reader.string(); + break; + } + case 5: { + message.maxSuggestions = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.languageCodes != null && message.hasOwnProperty("languageCodes")) { + if (!Array.isArray(message.languageCodes)) + return "languageCodes: array expected"; + for (var i = 0; i < message.languageCodes.length; ++i) + if (!$util.isString(message.languageCodes[i])) + return "languageCodes: string[] expected"; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + if (!$util.isString(message.deviceType)) + return "deviceType: string expected"; + if (message.dataset != null && message.hasOwnProperty("dataset")) + if (!$util.isString(message.dataset)) + return "dataset: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + return null; + }; + + /** + * Creates a CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompleteQueryRequest} CompleteQueryRequest + */ + CompleteQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompleteQueryRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompleteQueryRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.languageCodes) { + if (!Array.isArray(object.languageCodes)) + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryRequest.languageCodes: array expected"); + message.languageCodes = []; + for (var i = 0; i < object.languageCodes.length; ++i) + message.languageCodes[i] = String(object.languageCodes[i]); + } + if (object.deviceType != null) + message.deviceType = String(object.deviceType); + if (object.dataset != null) + message.dataset = String(object.dataset); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + return message; + }; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryRequest} message CompleteQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languageCodes = []; + if (options.defaults) { + object.catalog = ""; + object.query = ""; + object.deviceType = ""; + object.maxSuggestions = 0; + object.dataset = ""; + object.visitorId = ""; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.languageCodes && message.languageCodes.length) { + object.languageCodes = []; + for (var j = 0; j < message.languageCodes.length; ++j) + object.languageCodes[j] = message.languageCodes[j]; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + object.deviceType = message.deviceType; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.dataset != null && message.hasOwnProperty("dataset")) + object.dataset = message.dataset; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + return object; + }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompleteQueryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompleteQueryRequest"; + }; + + return CompleteQueryRequest; + })(); + + v2alpha.CompleteQueryResponse = (function() { + + /** + * Properties of a CompleteQueryResponse. + * @memberof google.cloud.retail.v2alpha + * @interface ICompleteQueryResponse + * @property {Array.|null} [completionResults] CompleteQueryResponse completionResults + * @property {string|null} [attributionToken] CompleteQueryResponse attributionToken + * @property {Array.|null} [recentSearchResults] CompleteQueryResponse recentSearchResults + */ + + /** + * Constructs a new CompleteQueryResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CompleteQueryResponse. + * @implements ICompleteQueryResponse + * @constructor + * @param {google.cloud.retail.v2alpha.ICompleteQueryResponse=} [properties] Properties to set + */ + function CompleteQueryResponse(properties) { + this.completionResults = []; + this.recentSearchResults = []; + 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]]; + } + + /** + * CompleteQueryResponse completionResults. + * @member {Array.} completionResults + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.completionResults = $util.emptyArray; + + /** + * CompleteQueryResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.attributionToken = ""; + + /** + * CompleteQueryResponse recentSearchResults. + * @member {Array.} recentSearchResults + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.recentSearchResults = $util.emptyArray; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse} CompleteQueryResponse instance + */ + CompleteQueryResponse.create = function create(properties) { + return new CompleteQueryResponse(properties); + }; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionResults != null && message.completionResults.length) + for (var i = 0; i < message.completionResults.length; ++i) + $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.encode(message.completionResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.recentSearchResults != null && message.recentSearchResults.length) + for (var i = 0; i < message.recentSearchResults.length; ++i) + $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.encode(message.recentSearchResults[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2alpha.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.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.cloud.retail.v2alpha.CompleteQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.completionResults && message.completionResults.length)) + message.completionResults = []; + message.completionResults.push($root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.recentSearchResults && message.recentSearchResults.length)) + message.recentSearchResults = []; + message.recentSearchResults.push($root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionResults != null && message.hasOwnProperty("completionResults")) { + if (!Array.isArray(message.completionResults)) + return "completionResults: array expected"; + for (var i = 0; i < message.completionResults.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.verify(message.completionResults[i]); + if (error) + return "completionResults." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.recentSearchResults != null && message.hasOwnProperty("recentSearchResults")) { + if (!Array.isArray(message.recentSearchResults)) + return "recentSearchResults: array expected"; + for (var i = 0; i < message.recentSearchResults.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.verify(message.recentSearchResults[i]); + if (error) + return "recentSearchResults." + error; + } + } + return null; + }; + + /** + * Creates a CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse} CompleteQueryResponse + */ + CompleteQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompleteQueryResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompleteQueryResponse(); + if (object.completionResults) { + if (!Array.isArray(object.completionResults)) + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.completionResults: array expected"); + message.completionResults = []; + for (var i = 0; i < object.completionResults.length; ++i) { + if (typeof object.completionResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.completionResults: object expected"); + message.completionResults[i] = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.fromObject(object.completionResults[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.recentSearchResults) { + if (!Array.isArray(object.recentSearchResults)) + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.recentSearchResults: array expected"); + message.recentSearchResults = []; + for (var i = 0; i < object.recentSearchResults.length; ++i) { + if (typeof object.recentSearchResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.recentSearchResults: object expected"); + message.recentSearchResults[i] = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.fromObject(object.recentSearchResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse} message CompleteQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.completionResults = []; + object.recentSearchResults = []; + } + if (options.defaults) + object.attributionToken = ""; + if (message.completionResults && message.completionResults.length) { + object.completionResults = []; + for (var j = 0; j < message.completionResults.length; ++j) + object.completionResults[j] = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.toObject(message.completionResults[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.recentSearchResults && message.recentSearchResults.length) { + object.recentSearchResults = []; + for (var j = 0; j < message.recentSearchResults.length; ++j) + object.recentSearchResults[j] = $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.toObject(message.recentSearchResults[j], options); + } + return object; + }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompleteQueryResponse"; + }; + + CompleteQueryResponse.CompletionResult = (function() { + + /** + * Properties of a CompletionResult. + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @interface ICompletionResult + * @property {string|null} [suggestion] CompletionResult suggestion + * @property {Object.|null} [attributes] CompletionResult attributes + */ + + /** + * Constructs a new CompletionResult. + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @classdesc Represents a CompletionResult. + * @implements ICompletionResult + * @constructor + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + */ + function CompletionResult(properties) { + this.attributes = {}; + 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]]; + } + + /** + * CompletionResult suggestion. + * @member {string} suggestion + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.suggestion = ""; + + /** + * CompletionResult attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.attributes = $util.emptyObject; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult} CompletionResult instance + */ + CompletionResult.create = function create(properties) { + return new CompletionResult(properties); + }; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.suggestion != null && Object.hasOwnProperty.call(message, "suggestion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.suggestion); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2alpha.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.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.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.suggestion = reader.string(); + break; + } + case 2: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2alpha.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + if (!$util.isString(message.suggestion)) + return "suggestion: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + return null; + }; + + /** + * Creates a CompletionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult} CompletionResult + */ + CompletionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult(); + if (object.suggestion != null) + message.suggestion = String(object.suggestion); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2alpha.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult} message CompletionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) + object.suggestion = ""; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + object.suggestion = message.suggestion; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2alpha.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + return object; + }; + + /** + * Converts this CompletionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @instance + * @returns {Object.} JSON object + */ + CompletionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult"; + }; + + return CompletionResult; + })(); + + CompleteQueryResponse.RecentSearchResult = (function() { + + /** + * Properties of a RecentSearchResult. + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @interface IRecentSearchResult + * @property {string|null} [recentSearch] RecentSearchResult recentSearch + */ + + /** + * Constructs a new RecentSearchResult. + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse + * @classdesc Represents a RecentSearchResult. + * @implements IRecentSearchResult + * @constructor + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + */ + function RecentSearchResult(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]]; + } + + /** + * RecentSearchResult recentSearch. + * @member {string} recentSearch + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @instance + */ + RecentSearchResult.prototype.recentSearch = ""; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult} RecentSearchResult instance + */ + RecentSearchResult.create = function create(properties) { + return new RecentSearchResult(properties); + }; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recentSearch != null && Object.hasOwnProperty.call(message, "recentSearch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.recentSearch); + return writer; + }; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.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.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recentSearch = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentSearchResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentSearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + if (!$util.isString(message.recentSearch)) + return "recentSearch: string expected"; + return null; + }; + + /** + * Creates a RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + */ + RecentSearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult(); + if (object.recentSearch != null) + message.recentSearch = String(object.recentSearch); + return message; + }; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult} message RecentSearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentSearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.recentSearch = ""; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + object.recentSearch = message.recentSearch; + return object; + }; + + /** + * Converts this RecentSearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @instance + * @returns {Object.} JSON object + */ + RecentSearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecentSearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecentSearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CompleteQueryResponse.RecentSearchResult"; + }; + + return RecentSearchResult; + })(); + + return CompleteQueryResponse; + })(); + + v2alpha.Control = (function() { + + /** + * Properties of a Control. + * @memberof google.cloud.retail.v2alpha + * @interface IControl + * @property {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec|null} [facetSpec] Control facetSpec + * @property {google.cloud.retail.v2alpha.IRule|null} [rule] Control rule + * @property {string|null} [name] Control name + * @property {string|null} [displayName] Control displayName + * @property {Array.|null} [associatedServingConfigIds] Control associatedServingConfigIds + * @property {Array.|null} [solutionTypes] Control solutionTypes + * @property {Array.|null} [searchSolutionUseCase] Control searchSolutionUseCase + */ + + /** + * Constructs a new Control. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Control. + * @implements IControl + * @constructor + * @param {google.cloud.retail.v2alpha.IControl=} [properties] Properties to set + */ + function Control(properties) { + this.associatedServingConfigIds = []; + this.solutionTypes = []; + this.searchSolutionUseCase = []; + 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]]; + } + + /** + * Control facetSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec|null|undefined} facetSpec + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.facetSpec = null; + + /** + * Control rule. + * @member {google.cloud.retail.v2alpha.IRule|null|undefined} rule + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.rule = null; + + /** + * Control name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.name = ""; + + /** + * Control displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.displayName = ""; + + /** + * Control associatedServingConfigIds. + * @member {Array.} associatedServingConfigIds + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.associatedServingConfigIds = $util.emptyArray; + + /** + * Control solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.solutionTypes = $util.emptyArray; + + /** + * Control searchSolutionUseCase. + * @member {Array.} searchSolutionUseCase + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Control.prototype.searchSolutionUseCase = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Control control. + * @member {"facetSpec"|"rule"|undefined} control + * @memberof google.cloud.retail.v2alpha.Control + * @instance + */ + Object.defineProperty(Control.prototype, "control", { + get: $util.oneOfGetter($oneOfFields = ["facetSpec", "rule"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Control instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {google.cloud.retail.v2alpha.IControl=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Control} Control instance + */ + Control.create = function create(properties) { + return new Control(properties); + }; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2alpha.Control.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {google.cloud.retail.v2alpha.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.facetSpec != null && Object.hasOwnProperty.call(message, "facetSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.encode(message.facetSpec, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.rule != null && Object.hasOwnProperty.call(message, "rule")) + $root.google.cloud.retail.v2alpha.Rule.encode(message.rule, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.associatedServingConfigIds != null && message.associatedServingConfigIds.length) + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.associatedServingConfigIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 6, wireType 2 =*/50).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + if (message.searchSolutionUseCase != null && message.searchSolutionUseCase.length) { + writer.uint32(/* id 7, wireType 2 =*/58).fork(); + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + writer.int32(message.searchSolutionUseCase[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Control.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {google.cloud.retail.v2alpha.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Control message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.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.cloud.retail.v2alpha.Control(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.facetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.decode(reader, reader.uint32()); + break; + } + case 4: { + message.rule = $root.google.cloud.retail.v2alpha.Rule.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 5: { + if (!(message.associatedServingConfigIds && message.associatedServingConfigIds.length)) + message.associatedServingConfigIds = []; + message.associatedServingConfigIds.push(reader.string()); + break; + } + case 6: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + case 7: { + if (!(message.searchSolutionUseCase && message.searchSolutionUseCase.length)) + message.searchSolutionUseCase = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.searchSolutionUseCase.push(reader.int32()); + } else + message.searchSolutionUseCase.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Control message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Control.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.facetSpec != null && message.hasOwnProperty("facetSpec")) { + properties.control = 1; + { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify(message.facetSpec); + if (error) + return "facetSpec." + error; + } + } + if (message.rule != null && message.hasOwnProperty("rule")) { + if (properties.control === 1) + return "control: multiple values"; + properties.control = 1; + { + var error = $root.google.cloud.retail.v2alpha.Rule.verify(message.rule); + if (error) + return "rule." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.associatedServingConfigIds != null && message.hasOwnProperty("associatedServingConfigIds")) { + if (!Array.isArray(message.associatedServingConfigIds)) + return "associatedServingConfigIds: array expected"; + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + if (!$util.isString(message.associatedServingConfigIds[i])) + return "associatedServingConfigIds: string[] expected"; + } + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + if (message.searchSolutionUseCase != null && message.hasOwnProperty("searchSolutionUseCase")) { + if (!Array.isArray(message.searchSolutionUseCase)) + return "searchSolutionUseCase: array expected"; + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + switch (message.searchSolutionUseCase[i]) { + default: + return "searchSolutionUseCase: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a Control message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Control} Control + */ + Control.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Control) + return object; + var message = new $root.google.cloud.retail.v2alpha.Control(); + if (object.facetSpec != null) { + if (typeof object.facetSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Control.facetSpec: object expected"); + message.facetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.fromObject(object.facetSpec); + } + if (object.rule != null) { + if (typeof object.rule !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Control.rule: object expected"); + message.rule = $root.google.cloud.retail.v2alpha.Rule.fromObject(object.rule); + } + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.associatedServingConfigIds) { + if (!Array.isArray(object.associatedServingConfigIds)) + throw TypeError(".google.cloud.retail.v2alpha.Control.associatedServingConfigIds: array expected"); + message.associatedServingConfigIds = []; + for (var i = 0; i < object.associatedServingConfigIds.length; ++i) + message.associatedServingConfigIds[i] = String(object.associatedServingConfigIds[i]); + } + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2alpha.Control.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + if (object.searchSolutionUseCase) { + if (!Array.isArray(object.searchSolutionUseCase)) + throw TypeError(".google.cloud.retail.v2alpha.Control.searchSolutionUseCase: array expected"); + message.searchSolutionUseCase = []; + for (var i = 0; i < object.searchSolutionUseCase.length; ++i) + switch (object.searchSolutionUseCase[i]) { + default: + if (typeof object.searchSolutionUseCase[i] === "number") { + message.searchSolutionUseCase[i] = object.searchSolutionUseCase[i]; + break; + } + case "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": + case 0: + message.searchSolutionUseCase[i] = 0; + break; + case "SEARCH_SOLUTION_USE_CASE_SEARCH": + case 1: + message.searchSolutionUseCase[i] = 1; + break; + case "SEARCH_SOLUTION_USE_CASE_BROWSE": + case 2: + message.searchSolutionUseCase[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {google.cloud.retail.v2alpha.Control} message Control + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Control.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.associatedServingConfigIds = []; + object.solutionTypes = []; + object.searchSolutionUseCase = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.facetSpec != null && message.hasOwnProperty("facetSpec")) { + object.facetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.toObject(message.facetSpec, options); + if (options.oneofs) + object.control = "facetSpec"; + } + if (message.rule != null && message.hasOwnProperty("rule")) { + object.rule = $root.google.cloud.retail.v2alpha.Rule.toObject(message.rule, options); + if (options.oneofs) + object.control = "rule"; + } + if (message.associatedServingConfigIds && message.associatedServingConfigIds.length) { + object.associatedServingConfigIds = []; + for (var j = 0; j < message.associatedServingConfigIds.length; ++j) + object.associatedServingConfigIds[j] = message.associatedServingConfigIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2alpha.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2alpha.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + if (message.searchSolutionUseCase && message.searchSolutionUseCase.length) { + object.searchSolutionUseCase = []; + for (var j = 0; j < message.searchSolutionUseCase.length; ++j) + object.searchSolutionUseCase[j] = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchSolutionUseCase[message.searchSolutionUseCase[j]] === undefined ? message.searchSolutionUseCase[j] : $root.google.cloud.retail.v2alpha.SearchSolutionUseCase[message.searchSolutionUseCase[j]] : message.searchSolutionUseCase[j]; + } + return object; + }; + + /** + * Converts this Control to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Control + * @instance + * @returns {Object.} JSON object + */ + Control.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Control + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Control + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Control.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Control"; + }; + + return Control; + })(); + + v2alpha.SearchService = (function() { + + /** + * Constructs a new SearchService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SearchService + * @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 SearchService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (SearchService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = SearchService; + + /** + * Creates new SearchService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchService + * @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 {SearchService} RPC service. Useful where requests and/or responses are streamed. + */ + SearchService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.SearchService|search}. + * @memberof google.cloud.retail.v2alpha.SearchService + * @typedef SearchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.SearchResponse} [response] SearchResponse + */ + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2alpha.SearchService + * @instance + * @param {google.cloud.retail.v2alpha.ISearchRequest} request SearchRequest message or plain object + * @param {google.cloud.retail.v2alpha.SearchService.SearchCallback} callback Node-style callback called with the error, if any, and SearchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SearchService.prototype.search = function search(request, callback) { + return this.rpcCall(search, $root.google.cloud.retail.v2alpha.SearchRequest, $root.google.cloud.retail.v2alpha.SearchResponse, request, callback); + }, "name", { value: "Search" }); + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2alpha.SearchService + * @instance + * @param {google.cloud.retail.v2alpha.ISearchRequest} request SearchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return SearchService; + })(); + + v2alpha.SearchRequest = (function() { + + /** + * Properties of a SearchRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ISearchRequest + * @property {string|null} [placement] SearchRequest placement + * @property {string|null} [branch] SearchRequest branch + * @property {string|null} [query] SearchRequest query + * @property {string|null} [visitorId] SearchRequest visitorId + * @property {google.cloud.retail.v2alpha.IUserInfo|null} [userInfo] SearchRequest userInfo + * @property {number|null} [pageSize] SearchRequest pageSize + * @property {string|null} [pageToken] SearchRequest pageToken + * @property {number|null} [offset] SearchRequest offset + * @property {string|null} [filter] SearchRequest filter + * @property {string|null} [canonicalFilter] SearchRequest canonicalFilter + * @property {string|null} [orderBy] SearchRequest orderBy + * @property {Array.|null} [facetSpecs] SearchRequest facetSpecs + * @property {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] SearchRequest dynamicFacetSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec|null} [boostSpec] SearchRequest boostSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec|null} [queryExpansionSpec] SearchRequest queryExpansionSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold|null} [relevanceThreshold] SearchRequest relevanceThreshold + * @property {Array.|null} [variantRollupKeys] SearchRequest variantRollupKeys + * @property {Array.|null} [pageCategories] SearchRequest pageCategories + * @property {google.cloud.retail.v2alpha.SearchRequest.SearchMode|null} [searchMode] SearchRequest searchMode + * @property {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] SearchRequest personalizationSpec + * @property {Object.|null} [labels] SearchRequest labels + * @property {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec|null} [spellCorrectionSpec] SearchRequest spellCorrectionSpec + */ + + /** + * Constructs a new SearchRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SearchRequest. + * @implements ISearchRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ISearchRequest=} [properties] Properties to set + */ + function SearchRequest(properties) { + this.facetSpecs = []; + this.variantRollupKeys = []; + this.pageCategories = []; + 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]]; + } + + /** + * SearchRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.placement = ""; + + /** + * SearchRequest branch. + * @member {string} branch + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.branch = ""; + + /** + * SearchRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.query = ""; + + /** + * SearchRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.visitorId = ""; + + /** + * SearchRequest userInfo. + * @member {google.cloud.retail.v2alpha.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.userInfo = null; + + /** + * SearchRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.pageSize = 0; + + /** + * SearchRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.pageToken = ""; + + /** + * SearchRequest offset. + * @member {number} offset + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.offset = 0; + + /** + * SearchRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.filter = ""; + + /** + * SearchRequest canonicalFilter. + * @member {string} canonicalFilter + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.canonicalFilter = ""; + + /** + * SearchRequest orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.orderBy = ""; + + /** + * SearchRequest facetSpecs. + * @member {Array.} facetSpecs + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.facetSpecs = $util.emptyArray; + + /** + * SearchRequest dynamicFacetSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.dynamicFacetSpec = null; + + /** + * SearchRequest boostSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec|null|undefined} boostSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.boostSpec = null; + + /** + * SearchRequest queryExpansionSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec|null|undefined} queryExpansionSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.queryExpansionSpec = null; + + /** + * SearchRequest relevanceThreshold. + * @member {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} relevanceThreshold + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.relevanceThreshold = 0; + + /** + * SearchRequest variantRollupKeys. + * @member {Array.} variantRollupKeys + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.variantRollupKeys = $util.emptyArray; + + /** + * SearchRequest pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.pageCategories = $util.emptyArray; + + /** + * SearchRequest searchMode. + * @member {google.cloud.retail.v2alpha.SearchRequest.SearchMode} searchMode + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.searchMode = 0; + + /** + * SearchRequest personalizationSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec|null|undefined} personalizationSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.personalizationSpec = null; + + /** + * SearchRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.labels = $util.emptyObject; + + /** + * SearchRequest spellCorrectionSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec|null|undefined} spellCorrectionSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + SearchRequest.prototype.spellCorrectionSpec = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * SearchRequest _spellCorrectionSpec. + * @member {"spellCorrectionSpec"|undefined} _spellCorrectionSpec + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + */ + Object.defineProperty(SearchRequest.prototype, "_spellCorrectionSpec", { + get: $util.oneOfGetter($oneOfFields = ["spellCorrectionSpec"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new SearchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISearchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest} SearchRequest instance + */ + SearchRequest.create = function create(properties) { + return new SearchRequest(properties); + }; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branch); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.query); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.visitorId); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2alpha.UserInfo.encode(message.userInfo, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.pageToken); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.offset); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.orderBy); + if (message.facetSpecs != null && message.facetSpecs.length) + for (var i = 0; i < message.facetSpecs.length; ++i) + $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.encode(message.facetSpecs[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.boostSpec != null && Object.hasOwnProperty.call(message, "boostSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.encode(message.boostSpec, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + if (message.queryExpansionSpec != null && Object.hasOwnProperty.call(message, "queryExpansionSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.encode(message.queryExpansionSpec, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.relevanceThreshold != null && Object.hasOwnProperty.call(message, "relevanceThreshold")) + writer.uint32(/* id 15, wireType 0 =*/120).int32(message.relevanceThreshold); + if (message.variantRollupKeys != null && message.variantRollupKeys.length) + for (var i = 0; i < message.variantRollupKeys.length; ++i) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.variantRollupKeys[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 23, wireType 2 =*/186).string(message.pageCategories[i]); + if (message.canonicalFilter != null && Object.hasOwnProperty.call(message, "canonicalFilter")) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.canonicalFilter); + if (message.searchMode != null && Object.hasOwnProperty.call(message, "searchMode")) + writer.uint32(/* id 31, wireType 0 =*/248).int32(message.searchMode); + if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 32, wireType 2 =*/258).fork()).ldelim(); + 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 34, wireType 2 =*/274).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.spellCorrectionSpec != null && Object.hasOwnProperty.call(message, "spellCorrectionSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.encode(message.spellCorrectionSpec, writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {google.cloud.retail.v2alpha.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.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.cloud.retail.v2alpha.SearchRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.branch = reader.string(); + break; + } + case 3: { + message.query = reader.string(); + break; + } + case 4: { + message.visitorId = reader.string(); + break; + } + case 5: { + message.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.decode(reader, reader.uint32()); + break; + } + case 7: { + message.pageSize = reader.int32(); + break; + } + case 8: { + message.pageToken = reader.string(); + break; + } + case 9: { + message.offset = reader.int32(); + break; + } + case 10: { + message.filter = reader.string(); + break; + } + case 28: { + message.canonicalFilter = reader.string(); + break; + } + case 11: { + message.orderBy = reader.string(); + break; + } + case 12: { + if (!(message.facetSpecs && message.facetSpecs.length)) + message.facetSpecs = []; + message.facetSpecs.push($root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.decode(reader, reader.uint32())); + break; + } + case 21: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 13: { + message.boostSpec = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.decode(reader, reader.uint32()); + break; + } + case 14: { + message.queryExpansionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.decode(reader, reader.uint32()); + break; + } + case 15: { + message.relevanceThreshold = reader.int32(); + break; + } + case 17: { + if (!(message.variantRollupKeys && message.variantRollupKeys.length)) + message.variantRollupKeys = []; + message.variantRollupKeys.push(reader.string()); + break; + } + case 23: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 31: { + message.searchMode = reader.int32(); + break; + } + case 32: { + message.personalizationSpec = $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); + break; + } + case 34: { + 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 35: { + message.spellCorrectionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2alpha.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + 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"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + if (!$util.isString(message.canonicalFilter)) + return "canonicalFilter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.facetSpecs != null && message.hasOwnProperty("facetSpecs")) { + if (!Array.isArray(message.facetSpecs)) + return "facetSpecs: array expected"; + for (var i = 0; i < message.facetSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify(message.facetSpecs[i]); + if (error) + return "facetSpecs." + error; + } + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.verify(message.boostSpec); + if (error) + return "boostSpec." + error; + } + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.verify(message.queryExpansionSpec); + if (error) + return "queryExpansionSpec." + error; + } + if (message.relevanceThreshold != null && message.hasOwnProperty("relevanceThreshold")) + switch (message.relevanceThreshold) { + default: + return "relevanceThreshold: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.variantRollupKeys != null && message.hasOwnProperty("variantRollupKeys")) { + if (!Array.isArray(message.variantRollupKeys)) + return "variantRollupKeys: array expected"; + for (var i = 0; i < message.variantRollupKeys.length; ++i) + if (!$util.isString(message.variantRollupKeys[i])) + return "variantRollupKeys: string[] expected"; + } + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + switch (message.searchMode) { + default: + return "searchMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.verify(message.personalizationSpec); + if (error) + return "personalizationSpec." + error; + } + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + properties._spellCorrectionSpec = 1; + { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.verify(message.spellCorrectionSpec); + if (error) + return "spellCorrectionSpec." + error; + } + } + return null; + }; + + /** + * Creates a SearchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest} SearchRequest + */ + SearchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.branch != null) + message.branch = String(object.branch); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.fromObject(object.userInfo); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.filter != null) + message.filter = String(object.filter); + if (object.canonicalFilter != null) + message.canonicalFilter = String(object.canonicalFilter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.facetSpecs) { + if (!Array.isArray(object.facetSpecs)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.facetSpecs: array expected"); + message.facetSpecs = []; + for (var i = 0; i < object.facetSpecs.length; ++i) { + if (typeof object.facetSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.facetSpecs: object expected"); + message.facetSpecs[i] = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.fromObject(object.facetSpecs[i]); + } + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostSpec != null) { + if (typeof object.boostSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.boostSpec: object expected"); + message.boostSpec = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.fromObject(object.boostSpec); + } + if (object.queryExpansionSpec != null) { + if (typeof object.queryExpansionSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.queryExpansionSpec: object expected"); + message.queryExpansionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.fromObject(object.queryExpansionSpec); + } + switch (object.relevanceThreshold) { + default: + if (typeof object.relevanceThreshold === "number") { + message.relevanceThreshold = object.relevanceThreshold; + break; + } + break; + case "RELEVANCE_THRESHOLD_UNSPECIFIED": + case 0: + message.relevanceThreshold = 0; + break; + case "HIGH": + case 1: + message.relevanceThreshold = 1; + break; + case "MEDIUM": + case 2: + message.relevanceThreshold = 2; + break; + case "LOW": + case 3: + message.relevanceThreshold = 3; + break; + case "LOWEST": + case 4: + message.relevanceThreshold = 4; + break; + } + if (object.variantRollupKeys) { + if (!Array.isArray(object.variantRollupKeys)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.variantRollupKeys: array expected"); + message.variantRollupKeys = []; + for (var i = 0; i < object.variantRollupKeys.length; ++i) + message.variantRollupKeys[i] = String(object.variantRollupKeys[i]); + } + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + switch (object.searchMode) { + default: + if (typeof object.searchMode === "number") { + message.searchMode = object.searchMode; + break; + } + break; + case "SEARCH_MODE_UNSPECIFIED": + case 0: + message.searchMode = 0; + break; + case "PRODUCT_SEARCH_ONLY": + case 1: + message.searchMode = 1; + break; + case "FACETED_SEARCH_ONLY": + case 2: + message.searchMode = 2; + break; + } + if (object.personalizationSpec != null) { + if (typeof object.personalizationSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.personalizationSpec: object expected"); + message.personalizationSpec = $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.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.spellCorrectionSpec != null) { + if (typeof object.spellCorrectionSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.spellCorrectionSpec: object expected"); + message.spellCorrectionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.fromObject(object.spellCorrectionSpec); + } + return message; + }; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest} message SearchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetSpecs = []; + object.variantRollupKeys = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.placement = ""; + object.branch = ""; + object.query = ""; + object.visitorId = ""; + object.userInfo = null; + object.pageSize = 0; + object.pageToken = ""; + object.offset = 0; + object.filter = ""; + object.orderBy = ""; + object.boostSpec = null; + object.queryExpansionSpec = null; + object.relevanceThreshold = options.enums === String ? "RELEVANCE_THRESHOLD_UNSPECIFIED" : 0; + object.dynamicFacetSpec = null; + object.canonicalFilter = ""; + object.searchMode = options.enums === String ? "SEARCH_MODE_UNSPECIFIED" : 0; + object.personalizationSpec = null; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2alpha.UserInfo.toObject(message.userInfo, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.facetSpecs && message.facetSpecs.length) { + object.facetSpecs = []; + for (var j = 0; j < message.facetSpecs.length; ++j) + object.facetSpecs[j] = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.toObject(message.facetSpecs[j], options); + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) + object.boostSpec = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.toObject(message.boostSpec, options); + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) + object.queryExpansionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.toObject(message.queryExpansionSpec, options); + if (message.relevanceThreshold != null && message.hasOwnProperty("relevanceThreshold")) + object.relevanceThreshold = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold[message.relevanceThreshold] === undefined ? message.relevanceThreshold : $root.google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold[message.relevanceThreshold] : message.relevanceThreshold; + if (message.variantRollupKeys && message.variantRollupKeys.length) { + object.variantRollupKeys = []; + for (var j = 0; j < message.variantRollupKeys.length; ++j) + object.variantRollupKeys[j] = message.variantRollupKeys[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + object.canonicalFilter = message.canonicalFilter; + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + object.searchMode = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.SearchMode[message.searchMode] === undefined ? message.searchMode : $root.google.cloud.retail.v2alpha.SearchRequest.SearchMode[message.searchMode] : message.searchMode; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) + object.personalizationSpec = $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + object.spellCorrectionSpec = $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.toObject(message.spellCorrectionSpec, options); + if (options.oneofs) + object._spellCorrectionSpec = "spellCorrectionSpec"; + } + return object; + }; + + /** + * Converts this SearchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @instance + * @returns {Object.} JSON object + */ + SearchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest"; + }; + + SearchRequest.FacetSpec = (function() { + + /** + * Properties of a FacetSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface IFacetSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey|null} [facetKey] FacetSpec facetKey + * @property {number|null} [limit] FacetSpec limit + * @property {Array.|null} [excludedFilterKeys] FacetSpec excludedFilterKeys + * @property {boolean|null} [enableDynamicPosition] FacetSpec enableDynamicPosition + */ + + /** + * Constructs a new FacetSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a FacetSpec. + * @implements IFacetSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec=} [properties] Properties to set + */ + function FacetSpec(properties) { + this.excludedFilterKeys = []; + 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]]; + } + + /** + * FacetSpec facetKey. + * @member {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey|null|undefined} facetKey + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.facetKey = null; + + /** + * FacetSpec limit. + * @member {number} limit + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.limit = 0; + + /** + * FacetSpec excludedFilterKeys. + * @member {Array.} excludedFilterKeys + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.excludedFilterKeys = $util.emptyArray; + + /** + * FacetSpec enableDynamicPosition. + * @member {boolean} enableDynamicPosition + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.enableDynamicPosition = false; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec} FacetSpec instance + */ + FacetSpec.create = function create(properties) { + return new FacetSpec(properties); + }; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.facetKey != null && Object.hasOwnProperty.call(message, "facetKey")) + $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.encode(message.facetKey, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.limit); + if (message.excludedFilterKeys != null && message.excludedFilterKeys.length) + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.excludedFilterKeys[i]); + if (message.enableDynamicPosition != null && Object.hasOwnProperty.call(message, "enableDynamicPosition")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.enableDynamicPosition); + return writer; + }; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.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.cloud.retail.v2alpha.SearchRequest.FacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.facetKey = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.decode(reader, reader.uint32()); + break; + } + case 2: { + message.limit = reader.int32(); + break; + } + case 3: { + if (!(message.excludedFilterKeys && message.excludedFilterKeys.length)) + message.excludedFilterKeys = []; + message.excludedFilterKeys.push(reader.string()); + break; + } + case 4: { + message.enableDynamicPosition = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.facetKey != null && message.hasOwnProperty("facetKey")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.verify(message.facetKey); + if (error) + return "facetKey." + error; + } + if (message.limit != null && message.hasOwnProperty("limit")) + if (!$util.isInteger(message.limit)) + return "limit: integer expected"; + if (message.excludedFilterKeys != null && message.hasOwnProperty("excludedFilterKeys")) { + if (!Array.isArray(message.excludedFilterKeys)) + return "excludedFilterKeys: array expected"; + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + if (!$util.isString(message.excludedFilterKeys[i])) + return "excludedFilterKeys: string[] expected"; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + if (typeof message.enableDynamicPosition !== "boolean") + return "enableDynamicPosition: boolean expected"; + return null; + }; + + /** + * Creates a FacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec} FacetSpec + */ + FacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec(); + if (object.facetKey != null) { + if (typeof object.facetKey !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.facetKey: object expected"); + message.facetKey = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.fromObject(object.facetKey); + } + if (object.limit != null) + message.limit = object.limit | 0; + if (object.excludedFilterKeys) { + if (!Array.isArray(object.excludedFilterKeys)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.excludedFilterKeys: array expected"); + message.excludedFilterKeys = []; + for (var i = 0; i < object.excludedFilterKeys.length; ++i) + message.excludedFilterKeys[i] = String(object.excludedFilterKeys[i]); + } + if (object.enableDynamicPosition != null) + message.enableDynamicPosition = Boolean(object.enableDynamicPosition); + return message; + }; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec} message FacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.excludedFilterKeys = []; + if (options.defaults) { + object.facetKey = null; + object.limit = 0; + object.enableDynamicPosition = false; + } + if (message.facetKey != null && message.hasOwnProperty("facetKey")) + object.facetKey = $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.toObject(message.facetKey, options); + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = message.limit; + if (message.excludedFilterKeys && message.excludedFilterKeys.length) { + object.excludedFilterKeys = []; + for (var j = 0; j < message.excludedFilterKeys.length; ++j) + object.excludedFilterKeys[j] = message.excludedFilterKeys[j]; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + object.enableDynamicPosition = message.enableDynamicPosition; + return object; + }; + + /** + * Converts this FacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @instance + * @returns {Object.} JSON object + */ + FacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.FacetSpec"; + }; + + FacetSpec.FacetKey = (function() { + + /** + * Properties of a FacetKey. + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @interface IFacetKey + * @property {string|null} [key] FacetKey key + * @property {Array.|null} [intervals] FacetKey intervals + * @property {Array.|null} [restrictedValues] FacetKey restrictedValues + * @property {Array.|null} [prefixes] FacetKey prefixes + * @property {Array.|null} [contains] FacetKey contains + * @property {boolean|null} [caseInsensitive] FacetKey caseInsensitive + * @property {string|null} [orderBy] FacetKey orderBy + * @property {string|null} [query] FacetKey query + * @property {boolean|null} [returnMinMax] FacetKey returnMinMax + */ + + /** + * Constructs a new FacetKey. + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec + * @classdesc Represents a FacetKey. + * @implements IFacetKey + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + */ + function FacetKey(properties) { + this.intervals = []; + this.restrictedValues = []; + this.prefixes = []; + this.contains = []; + 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]]; + } + + /** + * FacetKey key. + * @member {string} key + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.key = ""; + + /** + * FacetKey intervals. + * @member {Array.} intervals + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.intervals = $util.emptyArray; + + /** + * FacetKey restrictedValues. + * @member {Array.} restrictedValues + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.restrictedValues = $util.emptyArray; + + /** + * FacetKey prefixes. + * @member {Array.} prefixes + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.prefixes = $util.emptyArray; + + /** + * FacetKey contains. + * @member {Array.} contains + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.contains = $util.emptyArray; + + /** + * FacetKey caseInsensitive. + * @member {boolean} caseInsensitive + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.caseInsensitive = false; + + /** + * FacetKey orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.orderBy = ""; + + /** + * FacetKey query. + * @member {string} query + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.query = ""; + + /** + * FacetKey returnMinMax. + * @member {boolean} returnMinMax + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.returnMinMax = false; + + /** + * Creates a new FacetKey instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey} FacetKey instance + */ + FacetKey.create = function create(properties) { + return new FacetKey(properties); + }; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.intervals != null && message.intervals.length) + for (var i = 0; i < message.intervals.length; ++i) + $root.google.cloud.retail.v2alpha.Interval.encode(message.intervals[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.restrictedValues != null && message.restrictedValues.length) + for (var i = 0; i < message.restrictedValues.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.restrictedValues[i]); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.orderBy); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.query); + if (message.prefixes != null && message.prefixes.length) + for (var i = 0; i < message.prefixes.length; ++i) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.prefixes[i]); + if (message.contains != null && message.contains.length) + for (var i = 0; i < message.contains.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.contains[i]); + if (message.caseInsensitive != null && Object.hasOwnProperty.call(message, "caseInsensitive")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.caseInsensitive); + if (message.returnMinMax != null && Object.hasOwnProperty.call(message, "returnMinMax")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.returnMinMax); + return writer; + }; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.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.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.intervals && message.intervals.length)) + message.intervals = []; + message.intervals.push($root.google.cloud.retail.v2alpha.Interval.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.restrictedValues && message.restrictedValues.length)) + message.restrictedValues = []; + message.restrictedValues.push(reader.string()); + break; + } + case 8: { + if (!(message.prefixes && message.prefixes.length)) + message.prefixes = []; + message.prefixes.push(reader.string()); + break; + } + case 9: { + if (!(message.contains && message.contains.length)) + message.contains = []; + message.contains.push(reader.string()); + break; + } + case 10: { + message.caseInsensitive = reader.bool(); + break; + } + case 4: { + message.orderBy = reader.string(); + break; + } + case 5: { + message.query = reader.string(); + break; + } + case 11: { + message.returnMinMax = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetKey message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.intervals != null && message.hasOwnProperty("intervals")) { + if (!Array.isArray(message.intervals)) + return "intervals: array expected"; + for (var i = 0; i < message.intervals.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Interval.verify(message.intervals[i]); + if (error) + return "intervals." + error; + } + } + if (message.restrictedValues != null && message.hasOwnProperty("restrictedValues")) { + if (!Array.isArray(message.restrictedValues)) + return "restrictedValues: array expected"; + for (var i = 0; i < message.restrictedValues.length; ++i) + if (!$util.isString(message.restrictedValues[i])) + return "restrictedValues: string[] expected"; + } + if (message.prefixes != null && message.hasOwnProperty("prefixes")) { + if (!Array.isArray(message.prefixes)) + return "prefixes: array expected"; + for (var i = 0; i < message.prefixes.length; ++i) + if (!$util.isString(message.prefixes[i])) + return "prefixes: string[] expected"; + } + if (message.contains != null && message.hasOwnProperty("contains")) { + if (!Array.isArray(message.contains)) + return "contains: array expected"; + for (var i = 0; i < message.contains.length; ++i) + if (!$util.isString(message.contains[i])) + return "contains: string[] expected"; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + if (typeof message.caseInsensitive !== "boolean") + return "caseInsensitive: boolean expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + if (typeof message.returnMinMax !== "boolean") + return "returnMinMax: boolean expected"; + return null; + }; + + /** + * Creates a FacetKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey} FacetKey + */ + FacetKey.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey(); + if (object.key != null) + message.key = String(object.key); + if (object.intervals) { + if (!Array.isArray(object.intervals)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals: array expected"); + message.intervals = []; + for (var i = 0; i < object.intervals.length; ++i) { + if (typeof object.intervals[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.intervals: object expected"); + message.intervals[i] = $root.google.cloud.retail.v2alpha.Interval.fromObject(object.intervals[i]); + } + } + if (object.restrictedValues) { + if (!Array.isArray(object.restrictedValues)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.restrictedValues: array expected"); + message.restrictedValues = []; + for (var i = 0; i < object.restrictedValues.length; ++i) + message.restrictedValues[i] = String(object.restrictedValues[i]); + } + if (object.prefixes) { + if (!Array.isArray(object.prefixes)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.prefixes: array expected"); + message.prefixes = []; + for (var i = 0; i < object.prefixes.length; ++i) + message.prefixes[i] = String(object.prefixes[i]); + } + if (object.contains) { + if (!Array.isArray(object.contains)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.contains: array expected"); + message.contains = []; + for (var i = 0; i < object.contains.length; ++i) + message.contains[i] = String(object.contains[i]); + } + if (object.caseInsensitive != null) + message.caseInsensitive = Boolean(object.caseInsensitive); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.query != null) + message.query = String(object.query); + if (object.returnMinMax != null) + message.returnMinMax = Boolean(object.returnMinMax); + return message; + }; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey} message FacetKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.intervals = []; + object.restrictedValues = []; + object.prefixes = []; + object.contains = []; + } + if (options.defaults) { + object.key = ""; + object.orderBy = ""; + object.query = ""; + object.caseInsensitive = false; + object.returnMinMax = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.intervals && message.intervals.length) { + object.intervals = []; + for (var j = 0; j < message.intervals.length; ++j) + object.intervals[j] = $root.google.cloud.retail.v2alpha.Interval.toObject(message.intervals[j], options); + } + if (message.restrictedValues && message.restrictedValues.length) { + object.restrictedValues = []; + for (var j = 0; j < message.restrictedValues.length; ++j) + object.restrictedValues[j] = message.restrictedValues[j]; + } + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.prefixes && message.prefixes.length) { + object.prefixes = []; + for (var j = 0; j < message.prefixes.length; ++j) + object.prefixes[j] = message.prefixes[j]; + } + if (message.contains && message.contains.length) { + object.contains = []; + for (var j = 0; j < message.contains.length; ++j) + object.contains[j] = message.contains[j]; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + object.caseInsensitive = message.caseInsensitive; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + object.returnMinMax = message.returnMinMax; + return object; + }; + + /** + * Converts this FacetKey to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @instance + * @returns {Object.} JSON object + */ + FacetKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetKey + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey"; + }; + + return FacetKey; + })(); + + return FacetSpec; + })(); + + SearchRequest.DynamicFacetSpec = (function() { + + /** + * Properties of a DynamicFacetSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface IDynamicFacetSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode|null} [mode] DynamicFacetSpec mode + */ + + /** + * Constructs a new DynamicFacetSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a DynamicFacetSpec. + * @implements IDynamicFacetSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + */ + function DynamicFacetSpec(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]]; + } + + /** + * DynamicFacetSpec mode. + * @member {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode} mode + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @instance + */ + DynamicFacetSpec.prototype.mode = 0; + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} DynamicFacetSpec instance + */ + DynamicFacetSpec.create = function create(properties) { + return new DynamicFacetSpec(properties); + }; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.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.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DynamicFacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DynamicFacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + */ + DynamicFacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec(); + 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 "DISABLED": + case 1: + message.mode = 1; + break; + case "ENABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} message DynamicFacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DynamicFacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @instance + * @returns {Object.} JSON object + */ + DynamicFacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DynamicFacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DynamicFacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} ENABLED=2 ENABLED value + */ + DynamicFacetSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[2] = "ENABLED"] = 2; + return values; + })(); + + return DynamicFacetSpec; + })(); + + SearchRequest.BoostSpec = (function() { + + /** + * Properties of a BoostSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface IBoostSpec + * @property {Array.|null} [conditionBoostSpecs] BoostSpec conditionBoostSpecs + * @property {boolean|null} [skipBoostSpecValidation] BoostSpec skipBoostSpecValidation + */ + + /** + * Constructs a new BoostSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a BoostSpec. + * @implements IBoostSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec=} [properties] Properties to set + */ + function BoostSpec(properties) { + this.conditionBoostSpecs = []; + 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]]; + } + + /** + * BoostSpec conditionBoostSpecs. + * @member {Array.} conditionBoostSpecs + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.conditionBoostSpecs = $util.emptyArray; + + /** + * BoostSpec skipBoostSpecValidation. + * @member {boolean|null|undefined} skipBoostSpecValidation + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.skipBoostSpecValidation = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BoostSpec _skipBoostSpecValidation. + * @member {"skipBoostSpecValidation"|undefined} _skipBoostSpecValidation + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @instance + */ + Object.defineProperty(BoostSpec.prototype, "_skipBoostSpecValidation", { + get: $util.oneOfGetter($oneOfFields = ["skipBoostSpecValidation"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} BoostSpec instance + */ + BoostSpec.create = function create(properties) { + return new BoostSpec(properties); + }; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.conditionBoostSpecs != null && message.conditionBoostSpecs.length) + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.conditionBoostSpecs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.skipBoostSpecValidation != null && Object.hasOwnProperty.call(message, "skipBoostSpecValidation")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.skipBoostSpecValidation); + return writer; + }; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.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.cloud.retail.v2alpha.SearchRequest.BoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.conditionBoostSpecs && message.conditionBoostSpecs.length)) + message.conditionBoostSpecs = []; + message.conditionBoostSpecs.push($root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + case 2: { + message.skipBoostSpecValidation = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.conditionBoostSpecs != null && message.hasOwnProperty("conditionBoostSpecs")) { + if (!Array.isArray(message.conditionBoostSpecs)) + return "conditionBoostSpecs: array expected"; + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.conditionBoostSpecs[i]); + if (error) + return "conditionBoostSpecs." + error; + } + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + properties._skipBoostSpecValidation = 1; + if (typeof message.skipBoostSpecValidation !== "boolean") + return "skipBoostSpecValidation: boolean expected"; + } + return null; + }; + + /** + * Creates a BoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} BoostSpec + */ + BoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec(); + if (object.conditionBoostSpecs) { + if (!Array.isArray(object.conditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.BoostSpec.conditionBoostSpecs: array expected"); + message.conditionBoostSpecs = []; + for (var i = 0; i < object.conditionBoostSpecs.length; ++i) { + if (typeof object.conditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchRequest.BoostSpec.conditionBoostSpecs: object expected"); + message.conditionBoostSpecs[i] = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.conditionBoostSpecs[i]); + } + } + if (object.skipBoostSpecValidation != null) + message.skipBoostSpecValidation = Boolean(object.skipBoostSpecValidation); + return message; + }; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} message BoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.conditionBoostSpecs = []; + if (message.conditionBoostSpecs && message.conditionBoostSpecs.length) { + object.conditionBoostSpecs = []; + for (var j = 0; j < message.conditionBoostSpecs.length; ++j) + object.conditionBoostSpecs[j] = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.conditionBoostSpecs[j], options); + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + object.skipBoostSpecValidation = message.skipBoostSpecValidation; + if (options.oneofs) + object._skipBoostSpecValidation = "skipBoostSpecValidation"; + } + return object; + }; + + /** + * Converts this BoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @instance + * @returns {Object.} JSON object + */ + BoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.BoostSpec"; + }; + + BoostSpec.ConditionBoostSpec = (function() { + + /** + * Properties of a ConditionBoostSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @interface IConditionBoostSpec + * @property {string|null} [condition] ConditionBoostSpec condition + * @property {number|null} [boost] ConditionBoostSpec boost + */ + + /** + * Constructs a new ConditionBoostSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec + * @classdesc Represents a ConditionBoostSpec. + * @implements IConditionBoostSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + */ + function ConditionBoostSpec(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]]; + } + + /** + * ConditionBoostSpec condition. + * @member {string} condition + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.condition = ""; + + /** + * ConditionBoostSpec boost. + * @member {number} boost + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.boost = 0; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec instance + */ + ConditionBoostSpec.create = function create(properties) { + return new ConditionBoostSpec(properties); + }; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.condition); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.boost); + return writer; + }; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.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.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.string(); + break; + } + case 2: { + message.boost = reader.float(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ConditionBoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ConditionBoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + if (!$util.isString(message.condition)) + return "condition: string expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + return null; + }; + + /** + * Creates a ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + */ + ConditionBoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec(); + if (object.condition != null) + message.condition = String(object.condition); + if (object.boost != null) + message.boost = Number(object.boost); + return message; + }; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec} message ConditionBoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ConditionBoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = ""; + object.boost = 0; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = message.condition; + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + return object; + }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + * @returns {Object.} JSON object + */ + ConditionBoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ConditionBoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ConditionBoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec"; + }; + + return ConditionBoostSpec; + })(); + + return BoostSpec; + })(); + + SearchRequest.QueryExpansionSpec = (function() { + + /** + * Properties of a QueryExpansionSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface IQueryExpansionSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition|null} [condition] QueryExpansionSpec condition + * @property {boolean|null} [pinUnexpandedResults] QueryExpansionSpec pinUnexpandedResults + */ + + /** + * Constructs a new QueryExpansionSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a QueryExpansionSpec. + * @implements IQueryExpansionSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + */ + function QueryExpansionSpec(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]]; + } + + /** + * QueryExpansionSpec condition. + * @member {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition} condition + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.condition = 0; + + /** + * QueryExpansionSpec pinUnexpandedResults. + * @member {boolean} pinUnexpandedResults + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.pinUnexpandedResults = false; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} QueryExpansionSpec instance + */ + QueryExpansionSpec.create = function create(properties) { + return new QueryExpansionSpec(properties); + }; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.condition); + if (message.pinUnexpandedResults != null && Object.hasOwnProperty.call(message, "pinUnexpandedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.pinUnexpandedResults); + return writer; + }; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.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.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.int32(); + break; + } + case 2: { + message.pinUnexpandedResults = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + switch (message.condition) { + default: + return "condition: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + if (typeof message.pinUnexpandedResults !== "boolean") + return "pinUnexpandedResults: boolean expected"; + return null; + }; + + /** + * Creates a QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + */ + QueryExpansionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec(); + switch (object.condition) { + default: + if (typeof object.condition === "number") { + message.condition = object.condition; + break; + } + break; + case "CONDITION_UNSPECIFIED": + case 0: + message.condition = 0; + break; + case "DISABLED": + case 1: + message.condition = 1; + break; + case "AUTO": + case 3: + message.condition = 3; + break; + } + if (object.pinUnexpandedResults != null) + message.pinUnexpandedResults = Boolean(object.pinUnexpandedResults); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} message QueryExpansionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = options.enums === String ? "CONDITION_UNSPECIFIED" : 0; + object.pinUnexpandedResults = false; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition[message.condition] === undefined ? message.condition : $root.google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition[message.condition] : message.condition; + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + object.pinUnexpandedResults = message.pinUnexpandedResults; + return object; + }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec"; + }; + + /** + * Condition enum. + * @name google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec.Condition + * @enum {number} + * @property {number} CONDITION_UNSPECIFIED=0 CONDITION_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} AUTO=3 AUTO value + */ + QueryExpansionSpec.Condition = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CONDITION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[3] = "AUTO"] = 3; + return values; + })(); + + return QueryExpansionSpec; + })(); + + SearchRequest.PersonalizationSpec = (function() { + + /** + * Properties of a PersonalizationSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface IPersonalizationSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode|null} [mode] PersonalizationSpec mode + */ + + /** + * Constructs a new PersonalizationSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a PersonalizationSpec. + * @implements IPersonalizationSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + */ + function PersonalizationSpec(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]]; + } + + /** + * PersonalizationSpec mode. + * @member {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode} mode + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @instance + */ + PersonalizationSpec.prototype.mode = 0; + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} PersonalizationSpec instance + */ + PersonalizationSpec.create = function create(properties) { + return new PersonalizationSpec(properties); + }; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.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.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PersonalizationSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PersonalizationSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} PersonalizationSpec + */ + PersonalizationSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec(); + 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 "AUTO": + case 1: + message.mode = 1; + break; + case "DISABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} message PersonalizationSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PersonalizationSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this PersonalizationSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @instance + * @returns {Object.} JSON object + */ + PersonalizationSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PersonalizationSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PersonalizationSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} AUTO=1 AUTO value + * @property {number} DISABLED=2 DISABLED value + */ + PersonalizationSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "AUTO"] = 1; + values[valuesById[2] = "DISABLED"] = 2; + return values; + })(); + + return PersonalizationSpec; + })(); + + SearchRequest.SpellCorrectionSpec = (function() { + + /** + * Properties of a SpellCorrectionSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @interface ISpellCorrectionSpec + * @property {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode|null} [mode] SpellCorrectionSpec mode + */ + + /** + * Constructs a new SpellCorrectionSpec. + * @memberof google.cloud.retail.v2alpha.SearchRequest + * @classdesc Represents a SpellCorrectionSpec. + * @implements ISpellCorrectionSpec + * @constructor + * @param {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + */ + function SpellCorrectionSpec(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]]; + } + + /** + * SpellCorrectionSpec mode. + * @member {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode} mode + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @instance + */ + SpellCorrectionSpec.prototype.mode = 0; + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec instance + */ + SpellCorrectionSpec.create = function create(properties) { + return new SpellCorrectionSpec(properties); + }; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.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.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpellCorrectionSpec message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpellCorrectionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + */ + SpellCorrectionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec(); + 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 "SUGGESTION_ONLY": + case 1: + message.mode = 1; + break; + case "AUTO": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} message SpellCorrectionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpellCorrectionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @instance + * @returns {Object.} JSON object + */ + SpellCorrectionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpellCorrectionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} SUGGESTION_ONLY=1 SUGGESTION_ONLY value + * @property {number} AUTO=2 AUTO value + */ + SpellCorrectionSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SUGGESTION_ONLY"] = 1; + values[valuesById[2] = "AUTO"] = 2; + return values; + })(); + + return SpellCorrectionSpec; + })(); + + /** + * RelevanceThreshold enum. + * @name google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold + * @enum {number} + * @property {number} RELEVANCE_THRESHOLD_UNSPECIFIED=0 RELEVANCE_THRESHOLD_UNSPECIFIED value + * @property {number} HIGH=1 HIGH value + * @property {number} MEDIUM=2 MEDIUM value + * @property {number} LOW=3 LOW value + * @property {number} LOWEST=4 LOWEST value + */ + SearchRequest.RelevanceThreshold = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RELEVANCE_THRESHOLD_UNSPECIFIED"] = 0; + values[valuesById[1] = "HIGH"] = 1; + values[valuesById[2] = "MEDIUM"] = 2; + values[valuesById[3] = "LOW"] = 3; + values[valuesById[4] = "LOWEST"] = 4; + return values; + })(); + + /** + * SearchMode enum. + * @name google.cloud.retail.v2alpha.SearchRequest.SearchMode + * @enum {number} + * @property {number} SEARCH_MODE_UNSPECIFIED=0 SEARCH_MODE_UNSPECIFIED value + * @property {number} PRODUCT_SEARCH_ONLY=1 PRODUCT_SEARCH_ONLY value + * @property {number} FACETED_SEARCH_ONLY=2 FACETED_SEARCH_ONLY value + */ + SearchRequest.SearchMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_SEARCH_ONLY"] = 1; + values[valuesById[2] = "FACETED_SEARCH_ONLY"] = 2; + return values; + })(); + + return SearchRequest; + })(); + + v2alpha.SearchResponse = (function() { + + /** + * Properties of a SearchResponse. + * @memberof google.cloud.retail.v2alpha + * @interface ISearchResponse + * @property {Array.|null} [results] SearchResponse results + * @property {Array.|null} [facets] SearchResponse facets + * @property {number|null} [totalSize] SearchResponse totalSize + * @property {string|null} [correctedQuery] SearchResponse correctedQuery + * @property {string|null} [attributionToken] SearchResponse attributionToken + * @property {string|null} [nextPageToken] SearchResponse nextPageToken + * @property {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo|null} [queryExpansionInfo] SearchResponse queryExpansionInfo + * @property {string|null} [redirectUri] SearchResponse redirectUri + * @property {Array.|null} [appliedControls] SearchResponse appliedControls + * @property {Array.|null} [invalidConditionBoostSpecs] SearchResponse invalidConditionBoostSpecs + */ + + /** + * Constructs a new SearchResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SearchResponse. + * @implements ISearchResponse + * @constructor + * @param {google.cloud.retail.v2alpha.ISearchResponse=} [properties] Properties to set + */ + function SearchResponse(properties) { + this.results = []; + this.facets = []; + this.appliedControls = []; + this.invalidConditionBoostSpecs = []; + 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]]; + } + + /** + * SearchResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.results = $util.emptyArray; + + /** + * SearchResponse facets. + * @member {Array.} facets + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.facets = $util.emptyArray; + + /** + * SearchResponse totalSize. + * @member {number} totalSize + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.totalSize = 0; + + /** + * SearchResponse correctedQuery. + * @member {string} correctedQuery + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.correctedQuery = ""; + + /** + * SearchResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.attributionToken = ""; + + /** + * SearchResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.nextPageToken = ""; + + /** + * SearchResponse queryExpansionInfo. + * @member {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo|null|undefined} queryExpansionInfo + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.queryExpansionInfo = null; + + /** + * SearchResponse redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.redirectUri = ""; + + /** + * SearchResponse appliedControls. + * @member {Array.} appliedControls + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.appliedControls = $util.emptyArray; + + /** + * SearchResponse invalidConditionBoostSpecs. + * @member {Array.} invalidConditionBoostSpecs + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + */ + SearchResponse.prototype.invalidConditionBoostSpecs = $util.emptyArray; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {google.cloud.retail.v2alpha.ISearchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchResponse} SearchResponse instance + */ + SearchResponse.create = function create(properties) { + return new SearchResponse(properties); + }; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {google.cloud.retail.v2alpha.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.facets != null && message.facets.length) + for (var i = 0; i < message.facets.length; ++i) + $root.google.cloud.retail.v2alpha.SearchResponse.Facet.encode(message.facets[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.totalSize != null && Object.hasOwnProperty.call(message, "totalSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.totalSize); + if (message.correctedQuery != null && Object.hasOwnProperty.call(message, "correctedQuery")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.correctedQuery); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.nextPageToken); + if (message.queryExpansionInfo != null && Object.hasOwnProperty.call(message, "queryExpansionInfo")) + $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.encode(message.queryExpansionInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectUri); + if (message.appliedControls != null && message.appliedControls.length) + for (var i = 0; i < message.appliedControls.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.appliedControls[i]); + if (message.invalidConditionBoostSpecs != null && message.invalidConditionBoostSpecs.length) + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.invalidConditionBoostSpecs[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {google.cloud.retail.v2alpha.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.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.cloud.retail.v2alpha.SearchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2alpha.SearchResponse.SearchResult.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.facets && message.facets.length)) + message.facets = []; + message.facets.push($root.google.cloud.retail.v2alpha.SearchResponse.Facet.decode(reader, reader.uint32())); + break; + } + case 3: { + message.totalSize = reader.int32(); + break; + } + case 4: { + message.correctedQuery = reader.string(); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + message.nextPageToken = reader.string(); + break; + } + case 7: { + message.queryExpansionInfo = $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.decode(reader, reader.uint32()); + break; + } + case 10: { + message.redirectUri = reader.string(); + break; + } + case 12: { + if (!(message.appliedControls && message.appliedControls.length)) + message.appliedControls = []; + message.appliedControls.push(reader.string()); + break; + } + case 14: { + if (!(message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length)) + message.invalidConditionBoostSpecs = []; + message.invalidConditionBoostSpecs.push($root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.facets != null && message.hasOwnProperty("facets")) { + if (!Array.isArray(message.facets)) + return "facets: array expected"; + for (var i = 0; i < message.facets.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.SearchResponse.Facet.verify(message.facets[i]); + if (error) + return "facets." + error; + } + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + if (!$util.isInteger(message.totalSize)) + return "totalSize: integer expected"; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + if (!$util.isString(message.correctedQuery)) + return "correctedQuery: string expected"; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) { + var error = $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.verify(message.queryExpansionInfo); + if (error) + return "queryExpansionInfo." + error; + } + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + if (message.appliedControls != null && message.hasOwnProperty("appliedControls")) { + if (!Array.isArray(message.appliedControls)) + return "appliedControls: array expected"; + for (var i = 0; i < message.appliedControls.length; ++i) + if (!$util.isString(message.appliedControls[i])) + return "appliedControls: string[] expected"; + } + if (message.invalidConditionBoostSpecs != null && message.hasOwnProperty("invalidConditionBoostSpecs")) { + if (!Array.isArray(message.invalidConditionBoostSpecs)) + return "invalidConditionBoostSpecs: array expected"; + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.invalidConditionBoostSpecs[i]); + if (error) + return "invalidConditionBoostSpecs." + error; + } + } + return null; + }; + + /** + * Creates a SearchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchResponse} SearchResponse + */ + SearchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult.fromObject(object.results[i]); + } + } + if (object.facets) { + if (!Array.isArray(object.facets)) + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.facets: array expected"); + message.facets = []; + for (var i = 0; i < object.facets.length; ++i) { + if (typeof object.facets[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.facets: object expected"); + message.facets[i] = $root.google.cloud.retail.v2alpha.SearchResponse.Facet.fromObject(object.facets[i]); + } + } + if (object.totalSize != null) + message.totalSize = object.totalSize | 0; + if (object.correctedQuery != null) + message.correctedQuery = String(object.correctedQuery); + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + if (object.queryExpansionInfo != null) { + if (typeof object.queryExpansionInfo !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.queryExpansionInfo: object expected"); + message.queryExpansionInfo = $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.fromObject(object.queryExpansionInfo); + } + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + if (object.appliedControls) { + if (!Array.isArray(object.appliedControls)) + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.appliedControls: array expected"); + message.appliedControls = []; + for (var i = 0; i < object.appliedControls.length; ++i) + message.appliedControls[i] = String(object.appliedControls[i]); + } + if (object.invalidConditionBoostSpecs) { + if (!Array.isArray(object.invalidConditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.invalidConditionBoostSpecs: array expected"); + message.invalidConditionBoostSpecs = []; + for (var i = 0; i < object.invalidConditionBoostSpecs.length; ++i) { + if (typeof object.invalidConditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.invalidConditionBoostSpecs: object expected"); + message.invalidConditionBoostSpecs[i] = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.invalidConditionBoostSpecs[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse} message SearchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.facets = []; + object.appliedControls = []; + object.invalidConditionBoostSpecs = []; + } + if (options.defaults) { + object.totalSize = 0; + object.correctedQuery = ""; + object.attributionToken = ""; + object.nextPageToken = ""; + object.queryExpansionInfo = null; + object.redirectUri = ""; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult.toObject(message.results[j], options); + } + if (message.facets && message.facets.length) { + object.facets = []; + for (var j = 0; j < message.facets.length; ++j) + object.facets[j] = $root.google.cloud.retail.v2alpha.SearchResponse.Facet.toObject(message.facets[j], options); + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + object.totalSize = message.totalSize; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + object.correctedQuery = message.correctedQuery; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) + object.queryExpansionInfo = $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.toObject(message.queryExpansionInfo, options); + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + if (message.appliedControls && message.appliedControls.length) { + object.appliedControls = []; + for (var j = 0; j < message.appliedControls.length; ++j) + object.appliedControls[j] = message.appliedControls[j]; + } + if (message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length) { + object.invalidConditionBoostSpecs = []; + for (var j = 0; j < message.invalidConditionBoostSpecs.length; ++j) + object.invalidConditionBoostSpecs[j] = $root.google.cloud.retail.v2alpha.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.invalidConditionBoostSpecs[j], options); + } + return object; + }; + + /** + * Converts this SearchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @instance + * @returns {Object.} JSON object + */ + SearchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchResponse"; + }; + + SearchResponse.SearchResult = (function() { + + /** + * Properties of a SearchResult. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @interface ISearchResult + * @property {string|null} [id] SearchResult id + * @property {google.cloud.retail.v2alpha.IProduct|null} [product] SearchResult product + * @property {number|null} [matchingVariantCount] SearchResult matchingVariantCount + * @property {Object.|null} [matchingVariantFields] SearchResult matchingVariantFields + * @property {Object.|null} [variantRollupValues] SearchResult variantRollupValues + */ + + /** + * Constructs a new SearchResult. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @classdesc Represents a SearchResult. + * @implements ISearchResult + * @constructor + * @param {google.cloud.retail.v2alpha.SearchResponse.ISearchResult=} [properties] Properties to set + */ + function SearchResult(properties) { + this.matchingVariantFields = {}; + this.variantRollupValues = {}; + 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]]; + } + + /** + * SearchResult id. + * @member {string} id + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.id = ""; + + /** + * SearchResult product. + * @member {google.cloud.retail.v2alpha.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.product = null; + + /** + * SearchResult matchingVariantCount. + * @member {number} matchingVariantCount + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantCount = 0; + + /** + * SearchResult matchingVariantFields. + * @member {Object.} matchingVariantFields + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantFields = $util.emptyObject; + + /** + * SearchResult variantRollupValues. + * @member {Object.} variantRollupValues + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.variantRollupValues = $util.emptyObject; + + /** + * Creates a new SearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.ISearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchResponse.SearchResult} SearchResult instance + */ + SearchResult.create = function create(properties) { + return new SearchResult(properties); + }; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2alpha.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.matchingVariantCount != null && Object.hasOwnProperty.call(message, "matchingVariantCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.matchingVariantCount); + if (message.matchingVariantFields != null && Object.hasOwnProperty.call(message, "matchingVariantFields")) + for (var keys = Object.keys(message.matchingVariantFields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.FieldMask.encode(message.matchingVariantFields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.variantRollupValues != null && Object.hasOwnProperty.call(message, "variantRollupValues")) + for (var keys = Object.keys(message.variantRollupValues), 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.protobuf.Value.encode(message.variantRollupValues[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.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.cloud.retail.v2alpha.SearchResponse.SearchResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.matchingVariantCount = reader.int32(); + break; + } + case 4: { + if (message.matchingVariantFields === $util.emptyObject) + message.matchingVariantFields = {}; + 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.FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.matchingVariantFields[key] = value; + break; + } + case 5: { + if (message.variantRollupValues === $util.emptyObject) + message.variantRollupValues = {}; + 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.variantRollupValues[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + if (!$util.isInteger(message.matchingVariantCount)) + return "matchingVariantCount: integer expected"; + if (message.matchingVariantFields != null && message.hasOwnProperty("matchingVariantFields")) { + if (!$util.isObject(message.matchingVariantFields)) + return "matchingVariantFields: object expected"; + var key = Object.keys(message.matchingVariantFields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.FieldMask.verify(message.matchingVariantFields[key[i]]); + if (error) + return "matchingVariantFields." + error; + } + } + if (message.variantRollupValues != null && message.hasOwnProperty("variantRollupValues")) { + if (!$util.isObject(message.variantRollupValues)) + return "variantRollupValues: object expected"; + var key = Object.keys(message.variantRollupValues); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.variantRollupValues[key[i]]); + if (error) + return "variantRollupValues." + error; + } + } + return null; + }; + + /** + * Creates a SearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchResponse.SearchResult} SearchResult + */ + SearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchResponse.SearchResult(); + if (object.id != null) + message.id = String(object.id); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.SearchResult.product: object expected"); + message.product = $root.google.cloud.retail.v2alpha.Product.fromObject(object.product); + } + if (object.matchingVariantCount != null) + message.matchingVariantCount = object.matchingVariantCount | 0; + if (object.matchingVariantFields) { + if (typeof object.matchingVariantFields !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields = {}; + for (var keys = Object.keys(object.matchingVariantFields), i = 0; i < keys.length; ++i) { + if (typeof object.matchingVariantFields[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields[keys[i]] = $root.google.protobuf.FieldMask.fromObject(object.matchingVariantFields[keys[i]]); + } + } + if (object.variantRollupValues) { + if (typeof object.variantRollupValues !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues = {}; + for (var keys = Object.keys(object.variantRollupValues), i = 0; i < keys.length; ++i) { + if (typeof object.variantRollupValues[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues[keys[i]] = $root.google.protobuf.Value.fromObject(object.variantRollupValues[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.SearchResult} message SearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.matchingVariantFields = {}; + object.variantRollupValues = {}; + } + if (options.defaults) { + object.id = ""; + object.product = null; + object.matchingVariantCount = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2alpha.Product.toObject(message.product, options); + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + object.matchingVariantCount = message.matchingVariantCount; + var keys2; + if (message.matchingVariantFields && (keys2 = Object.keys(message.matchingVariantFields)).length) { + object.matchingVariantFields = {}; + for (var j = 0; j < keys2.length; ++j) + object.matchingVariantFields[keys2[j]] = $root.google.protobuf.FieldMask.toObject(message.matchingVariantFields[keys2[j]], options); + } + if (message.variantRollupValues && (keys2 = Object.keys(message.variantRollupValues)).length) { + object.variantRollupValues = {}; + for (var j = 0; j < keys2.length; ++j) + object.variantRollupValues[keys2[j]] = $root.google.protobuf.Value.toObject(message.variantRollupValues[keys2[j]], options); + } + return object; + }; + + /** + * Converts this SearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @instance + * @returns {Object.} JSON object + */ + SearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchResponse.SearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchResponse.SearchResult"; + }; + + return SearchResult; + })(); + + SearchResponse.Facet = (function() { + + /** + * Properties of a Facet. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @interface IFacet + * @property {string|null} [key] Facet key + * @property {Array.|null} [values] Facet values + * @property {boolean|null} [dynamicFacet] Facet dynamicFacet + */ + + /** + * Constructs a new Facet. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @classdesc Represents a Facet. + * @implements IFacet + * @constructor + * @param {google.cloud.retail.v2alpha.SearchResponse.IFacet=} [properties] Properties to set + */ + function Facet(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]]; + } + + /** + * Facet key. + * @member {string} key + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @instance + */ + Facet.prototype.key = ""; + + /** + * Facet values. + * @member {Array.} values + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @instance + */ + Facet.prototype.values = $util.emptyArray; + + /** + * Facet dynamicFacet. + * @member {boolean} dynamicFacet + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @instance + */ + Facet.prototype.dynamicFacet = false; + + /** + * Creates a new Facet instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IFacet=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet} Facet instance + */ + Facet.create = function create(properties) { + return new Facet(properties); + }; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.encode(message.values[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.dynamicFacet != null && Object.hasOwnProperty.call(message, "dynamicFacet")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.dynamicFacet); + return writer; + }; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.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.cloud.retail.v2alpha.SearchResponse.Facet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.decode(reader, reader.uint32())); + break; + } + case 3: { + message.dynamicFacet = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Facet message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Facet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string 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.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.verify(message.values[i]); + if (error) + return "values." + error; + } + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + if (typeof message.dynamicFacet !== "boolean") + return "dynamicFacet: boolean expected"; + return null; + }; + + /** + * Creates a Facet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet} Facet + */ + Facet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchResponse.Facet) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchResponse.Facet(); + if (object.key != null) + message.key = String(object.key); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.Facet.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.Facet.values: object expected"); + message.values[i] = $root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.fromObject(object.values[i]); + } + } + if (object.dynamicFacet != null) + message.dynamicFacet = Boolean(object.dynamicFacet); + return message; + }; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet} message Facet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Facet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (options.defaults) { + object.key = ""; + object.dynamicFacet = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.toObject(message.values[j], options); + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + object.dynamicFacet = message.dynamicFacet; + return object; + }; + + /** + * Converts this Facet to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @instance + * @returns {Object.} JSON object + */ + Facet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Facet + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Facet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchResponse.Facet"; + }; + + Facet.FacetValue = (function() { + + /** + * Properties of a FacetValue. + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @interface IFacetValue + * @property {string|null} [value] FacetValue value + * @property {google.cloud.retail.v2alpha.IInterval|null} [interval] FacetValue interval + * @property {number|Long|null} [count] FacetValue count + * @property {number|null} [minValue] FacetValue minValue + * @property {number|null} [maxValue] FacetValue maxValue + */ + + /** + * Constructs a new FacetValue. + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet + * @classdesc Represents a FacetValue. + * @implements IFacetValue + * @constructor + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + */ + function FacetValue(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]]; + } + + /** + * FacetValue value. + * @member {string|null|undefined} value + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.value = null; + + /** + * FacetValue interval. + * @member {google.cloud.retail.v2alpha.IInterval|null|undefined} interval + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.interval = null; + + /** + * FacetValue count. + * @member {number|Long} count + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.count = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * FacetValue minValue. + * @member {number} minValue + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.minValue = 0; + + /** + * FacetValue maxValue. + * @member {number} maxValue + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.maxValue = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FacetValue facetValue. + * @member {"value"|"interval"|undefined} facetValue + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + */ + Object.defineProperty(FacetValue.prototype, "facetValue", { + get: $util.oneOfGetter($oneOfFields = ["value", "interval"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new FacetValue instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue} FacetValue instance + */ + FacetValue.create = function create(properties) { + return new FacetValue(properties); + }; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.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); + if (message.interval != null && Object.hasOwnProperty.call(message, "interval")) + $root.google.cloud.retail.v2alpha.Interval.encode(message.interval, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.count); + if (message.minValue != null && Object.hasOwnProperty.call(message, "minValue")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.minValue); + if (message.maxValue != null && Object.hasOwnProperty.call(message, "maxValue")) + writer.uint32(/* id 6, wireType 1 =*/49).double(message.maxValue); + return writer; + }; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.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.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.interval = $root.google.cloud.retail.v2alpha.Interval.decode(reader, reader.uint32()); + break; + } + case 3: { + message.count = reader.int64(); + break; + } + case 5: { + message.minValue = reader.double(); + break; + } + case 6: { + message.maxValue = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetValue message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.value != null && message.hasOwnProperty("value")) { + properties.facetValue = 1; + if (!$util.isString(message.value)) + return "value: string expected"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + if (properties.facetValue === 1) + return "facetValue: multiple values"; + properties.facetValue = 1; + { + var error = $root.google.cloud.retail.v2alpha.Interval.verify(message.interval); + if (error) + return "interval." + error; + } + } + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count) && !(message.count && $util.isInteger(message.count.low) && $util.isInteger(message.count.high))) + return "count: integer|Long expected"; + if (message.minValue != null && message.hasOwnProperty("minValue")) + if (typeof message.minValue !== "number") + return "minValue: number expected"; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + if (typeof message.maxValue !== "number") + return "maxValue: number expected"; + return null; + }; + + /** + * Creates a FacetValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue} FacetValue + */ + FacetValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue(); + if (object.value != null) + message.value = String(object.value); + if (object.interval != null) { + if (typeof object.interval !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval: object expected"); + message.interval = $root.google.cloud.retail.v2alpha.Interval.fromObject(object.interval); + } + if (object.count != null) + if ($util.Long) + (message.count = $util.Long.fromValue(object.count)).unsigned = false; + else if (typeof object.count === "string") + message.count = parseInt(object.count, 10); + else if (typeof object.count === "number") + message.count = object.count; + else if (typeof object.count === "object") + message.count = new $util.LongBits(object.count.low >>> 0, object.count.high >>> 0).toNumber(); + if (object.minValue != null) + message.minValue = Number(object.minValue); + if (object.maxValue != null) + message.maxValue = Number(object.maxValue); + return message; + }; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue} message FacetValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetValue.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.count = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.count = options.longs === String ? "0" : 0; + object.minValue = 0; + object.maxValue = 0; + } + if (message.value != null && message.hasOwnProperty("value")) { + object.value = message.value; + if (options.oneofs) + object.facetValue = "value"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + object.interval = $root.google.cloud.retail.v2alpha.Interval.toObject(message.interval, options); + if (options.oneofs) + object.facetValue = "interval"; + } + if (message.count != null && message.hasOwnProperty("count")) + if (typeof message.count === "number") + object.count = options.longs === String ? String(message.count) : message.count; + else + object.count = options.longs === String ? $util.Long.prototype.toString.call(message.count) : options.longs === Number ? new $util.LongBits(message.count.low >>> 0, message.count.high >>> 0).toNumber() : message.count; + if (message.minValue != null && message.hasOwnProperty("minValue")) + object.minValue = options.json && !isFinite(message.minValue) ? String(message.minValue) : message.minValue; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + object.maxValue = options.json && !isFinite(message.maxValue) ? String(message.maxValue) : message.maxValue; + return object; + }; + + /** + * Converts this FacetValue to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @instance + * @returns {Object.} JSON object + */ + FacetValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetValue + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue"; + }; + + return FacetValue; + })(); + + return Facet; + })(); + + SearchResponse.QueryExpansionInfo = (function() { + + /** + * Properties of a QueryExpansionInfo. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @interface IQueryExpansionInfo + * @property {boolean|null} [expandedQuery] QueryExpansionInfo expandedQuery + * @property {number|Long|null} [pinnedResultCount] QueryExpansionInfo pinnedResultCount + */ + + /** + * Constructs a new QueryExpansionInfo. + * @memberof google.cloud.retail.v2alpha.SearchResponse + * @classdesc Represents a QueryExpansionInfo. + * @implements IQueryExpansionInfo + * @constructor + * @param {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + */ + function QueryExpansionInfo(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]]; + } + + /** + * QueryExpansionInfo expandedQuery. + * @member {boolean} expandedQuery + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.expandedQuery = false; + + /** + * QueryExpansionInfo pinnedResultCount. + * @member {number|Long} pinnedResultCount + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.pinnedResultCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo} QueryExpansionInfo instance + */ + QueryExpansionInfo.create = function create(properties) { + return new QueryExpansionInfo(properties); + }; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.expandedQuery != null && Object.hasOwnProperty.call(message, "expandedQuery")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.expandedQuery); + if (message.pinnedResultCount != null && Object.hasOwnProperty.call(message, "pinnedResultCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.pinnedResultCount); + return writer; + }; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.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.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.expandedQuery = reader.bool(); + break; + } + case 2: { + message.pinnedResultCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionInfo message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + if (typeof message.expandedQuery !== "boolean") + return "expandedQuery: boolean expected"; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (!$util.isInteger(message.pinnedResultCount) && !(message.pinnedResultCount && $util.isInteger(message.pinnedResultCount.low) && $util.isInteger(message.pinnedResultCount.high))) + return "pinnedResultCount: integer|Long expected"; + return null; + }; + + /** + * Creates a QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + */ + QueryExpansionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo) + return object; + var message = new $root.google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo(); + if (object.expandedQuery != null) + message.expandedQuery = Boolean(object.expandedQuery); + if (object.pinnedResultCount != null) + if ($util.Long) + (message.pinnedResultCount = $util.Long.fromValue(object.pinnedResultCount)).unsigned = false; + else if (typeof object.pinnedResultCount === "string") + message.pinnedResultCount = parseInt(object.pinnedResultCount, 10); + else if (typeof object.pinnedResultCount === "number") + message.pinnedResultCount = object.pinnedResultCount; + else if (typeof object.pinnedResultCount === "object") + message.pinnedResultCount = new $util.LongBits(object.pinnedResultCount.low >>> 0, object.pinnedResultCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo} message QueryExpansionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.expandedQuery = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.pinnedResultCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.pinnedResultCount = options.longs === String ? "0" : 0; + } + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + object.expandedQuery = message.expandedQuery; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (typeof message.pinnedResultCount === "number") + object.pinnedResultCount = options.longs === String ? String(message.pinnedResultCount) : message.pinnedResultCount; + else + object.pinnedResultCount = options.longs === String ? $util.Long.prototype.toString.call(message.pinnedResultCount) : options.longs === Number ? new $util.LongBits(message.pinnedResultCount.low >>> 0, message.pinnedResultCount.high >>> 0).toNumber() : message.pinnedResultCount; + return object; + }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SearchResponse.QueryExpansionInfo"; + }; + + return QueryExpansionInfo; + })(); + + return SearchResponse; + })(); + + v2alpha.ControlService = (function() { + + /** + * Constructs a new ControlService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ControlService + * @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 ControlService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ControlService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ControlService; + + /** + * Creates new ControlService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.ControlService + * @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 {ControlService} RPC service. Useful where requests and/or responses are streamed. + */ + ControlService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|createControl}. + * @memberof google.cloud.retail.v2alpha.ControlService + * @typedef CreateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Control} [response] Control + */ + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateControlRequest} request CreateControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ControlService.CreateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.createControl = function createControl(request, callback) { + return this.rpcCall(createControl, $root.google.cloud.retail.v2alpha.CreateControlRequest, $root.google.cloud.retail.v2alpha.Control, request, callback); + }, "name", { value: "CreateControl" }); + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateControlRequest} request CreateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|deleteControl}. + * @memberof google.cloud.retail.v2alpha.ControlService + * @typedef DeleteControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ControlService.DeleteControlCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.deleteControl = function deleteControl(request, callback) { + return this.rpcCall(deleteControl, $root.google.cloud.retail.v2alpha.DeleteControlRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteControl" }); + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|updateControl}. + * @memberof google.cloud.retail.v2alpha.ControlService + * @typedef UpdateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Control} [response] Control + */ + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ControlService.UpdateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.updateControl = function updateControl(request, callback) { + return this.rpcCall(updateControl, $root.google.cloud.retail.v2alpha.UpdateControlRequest, $root.google.cloud.retail.v2alpha.Control, request, callback); + }, "name", { value: "UpdateControl" }); + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|getControl}. + * @memberof google.cloud.retail.v2alpha.ControlService + * @typedef GetControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Control} [response] Control + */ + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IGetControlRequest} request GetControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ControlService.GetControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.getControl = function getControl(request, callback) { + return this.rpcCall(getControl, $root.google.cloud.retail.v2alpha.GetControlRequest, $root.google.cloud.retail.v2alpha.Control, request, callback); + }, "name", { value: "GetControl" }); + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IGetControlRequest} request GetControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ControlService|listControls}. + * @memberof google.cloud.retail.v2alpha.ControlService + * @typedef ListControlsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ListControlsResponse} [response] ListControlsResponse + */ + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IListControlsRequest} request ListControlsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ControlService.ListControlsCallback} callback Node-style callback called with the error, if any, and ListControlsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.listControls = function listControls(request, callback) { + return this.rpcCall(listControls, $root.google.cloud.retail.v2alpha.ListControlsRequest, $root.google.cloud.retail.v2alpha.ListControlsResponse, request, callback); + }, "name", { value: "ListControls" }); + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2alpha.ControlService + * @instance + * @param {google.cloud.retail.v2alpha.IListControlsRequest} request ListControlsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ControlService; + })(); + + v2alpha.CreateControlRequest = (function() { + + /** + * Properties of a CreateControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICreateControlRequest + * @property {string|null} [parent] CreateControlRequest parent + * @property {google.cloud.retail.v2alpha.IControl|null} [control] CreateControlRequest control + * @property {string|null} [controlId] CreateControlRequest controlId + */ + + /** + * Constructs a new CreateControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CreateControlRequest. + * @implements ICreateControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICreateControlRequest=} [properties] Properties to set + */ + function CreateControlRequest(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]]; + } + + /** + * CreateControlRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.parent = ""; + + /** + * CreateControlRequest control. + * @member {google.cloud.retail.v2alpha.IControl|null|undefined} control + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.control = null; + + /** + * CreateControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.controlId = ""; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CreateControlRequest} CreateControlRequest instance + */ + CreateControlRequest.create = function create(properties) { + return new CreateControlRequest(properties); + }; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2alpha.Control.encode(message.control, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.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.cloud.retail.v2alpha.CreateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.control = $root.google.cloud.retail.v2alpha.Control.decode(reader, reader.uint32()); + break; + } + case 3: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2alpha.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CreateControlRequest} CreateControlRequest + */ + CreateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CreateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CreateControlRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CreateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2alpha.Control.fromObject(object.control); + } + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.CreateControlRequest} message CreateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.control = null; + object.controlId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2alpha.Control.toObject(message.control, options); + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this CreateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @instance + * @returns {Object.} JSON object + */ + CreateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CreateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CreateControlRequest"; + }; + + return CreateControlRequest; + })(); + + v2alpha.UpdateControlRequest = (function() { + + /** + * Properties of an UpdateControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateControlRequest + * @property {google.cloud.retail.v2alpha.IControl|null} [control] UpdateControlRequest control + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateControlRequest updateMask + */ + + /** + * Constructs a new UpdateControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateControlRequest. + * @implements IUpdateControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest=} [properties] Properties to set + */ + function UpdateControlRequest(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]]; + } + + /** + * UpdateControlRequest control. + * @member {google.cloud.retail.v2alpha.IControl|null|undefined} control + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.control = null; + + /** + * UpdateControlRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateControlRequest} UpdateControlRequest instance + */ + UpdateControlRequest.create = function create(properties) { + return new UpdateControlRequest(properties); + }; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2alpha.Control.encode(message.control, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.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.cloud.retail.v2alpha.UpdateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.control = $root.google.cloud.retail.v2alpha.Control.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2alpha.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateControlRequest} UpdateControlRequest + */ + UpdateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateControlRequest(); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2alpha.Control.fromObject(object.control); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateControlRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateControlRequest} message UpdateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.control = null; + object.updateMask = null; + } + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2alpha.Control.toObject(message.control, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateControlRequest"; + }; + + return UpdateControlRequest; + })(); + + v2alpha.DeleteControlRequest = (function() { + + /** + * Properties of a DeleteControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IDeleteControlRequest + * @property {string|null} [name] DeleteControlRequest name + */ + + /** + * Constructs a new DeleteControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a DeleteControlRequest. + * @implements IDeleteControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest=} [properties] Properties to set + */ + function DeleteControlRequest(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]]; + } + + /** + * DeleteControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @instance + */ + DeleteControlRequest.prototype.name = ""; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.DeleteControlRequest} DeleteControlRequest instance + */ + DeleteControlRequest.create = function create(properties) { + return new DeleteControlRequest(properties); + }; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.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 DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.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.cloud.retail.v2alpha.DeleteControlRequest(); + 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 DeleteControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteControlRequest.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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.DeleteControlRequest} DeleteControlRequest + */ + DeleteControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.DeleteControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.DeleteControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2alpha.DeleteControlRequest} message DeleteControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteControlRequest.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 DeleteControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.DeleteControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.DeleteControlRequest"; + }; + + return DeleteControlRequest; + })(); + + v2alpha.GetControlRequest = (function() { + + /** + * Properties of a GetControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetControlRequest + * @property {string|null} [name] GetControlRequest name + */ + + /** + * Constructs a new GetControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetControlRequest. + * @implements IGetControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetControlRequest=} [properties] Properties to set + */ + function GetControlRequest(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]]; + } + + /** + * GetControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @instance + */ + GetControlRequest.prototype.name = ""; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetControlRequest} GetControlRequest instance + */ + GetControlRequest.create = function create(properties) { + return new GetControlRequest(properties); + }; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.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 GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.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.cloud.retail.v2alpha.GetControlRequest(); + 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 GetControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetControlRequest.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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetControlRequest} GetControlRequest + */ + GetControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {google.cloud.retail.v2alpha.GetControlRequest} message GetControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetControlRequest.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 GetControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @instance + * @returns {Object.} JSON object + */ + GetControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetControlRequest"; + }; + + return GetControlRequest; + })(); + + v2alpha.ListControlsRequest = (function() { + + /** + * Properties of a ListControlsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IListControlsRequest + * @property {string|null} [parent] ListControlsRequest parent + * @property {number|null} [pageSize] ListControlsRequest pageSize + * @property {string|null} [pageToken] ListControlsRequest pageToken + * @property {string|null} [filter] ListControlsRequest filter + */ + + /** + * Constructs a new ListControlsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListControlsRequest. + * @implements IListControlsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IListControlsRequest=} [properties] Properties to set + */ + function ListControlsRequest(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]]; + } + + /** + * ListControlsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.parent = ""; + + /** + * ListControlsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageSize = 0; + + /** + * ListControlsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageToken = ""; + + /** + * ListControlsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.filter = ""; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListControlsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListControlsRequest} ListControlsRequest instance + */ + ListControlsRequest.create = function create(properties) { + return new ListControlsRequest(properties); + }; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + return writer; + }; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.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.cloud.retail.v2alpha.ListControlsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListControlsRequest} ListControlsRequest + */ + ListControlsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListControlsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListControlsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {google.cloud.retail.v2alpha.ListControlsRequest} message ListControlsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this ListControlsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @instance + * @returns {Object.} JSON object + */ + ListControlsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListControlsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListControlsRequest"; + }; + + return ListControlsRequest; + })(); + + v2alpha.ListControlsResponse = (function() { + + /** + * Properties of a ListControlsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IListControlsResponse + * @property {Array.|null} [controls] ListControlsResponse controls + * @property {string|null} [nextPageToken] ListControlsResponse nextPageToken + */ + + /** + * Constructs a new ListControlsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListControlsResponse. + * @implements IListControlsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IListControlsResponse=} [properties] Properties to set + */ + function ListControlsResponse(properties) { + this.controls = []; + 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]]; + } + + /** + * ListControlsResponse controls. + * @member {Array.} controls + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.controls = $util.emptyArray; + + /** + * ListControlsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListControlsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListControlsResponse} ListControlsResponse instance + */ + ListControlsResponse.create = function create(properties) { + return new ListControlsResponse(properties); + }; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.controls != null && message.controls.length) + for (var i = 0; i < message.controls.length; ++i) + $root.google.cloud.retail.v2alpha.Control.encode(message.controls[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 ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListControlsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.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.cloud.retail.v2alpha.ListControlsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.controls && message.controls.length)) + message.controls = []; + message.controls.push($root.google.cloud.retail.v2alpha.Control.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.controls != null && message.hasOwnProperty("controls")) { + if (!Array.isArray(message.controls)) + return "controls: array expected"; + for (var i = 0; i < message.controls.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Control.verify(message.controls[i]); + if (error) + return "controls." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListControlsResponse} ListControlsResponse + */ + ListControlsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListControlsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListControlsResponse(); + if (object.controls) { + if (!Array.isArray(object.controls)) + throw TypeError(".google.cloud.retail.v2alpha.ListControlsResponse.controls: array expected"); + message.controls = []; + for (var i = 0; i < object.controls.length; ++i) { + if (typeof object.controls[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListControlsResponse.controls: object expected"); + message.controls[i] = $root.google.cloud.retail.v2alpha.Control.fromObject(object.controls[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {google.cloud.retail.v2alpha.ListControlsResponse} message ListControlsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.controls = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.controls && message.controls.length) { + object.controls = []; + for (var j = 0; j < message.controls.length; ++j) + object.controls[j] = $root.google.cloud.retail.v2alpha.Control.toObject(message.controls[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListControlsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @instance + * @returns {Object.} JSON object + */ + ListControlsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListControlsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListControlsResponse"; + }; + + return ListControlsResponse; + })(); + + v2alpha.ExportErrorsConfig = (function() { + + /** + * Properties of an ExportErrorsConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IExportErrorsConfig + * @property {string|null} [gcsPrefix] ExportErrorsConfig gcsPrefix + */ + + /** + * Constructs a new ExportErrorsConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ExportErrorsConfig. + * @implements IExportErrorsConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IExportErrorsConfig=} [properties] Properties to set + */ + function ExportErrorsConfig(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]]; + } + + /** + * ExportErrorsConfig gcsPrefix. + * @member {string|null|undefined} gcsPrefix + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @instance + */ + ExportErrorsConfig.prototype.gcsPrefix = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ExportErrorsConfig destination. + * @member {"gcsPrefix"|undefined} destination + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @instance + */ + Object.defineProperty(ExportErrorsConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsPrefix"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ExportErrorsConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IExportErrorsConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ExportErrorsConfig} ExportErrorsConfig instance + */ + ExportErrorsConfig.create = function create(properties) { + return new ExportErrorsConfig(properties); + }; + + /** + * Encodes the specified ExportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportErrorsConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IExportErrorsConfig} message ExportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportErrorsConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsPrefix != null && Object.hasOwnProperty.call(message, "gcsPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsPrefix); + return writer; + }; + + /** + * Encodes the specified ExportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportErrorsConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.IExportErrorsConfig} message ExportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportErrorsConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ExportErrorsConfig} ExportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportErrorsConfig.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.cloud.retail.v2alpha.ExportErrorsConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ExportErrorsConfig} ExportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportErrorsConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportErrorsConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportErrorsConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + properties.destination = 1; + if (!$util.isString(message.gcsPrefix)) + return "gcsPrefix: string expected"; + } + return null; + }; + + /** + * Creates an ExportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ExportErrorsConfig} ExportErrorsConfig + */ + ExportErrorsConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ExportErrorsConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.ExportErrorsConfig(); + if (object.gcsPrefix != null) + message.gcsPrefix = String(object.gcsPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportErrorsConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2alpha.ExportErrorsConfig} message ExportErrorsConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportErrorsConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + object.gcsPrefix = message.gcsPrefix; + if (options.oneofs) + object.destination = "gcsPrefix"; + } + return object; + }; + + /** + * Converts this ExportErrorsConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @instance + * @returns {Object.} JSON object + */ + ExportErrorsConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportErrorsConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ExportErrorsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportErrorsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ExportErrorsConfig"; + }; + + return ExportErrorsConfig; + })(); + + v2alpha.ExportMetadata = (function() { + + /** + * Properties of an ExportMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IExportMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] ExportMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ExportMetadata updateTime + */ + + /** + * Constructs a new ExportMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ExportMetadata. + * @implements IExportMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IExportMetadata=} [properties] Properties to set + */ + function ExportMetadata(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]]; + } + + /** + * ExportMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @instance + */ + ExportMetadata.prototype.createTime = null; + + /** + * ExportMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @instance + */ + ExportMetadata.prototype.updateTime = null; + + /** + * Creates a new ExportMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IExportMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ExportMetadata} ExportMetadata instance + */ + ExportMetadata.create = function create(properties) { + return new ExportMetadata(properties); + }; + + /** + * Encodes the specified ExportMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IExportMetadata} message ExportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {google.cloud.retail.v2alpha.IExportMetadata} message ExportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ExportMetadata} ExportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportMetadata.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.cloud.retail.v2alpha.ExportMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ExportMetadata} ExportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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; + } + return null; + }; + + /** + * Creates an ExportMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ExportMetadata} ExportMetadata + */ + ExportMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ExportMetadata) + return object; + var message = new $root.google.cloud.retail.v2alpha.ExportMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from an ExportMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {google.cloud.retail.v2alpha.ExportMetadata} message ExportMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + return object; + }; + + /** + * Converts this ExportMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @instance + * @returns {Object.} JSON object + */ + ExportMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ExportMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ExportMetadata"; + }; + + return ExportMetadata; + })(); + + v2alpha.ExportProductsResponse = (function() { + + /** + * Properties of an ExportProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IExportProductsResponse + * @property {Array.|null} [errorSamples] ExportProductsResponse errorSamples + * @property {google.cloud.retail.v2alpha.IExportErrorsConfig|null} [errorsConfig] ExportProductsResponse errorsConfig + * @property {google.cloud.retail.v2alpha.IOutputResult|null} [outputResult] ExportProductsResponse outputResult + */ + + /** + * Constructs a new ExportProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ExportProductsResponse. + * @implements IExportProductsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IExportProductsResponse=} [properties] Properties to set + */ + function ExportProductsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ExportProductsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ExportProductsResponse errorsConfig. + * @member {google.cloud.retail.v2alpha.IExportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.errorsConfig = null; + + /** + * ExportProductsResponse outputResult. + * @member {google.cloud.retail.v2alpha.IOutputResult|null|undefined} outputResult + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.outputResult = null; + + /** + * Creates a new ExportProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ExportProductsResponse} ExportProductsResponse instance + */ + ExportProductsResponse.create = function create(properties) { + return new ExportProductsResponse(properties); + }; + + /** + * Encodes the specified ExportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportProductsResponse} message ExportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ExportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.outputResult != null && Object.hasOwnProperty.call(message, "outputResult")) + $root.google.cloud.retail.v2alpha.OutputResult.encode(message.outputResult, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportProductsResponse} message ExportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ExportProductsResponse} ExportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportProductsResponse.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.cloud.retail.v2alpha.ExportProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ExportProductsResponse} ExportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.outputResult != null && message.hasOwnProperty("outputResult")) { + var error = $root.google.cloud.retail.v2alpha.OutputResult.verify(message.outputResult); + if (error) + return "outputResult." + error; + } + return null; + }; + + /** + * Creates an ExportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ExportProductsResponse} ExportProductsResponse + */ + ExportProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ExportProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ExportProductsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2alpha.ExportProductsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportProductsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportProductsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.outputResult != null) { + if (typeof object.outputResult !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportProductsResponse.outputResult: object expected"); + message.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.fromObject(object.outputResult); + } + return message; + }; + + /** + * Creates a plain object from an ExportProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.ExportProductsResponse} message ExportProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.outputResult = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.toObject(message.errorsConfig, options); + if (message.outputResult != null && message.hasOwnProperty("outputResult")) + object.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.toObject(message.outputResult, options); + return object; + }; + + /** + * Converts this ExportProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ExportProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ExportProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ExportProductsResponse"; + }; + + return ExportProductsResponse; + })(); + + v2alpha.ExportUserEventsResponse = (function() { + + /** + * Properties of an ExportUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IExportUserEventsResponse + * @property {Array.|null} [errorSamples] ExportUserEventsResponse errorSamples + * @property {google.cloud.retail.v2alpha.IExportErrorsConfig|null} [errorsConfig] ExportUserEventsResponse errorsConfig + * @property {google.cloud.retail.v2alpha.IOutputResult|null} [outputResult] ExportUserEventsResponse outputResult + */ + + /** + * Constructs a new ExportUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an ExportUserEventsResponse. + * @implements IExportUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IExportUserEventsResponse=} [properties] Properties to set + */ + function ExportUserEventsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ExportUserEventsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ExportUserEventsResponse errorsConfig. + * @member {google.cloud.retail.v2alpha.IExportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.errorsConfig = null; + + /** + * ExportUserEventsResponse outputResult. + * @member {google.cloud.retail.v2alpha.IOutputResult|null|undefined} outputResult + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.outputResult = null; + + /** + * Creates a new ExportUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ExportUserEventsResponse} ExportUserEventsResponse instance + */ + ExportUserEventsResponse.create = function create(properties) { + return new ExportUserEventsResponse(properties); + }; + + /** + * Encodes the specified ExportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ExportUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportUserEventsResponse} message ExportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2alpha.ExportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.outputResult != null && Object.hasOwnProperty.call(message, "outputResult")) + $root.google.cloud.retail.v2alpha.OutputResult.encode(message.outputResult, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ExportUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IExportUserEventsResponse} message ExportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ExportUserEventsResponse} ExportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportUserEventsResponse.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.cloud.retail.v2alpha.ExportUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ExportUserEventsResponse} ExportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.outputResult != null && message.hasOwnProperty("outputResult")) { + var error = $root.google.cloud.retail.v2alpha.OutputResult.verify(message.outputResult); + if (error) + return "outputResult." + error; + } + return null; + }; + + /** + * Creates an ExportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ExportUserEventsResponse} ExportUserEventsResponse + */ + ExportUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ExportUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ExportUserEventsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2alpha.ExportUserEventsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportUserEventsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportUserEventsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.outputResult != null) { + if (typeof object.outputResult !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ExportUserEventsResponse.outputResult: object expected"); + message.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.fromObject(object.outputResult); + } + return message; + }; + + /** + * Creates a plain object from an ExportUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.ExportUserEventsResponse} message ExportUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportUserEventsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.outputResult = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2alpha.ExportErrorsConfig.toObject(message.errorsConfig, options); + if (message.outputResult != null && message.hasOwnProperty("outputResult")) + object.outputResult = $root.google.cloud.retail.v2alpha.OutputResult.toObject(message.outputResult, options); + return object; + }; + + /** + * Converts this ExportUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + ExportUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ExportUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ExportUserEventsResponse"; + }; + + return ExportUserEventsResponse; + })(); + + v2alpha.OutputResult = (function() { + + /** + * Properties of an OutputResult. + * @memberof google.cloud.retail.v2alpha + * @interface IOutputResult + * @property {Array.|null} [bigqueryResult] OutputResult bigqueryResult + */ + + /** + * Constructs a new OutputResult. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an OutputResult. + * @implements IOutputResult + * @constructor + * @param {google.cloud.retail.v2alpha.IOutputResult=} [properties] Properties to set + */ + function OutputResult(properties) { + this.bigqueryResult = []; + 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]]; + } + + /** + * OutputResult bigqueryResult. + * @member {Array.} bigqueryResult + * @memberof google.cloud.retail.v2alpha.OutputResult + * @instance + */ + OutputResult.prototype.bigqueryResult = $util.emptyArray; + + /** + * Creates a new OutputResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {google.cloud.retail.v2alpha.IOutputResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.OutputResult} OutputResult instance + */ + OutputResult.create = function create(properties) { + return new OutputResult(properties); + }; + + /** + * Encodes the specified OutputResult message. Does not implicitly {@link google.cloud.retail.v2alpha.OutputResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {google.cloud.retail.v2alpha.IOutputResult} message OutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.bigqueryResult != null && message.bigqueryResult.length) + for (var i = 0; i < message.bigqueryResult.length; ++i) + $root.google.cloud.retail.v2alpha.BigQueryOutputResult.encode(message.bigqueryResult[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.OutputResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {google.cloud.retail.v2alpha.IOutputResult} message OutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OutputResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.OutputResult} OutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputResult.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.cloud.retail.v2alpha.OutputResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.bigqueryResult && message.bigqueryResult.length)) + message.bigqueryResult = []; + message.bigqueryResult.push($root.google.cloud.retail.v2alpha.BigQueryOutputResult.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OutputResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.OutputResult} OutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OutputResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OutputResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.bigqueryResult != null && message.hasOwnProperty("bigqueryResult")) { + if (!Array.isArray(message.bigqueryResult)) + return "bigqueryResult: array expected"; + for (var i = 0; i < message.bigqueryResult.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.BigQueryOutputResult.verify(message.bigqueryResult[i]); + if (error) + return "bigqueryResult." + error; + } + } + return null; + }; + + /** + * Creates an OutputResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.OutputResult} OutputResult + */ + OutputResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.OutputResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.OutputResult(); + if (object.bigqueryResult) { + if (!Array.isArray(object.bigqueryResult)) + throw TypeError(".google.cloud.retail.v2alpha.OutputResult.bigqueryResult: array expected"); + message.bigqueryResult = []; + for (var i = 0; i < object.bigqueryResult.length; ++i) { + if (typeof object.bigqueryResult[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.OutputResult.bigqueryResult: object expected"); + message.bigqueryResult[i] = $root.google.cloud.retail.v2alpha.BigQueryOutputResult.fromObject(object.bigqueryResult[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OutputResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {google.cloud.retail.v2alpha.OutputResult} message OutputResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OutputResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.bigqueryResult = []; + if (message.bigqueryResult && message.bigqueryResult.length) { + object.bigqueryResult = []; + for (var j = 0; j < message.bigqueryResult.length; ++j) + object.bigqueryResult[j] = $root.google.cloud.retail.v2alpha.BigQueryOutputResult.toObject(message.bigqueryResult[j], options); + } + return object; + }; + + /** + * Converts this OutputResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.OutputResult + * @instance + * @returns {Object.} JSON object + */ + OutputResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OutputResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.OutputResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OutputResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.OutputResult"; + }; + + return OutputResult; + })(); + + v2alpha.BigQueryOutputResult = (function() { + + /** + * Properties of a BigQueryOutputResult. + * @memberof google.cloud.retail.v2alpha + * @interface IBigQueryOutputResult + * @property {string|null} [datasetId] BigQueryOutputResult datasetId + * @property {string|null} [tableId] BigQueryOutputResult tableId + */ + + /** + * Constructs a new BigQueryOutputResult. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a BigQueryOutputResult. + * @implements IBigQueryOutputResult + * @constructor + * @param {google.cloud.retail.v2alpha.IBigQueryOutputResult=} [properties] Properties to set + */ + function BigQueryOutputResult(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]]; + } + + /** + * BigQueryOutputResult datasetId. + * @member {string} datasetId + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @instance + */ + BigQueryOutputResult.prototype.datasetId = ""; + + /** + * BigQueryOutputResult tableId. + * @member {string} tableId + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @instance + */ + BigQueryOutputResult.prototype.tableId = ""; + + /** + * Creates a new BigQueryOutputResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2alpha.IBigQueryOutputResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.BigQueryOutputResult} BigQueryOutputResult instance + */ + BigQueryOutputResult.create = function create(properties) { + return new BigQueryOutputResult(properties); + }; + + /** + * Encodes the specified BigQueryOutputResult message. Does not implicitly {@link google.cloud.retail.v2alpha.BigQueryOutputResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2alpha.IBigQueryOutputResult} message BigQueryOutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOutputResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.datasetId != null && Object.hasOwnProperty.call(message, "datasetId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.datasetId); + if (message.tableId != null && Object.hasOwnProperty.call(message, "tableId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.tableId); + return writer; + }; + + /** + * Encodes the specified BigQueryOutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.BigQueryOutputResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2alpha.IBigQueryOutputResult} message BigQueryOutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOutputResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.BigQueryOutputResult} BigQueryOutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOutputResult.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.cloud.retail.v2alpha.BigQueryOutputResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.datasetId = reader.string(); + break; + } + case 2: { + message.tableId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.BigQueryOutputResult} BigQueryOutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOutputResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQueryOutputResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQueryOutputResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + if (!$util.isString(message.datasetId)) + return "datasetId: string expected"; + if (message.tableId != null && message.hasOwnProperty("tableId")) + if (!$util.isString(message.tableId)) + return "tableId: string expected"; + return null; + }; + + /** + * Creates a BigQueryOutputResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.BigQueryOutputResult} BigQueryOutputResult + */ + BigQueryOutputResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.BigQueryOutputResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.BigQueryOutputResult(); + if (object.datasetId != null) + message.datasetId = String(object.datasetId); + if (object.tableId != null) + message.tableId = String(object.tableId); + return message; + }; + + /** + * Creates a plain object from a BigQueryOutputResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2alpha.BigQueryOutputResult} message BigQueryOutputResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQueryOutputResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.datasetId = ""; + object.tableId = ""; + } + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + object.datasetId = message.datasetId; + if (message.tableId != null && message.hasOwnProperty("tableId")) + object.tableId = message.tableId; + return object; + }; + + /** + * Converts this BigQueryOutputResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @instance + * @returns {Object.} JSON object + */ + BigQueryOutputResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BigQueryOutputResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.BigQueryOutputResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BigQueryOutputResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.BigQueryOutputResult"; + }; + + return BigQueryOutputResult; + })(); + + v2alpha.Model = (function() { + + /** + * Properties of a Model. + * @memberof google.cloud.retail.v2alpha + * @interface IModel + * @property {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig|null} [pageOptimizationConfig] Model pageOptimizationConfig + * @property {string|null} [name] Model name + * @property {string|null} [displayName] Model displayName + * @property {google.cloud.retail.v2alpha.Model.TrainingState|null} [trainingState] Model trainingState + * @property {google.cloud.retail.v2alpha.Model.ServingState|null} [servingState] Model servingState + * @property {google.protobuf.ITimestamp|null} [createTime] Model createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Model updateTime + * @property {string|null} [type] Model type + * @property {string|null} [optimizationObjective] Model optimizationObjective + * @property {google.cloud.retail.v2alpha.Model.PeriodicTuningState|null} [periodicTuningState] Model periodicTuningState + * @property {google.protobuf.ITimestamp|null} [lastTuneTime] Model lastTuneTime + * @property {string|null} [tuningOperation] Model tuningOperation + * @property {google.cloud.retail.v2alpha.Model.DataState|null} [dataState] Model dataState + * @property {google.cloud.retail.v2alpha.RecommendationsFilteringOption|null} [filteringOption] Model filteringOption + * @property {Array.|null} [servingConfigLists] Model servingConfigLists + */ + + /** + * Constructs a new Model. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a Model. + * @implements IModel + * @constructor + * @param {google.cloud.retail.v2alpha.IModel=} [properties] Properties to set + */ + function Model(properties) { + this.servingConfigLists = []; + 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]]; + } + + /** + * Model pageOptimizationConfig. + * @member {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig|null|undefined} pageOptimizationConfig + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.pageOptimizationConfig = null; + + /** + * Model name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.name = ""; + + /** + * Model displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.displayName = ""; + + /** + * Model trainingState. + * @member {google.cloud.retail.v2alpha.Model.TrainingState} trainingState + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.trainingState = 0; + + /** + * Model servingState. + * @member {google.cloud.retail.v2alpha.Model.ServingState} servingState + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.servingState = 0; + + /** + * Model createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.createTime = null; + + /** + * Model updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.updateTime = null; + + /** + * Model type. + * @member {string} type + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.type = ""; + + /** + * Model optimizationObjective. + * @member {string} optimizationObjective + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.optimizationObjective = ""; + + /** + * Model periodicTuningState. + * @member {google.cloud.retail.v2alpha.Model.PeriodicTuningState} periodicTuningState + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.periodicTuningState = 0; + + /** + * Model lastTuneTime. + * @member {google.protobuf.ITimestamp|null|undefined} lastTuneTime + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.lastTuneTime = null; + + /** + * Model tuningOperation. + * @member {string} tuningOperation + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.tuningOperation = ""; + + /** + * Model dataState. + * @member {google.cloud.retail.v2alpha.Model.DataState} dataState + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.dataState = 0; + + /** + * Model filteringOption. + * @member {google.cloud.retail.v2alpha.RecommendationsFilteringOption} filteringOption + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.filteringOption = 0; + + /** + * Model servingConfigLists. + * @member {Array.} servingConfigLists + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Model.prototype.servingConfigLists = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Model trainingConfig. + * @member {"pageOptimizationConfig"|undefined} trainingConfig + * @memberof google.cloud.retail.v2alpha.Model + * @instance + */ + Object.defineProperty(Model.prototype, "trainingConfig", { + get: $util.oneOfGetter($oneOfFields = ["pageOptimizationConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Model instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {google.cloud.retail.v2alpha.IModel=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Model} Model instance + */ + Model.create = function create(properties) { + return new Model(properties); + }; + + /** + * Encodes the specified Model message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {google.cloud.retail.v2alpha.IModel} message Model message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Model.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.trainingState != null && Object.hasOwnProperty.call(message, "trainingState")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.trainingState); + if (message.servingState != null && Object.hasOwnProperty.call(message, "servingState")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.servingState); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + 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.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.type); + if (message.optimizationObjective != null && Object.hasOwnProperty.call(message, "optimizationObjective")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.optimizationObjective); + if (message.periodicTuningState != null && Object.hasOwnProperty.call(message, "periodicTuningState")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.periodicTuningState); + if (message.lastTuneTime != null && Object.hasOwnProperty.call(message, "lastTuneTime")) + $root.google.protobuf.Timestamp.encode(message.lastTuneTime, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.tuningOperation != null && Object.hasOwnProperty.call(message, "tuningOperation")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.tuningOperation); + if (message.dataState != null && Object.hasOwnProperty.call(message, "dataState")) + writer.uint32(/* id 16, wireType 0 =*/128).int32(message.dataState); + if (message.pageOptimizationConfig != null && Object.hasOwnProperty.call(message, "pageOptimizationConfig")) + $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.encode(message.pageOptimizationConfig, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.filteringOption != null && Object.hasOwnProperty.call(message, "filteringOption")) + writer.uint32(/* id 18, wireType 0 =*/144).int32(message.filteringOption); + if (message.servingConfigLists != null && message.servingConfigLists.length) + for (var i = 0; i < message.servingConfigLists.length; ++i) + $root.google.cloud.retail.v2alpha.Model.ServingConfigList.encode(message.servingConfigLists[i], writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Model message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {google.cloud.retail.v2alpha.IModel} message Model message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Model.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Model message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Model} Model + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Model.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.cloud.retail.v2alpha.Model(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 17: { + message.pageOptimizationConfig = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 3: { + message.trainingState = reader.int32(); + break; + } + case 4: { + message.servingState = reader.int32(); + break; + } + case 5: { + 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 7: { + message.type = reader.string(); + break; + } + case 8: { + message.optimizationObjective = reader.string(); + break; + } + case 11: { + message.periodicTuningState = reader.int32(); + break; + } + case 12: { + message.lastTuneTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 15: { + message.tuningOperation = reader.string(); + break; + } + case 16: { + message.dataState = reader.int32(); + break; + } + case 18: { + message.filteringOption = reader.int32(); + break; + } + case 19: { + if (!(message.servingConfigLists && message.servingConfigLists.length)) + message.servingConfigLists = []; + message.servingConfigLists.push($root.google.cloud.retail.v2alpha.Model.ServingConfigList.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Model message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Model} Model + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Model.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Model message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Model.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.pageOptimizationConfig != null && message.hasOwnProperty("pageOptimizationConfig")) { + properties.trainingConfig = 1; + { + var error = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.verify(message.pageOptimizationConfig); + if (error) + return "pageOptimizationConfig." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.trainingState != null && message.hasOwnProperty("trainingState")) + switch (message.trainingState) { + default: + return "trainingState: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.servingState != null && message.hasOwnProperty("servingState")) + switch (message.servingState) { + default: + return "servingState: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + 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.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.optimizationObjective != null && message.hasOwnProperty("optimizationObjective")) + if (!$util.isString(message.optimizationObjective)) + return "optimizationObjective: string expected"; + if (message.periodicTuningState != null && message.hasOwnProperty("periodicTuningState")) + switch (message.periodicTuningState) { + default: + return "periodicTuningState: enum value expected"; + case 0: + case 1: + case 3: + case 2: + break; + } + if (message.lastTuneTime != null && message.hasOwnProperty("lastTuneTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.lastTuneTime); + if (error) + return "lastTuneTime." + error; + } + if (message.tuningOperation != null && message.hasOwnProperty("tuningOperation")) + if (!$util.isString(message.tuningOperation)) + return "tuningOperation: string expected"; + if (message.dataState != null && message.hasOwnProperty("dataState")) + switch (message.dataState) { + default: + return "dataState: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.filteringOption != null && message.hasOwnProperty("filteringOption")) + switch (message.filteringOption) { + default: + return "filteringOption: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.servingConfigLists != null && message.hasOwnProperty("servingConfigLists")) { + if (!Array.isArray(message.servingConfigLists)) + return "servingConfigLists: array expected"; + for (var i = 0; i < message.servingConfigLists.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Model.ServingConfigList.verify(message.servingConfigLists[i]); + if (error) + return "servingConfigLists." + error; + } + } + return null; + }; + + /** + * Creates a Model message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Model} Model + */ + Model.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Model) + return object; + var message = new $root.google.cloud.retail.v2alpha.Model(); + if (object.pageOptimizationConfig != null) { + if (typeof object.pageOptimizationConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.pageOptimizationConfig: object expected"); + message.pageOptimizationConfig = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.fromObject(object.pageOptimizationConfig); + } + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + switch (object.trainingState) { + default: + if (typeof object.trainingState === "number") { + message.trainingState = object.trainingState; + break; + } + break; + case "TRAINING_STATE_UNSPECIFIED": + case 0: + message.trainingState = 0; + break; + case "PAUSED": + case 1: + message.trainingState = 1; + break; + case "TRAINING": + case 2: + message.trainingState = 2; + break; + } + switch (object.servingState) { + default: + if (typeof object.servingState === "number") { + message.servingState = object.servingState; + break; + } + break; + case "SERVING_STATE_UNSPECIFIED": + case 0: + message.servingState = 0; + break; + case "INACTIVE": + case 1: + message.servingState = 1; + break; + case "ACTIVE": + case 2: + message.servingState = 2; + break; + case "TUNED": + case 3: + message.servingState = 3; + break; + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.type != null) + message.type = String(object.type); + if (object.optimizationObjective != null) + message.optimizationObjective = String(object.optimizationObjective); + switch (object.periodicTuningState) { + default: + if (typeof object.periodicTuningState === "number") { + message.periodicTuningState = object.periodicTuningState; + break; + } + break; + case "PERIODIC_TUNING_STATE_UNSPECIFIED": + case 0: + message.periodicTuningState = 0; + break; + case "PERIODIC_TUNING_DISABLED": + case 1: + message.periodicTuningState = 1; + break; + case "ALL_TUNING_DISABLED": + case 3: + message.periodicTuningState = 3; + break; + case "PERIODIC_TUNING_ENABLED": + case 2: + message.periodicTuningState = 2; + break; + } + if (object.lastTuneTime != null) { + if (typeof object.lastTuneTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.lastTuneTime: object expected"); + message.lastTuneTime = $root.google.protobuf.Timestamp.fromObject(object.lastTuneTime); + } + if (object.tuningOperation != null) + message.tuningOperation = String(object.tuningOperation); + switch (object.dataState) { + default: + if (typeof object.dataState === "number") { + message.dataState = object.dataState; + break; + } + break; + case "DATA_STATE_UNSPECIFIED": + case 0: + message.dataState = 0; + break; + case "DATA_OK": + case 1: + message.dataState = 1; + break; + case "DATA_ERROR": + case 2: + message.dataState = 2; + break; + } + switch (object.filteringOption) { + default: + if (typeof object.filteringOption === "number") { + message.filteringOption = object.filteringOption; + break; + } + break; + case "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": + case 0: + message.filteringOption = 0; + break; + case "RECOMMENDATIONS_FILTERING_DISABLED": + case 1: + message.filteringOption = 1; + break; + case "RECOMMENDATIONS_FILTERING_ENABLED": + case 3: + message.filteringOption = 3; + break; + } + if (object.servingConfigLists) { + if (!Array.isArray(object.servingConfigLists)) + throw TypeError(".google.cloud.retail.v2alpha.Model.servingConfigLists: array expected"); + message.servingConfigLists = []; + for (var i = 0; i < object.servingConfigLists.length; ++i) { + if (typeof object.servingConfigLists[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.servingConfigLists: object expected"); + message.servingConfigLists[i] = $root.google.cloud.retail.v2alpha.Model.ServingConfigList.fromObject(object.servingConfigLists[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Model message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {google.cloud.retail.v2alpha.Model} message Model + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Model.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigLists = []; + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.trainingState = options.enums === String ? "TRAINING_STATE_UNSPECIFIED" : 0; + object.servingState = options.enums === String ? "SERVING_STATE_UNSPECIFIED" : 0; + object.createTime = null; + object.updateTime = null; + object.type = ""; + object.optimizationObjective = ""; + object.periodicTuningState = options.enums === String ? "PERIODIC_TUNING_STATE_UNSPECIFIED" : 0; + object.lastTuneTime = null; + object.tuningOperation = ""; + object.dataState = options.enums === String ? "DATA_STATE_UNSPECIFIED" : 0; + object.filteringOption = options.enums === String ? "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.trainingState != null && message.hasOwnProperty("trainingState")) + object.trainingState = options.enums === String ? $root.google.cloud.retail.v2alpha.Model.TrainingState[message.trainingState] === undefined ? message.trainingState : $root.google.cloud.retail.v2alpha.Model.TrainingState[message.trainingState] : message.trainingState; + if (message.servingState != null && message.hasOwnProperty("servingState")) + object.servingState = options.enums === String ? $root.google.cloud.retail.v2alpha.Model.ServingState[message.servingState] === undefined ? message.servingState : $root.google.cloud.retail.v2alpha.Model.ServingState[message.servingState] : message.servingState; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.optimizationObjective != null && message.hasOwnProperty("optimizationObjective")) + object.optimizationObjective = message.optimizationObjective; + if (message.periodicTuningState != null && message.hasOwnProperty("periodicTuningState")) + object.periodicTuningState = options.enums === String ? $root.google.cloud.retail.v2alpha.Model.PeriodicTuningState[message.periodicTuningState] === undefined ? message.periodicTuningState : $root.google.cloud.retail.v2alpha.Model.PeriodicTuningState[message.periodicTuningState] : message.periodicTuningState; + if (message.lastTuneTime != null && message.hasOwnProperty("lastTuneTime")) + object.lastTuneTime = $root.google.protobuf.Timestamp.toObject(message.lastTuneTime, options); + if (message.tuningOperation != null && message.hasOwnProperty("tuningOperation")) + object.tuningOperation = message.tuningOperation; + if (message.dataState != null && message.hasOwnProperty("dataState")) + object.dataState = options.enums === String ? $root.google.cloud.retail.v2alpha.Model.DataState[message.dataState] === undefined ? message.dataState : $root.google.cloud.retail.v2alpha.Model.DataState[message.dataState] : message.dataState; + if (message.pageOptimizationConfig != null && message.hasOwnProperty("pageOptimizationConfig")) { + object.pageOptimizationConfig = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.toObject(message.pageOptimizationConfig, options); + if (options.oneofs) + object.trainingConfig = "pageOptimizationConfig"; + } + if (message.filteringOption != null && message.hasOwnProperty("filteringOption")) + object.filteringOption = options.enums === String ? $root.google.cloud.retail.v2alpha.RecommendationsFilteringOption[message.filteringOption] === undefined ? message.filteringOption : $root.google.cloud.retail.v2alpha.RecommendationsFilteringOption[message.filteringOption] : message.filteringOption; + if (message.servingConfigLists && message.servingConfigLists.length) { + object.servingConfigLists = []; + for (var j = 0; j < message.servingConfigLists.length; ++j) + object.servingConfigLists[j] = $root.google.cloud.retail.v2alpha.Model.ServingConfigList.toObject(message.servingConfigLists[j], options); + } + return object; + }; + + /** + * Converts this Model to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Model + * @instance + * @returns {Object.} JSON object + */ + Model.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Model + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Model + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Model.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Model"; + }; + + Model.PageOptimizationConfig = (function() { + + /** + * Properties of a PageOptimizationConfig. + * @memberof google.cloud.retail.v2alpha.Model + * @interface IPageOptimizationConfig + * @property {string|null} [pageOptimizationEventType] PageOptimizationConfig pageOptimizationEventType + * @property {Array.|null} [panels] PageOptimizationConfig panels + * @property {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction|null} [restriction] PageOptimizationConfig restriction + */ + + /** + * Constructs a new PageOptimizationConfig. + * @memberof google.cloud.retail.v2alpha.Model + * @classdesc Represents a PageOptimizationConfig. + * @implements IPageOptimizationConfig + * @constructor + * @param {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig=} [properties] Properties to set + */ + function PageOptimizationConfig(properties) { + this.panels = []; + 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]]; + } + + /** + * PageOptimizationConfig pageOptimizationEventType. + * @member {string} pageOptimizationEventType + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @instance + */ + PageOptimizationConfig.prototype.pageOptimizationEventType = ""; + + /** + * PageOptimizationConfig panels. + * @member {Array.} panels + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @instance + */ + PageOptimizationConfig.prototype.panels = $util.emptyArray; + + /** + * PageOptimizationConfig restriction. + * @member {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction} restriction + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @instance + */ + PageOptimizationConfig.prototype.restriction = 0; + + /** + * Creates a new PageOptimizationConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig} PageOptimizationConfig instance + */ + PageOptimizationConfig.create = function create(properties) { + return new PageOptimizationConfig(properties); + }; + + /** + * Encodes the specified PageOptimizationConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig} message PageOptimizationConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PageOptimizationConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.pageOptimizationEventType != null && Object.hasOwnProperty.call(message, "pageOptimizationEventType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.pageOptimizationEventType); + if (message.panels != null && message.panels.length) + for (var i = 0; i < message.panels.length; ++i) + $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.encode(message.panels[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.restriction != null && Object.hasOwnProperty.call(message, "restriction")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.restriction); + return writer; + }; + + /** + * Encodes the specified PageOptimizationConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {google.cloud.retail.v2alpha.Model.IPageOptimizationConfig} message PageOptimizationConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PageOptimizationConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PageOptimizationConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig} PageOptimizationConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PageOptimizationConfig.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.cloud.retail.v2alpha.Model.PageOptimizationConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.pageOptimizationEventType = reader.string(); + break; + } + case 2: { + if (!(message.panels && message.panels.length)) + message.panels = []; + message.panels.push($root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.decode(reader, reader.uint32())); + break; + } + case 3: { + message.restriction = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PageOptimizationConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig} PageOptimizationConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PageOptimizationConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PageOptimizationConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PageOptimizationConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.pageOptimizationEventType != null && message.hasOwnProperty("pageOptimizationEventType")) + if (!$util.isString(message.pageOptimizationEventType)) + return "pageOptimizationEventType: string expected"; + if (message.panels != null && message.hasOwnProperty("panels")) { + if (!Array.isArray(message.panels)) + return "panels: array expected"; + for (var i = 0; i < message.panels.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.verify(message.panels[i]); + if (error) + return "panels." + error; + } + } + if (message.restriction != null && message.hasOwnProperty("restriction")) + switch (message.restriction) { + default: + return "restriction: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a PageOptimizationConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig} PageOptimizationConfig + */ + PageOptimizationConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig(); + if (object.pageOptimizationEventType != null) + message.pageOptimizationEventType = String(object.pageOptimizationEventType); + if (object.panels) { + if (!Array.isArray(object.panels)) + throw TypeError(".google.cloud.retail.v2alpha.Model.PageOptimizationConfig.panels: array expected"); + message.panels = []; + for (var i = 0; i < object.panels.length; ++i) { + if (typeof object.panels[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.PageOptimizationConfig.panels: object expected"); + message.panels[i] = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.fromObject(object.panels[i]); + } + } + switch (object.restriction) { + default: + if (typeof object.restriction === "number") { + message.restriction = object.restriction; + break; + } + break; + case "RESTRICTION_UNSPECIFIED": + case 0: + message.restriction = 0; + break; + case "NO_RESTRICTION": + case 1: + message.restriction = 1; + break; + case "UNIQUE_SERVING_CONFIG_RESTRICTION": + case 2: + message.restriction = 2; + break; + case "UNIQUE_MODEL_RESTRICTION": + case 3: + message.restriction = 3; + break; + case "UNIQUE_MODEL_TYPE_RESTRICTION": + case 4: + message.restriction = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a PageOptimizationConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig} message PageOptimizationConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PageOptimizationConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.panels = []; + if (options.defaults) { + object.pageOptimizationEventType = ""; + object.restriction = options.enums === String ? "RESTRICTION_UNSPECIFIED" : 0; + } + if (message.pageOptimizationEventType != null && message.hasOwnProperty("pageOptimizationEventType")) + object.pageOptimizationEventType = message.pageOptimizationEventType; + if (message.panels && message.panels.length) { + object.panels = []; + for (var j = 0; j < message.panels.length; ++j) + object.panels[j] = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.toObject(message.panels[j], options); + } + if (message.restriction != null && message.hasOwnProperty("restriction")) + object.restriction = options.enums === String ? $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction[message.restriction] === undefined ? message.restriction : $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction[message.restriction] : message.restriction; + return object; + }; + + /** + * Converts this PageOptimizationConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @instance + * @returns {Object.} JSON object + */ + PageOptimizationConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PageOptimizationConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PageOptimizationConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Model.PageOptimizationConfig"; + }; + + PageOptimizationConfig.Candidate = (function() { + + /** + * Properties of a Candidate. + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @interface ICandidate + * @property {string|null} [servingConfigId] Candidate servingConfigId + */ + + /** + * Constructs a new Candidate. + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @classdesc Represents a Candidate. + * @implements ICandidate + * @constructor + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate=} [properties] Properties to set + */ + function Candidate(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]]; + } + + /** + * Candidate servingConfigId. + * @member {string|null|undefined} servingConfigId + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @instance + */ + Candidate.prototype.servingConfigId = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Candidate candidate. + * @member {"servingConfigId"|undefined} candidate + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @instance + */ + Object.defineProperty(Candidate.prototype, "candidate", { + get: $util.oneOfGetter($oneOfFields = ["servingConfigId"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Candidate instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate} Candidate instance + */ + Candidate.create = function create(properties) { + return new Candidate(properties); + }; + + /** + * Encodes the specified Candidate message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate} message Candidate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Candidate.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigId != null && Object.hasOwnProperty.call(message, "servingConfigId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfigId); + return writer; + }; + + /** + * Encodes the specified Candidate message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate} message Candidate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Candidate.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Candidate message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate} Candidate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Candidate.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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfigId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Candidate message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate} Candidate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Candidate.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Candidate message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Candidate.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) { + properties.candidate = 1; + if (!$util.isString(message.servingConfigId)) + return "servingConfigId: string expected"; + } + return null; + }; + + /** + * Creates a Candidate message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate} Candidate + */ + Candidate.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate) + return object; + var message = new $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate(); + if (object.servingConfigId != null) + message.servingConfigId = String(object.servingConfigId); + return message; + }; + + /** + * Creates a plain object from a Candidate message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate} message Candidate + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Candidate.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) { + object.servingConfigId = message.servingConfigId; + if (options.oneofs) + object.candidate = "servingConfigId"; + } + return object; + }; + + /** + * Converts this Candidate to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @instance + * @returns {Object.} JSON object + */ + Candidate.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Candidate + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Candidate.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate"; + }; + + return Candidate; + })(); + + PageOptimizationConfig.Panel = (function() { + + /** + * Properties of a Panel. + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @interface IPanel + * @property {string|null} [displayName] Panel displayName + * @property {Array.|null} [candidates] Panel candidates + * @property {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate|null} [defaultCandidate] Panel defaultCandidate + */ + + /** + * Constructs a new Panel. + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig + * @classdesc Represents a Panel. + * @implements IPanel + * @constructor + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel=} [properties] Properties to set + */ + function Panel(properties) { + this.candidates = []; + 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]]; + } + + /** + * Panel displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @instance + */ + Panel.prototype.displayName = ""; + + /** + * Panel candidates. + * @member {Array.} candidates + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @instance + */ + Panel.prototype.candidates = $util.emptyArray; + + /** + * Panel defaultCandidate. + * @member {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.ICandidate|null|undefined} defaultCandidate + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @instance + */ + Panel.prototype.defaultCandidate = null; + + /** + * Creates a new Panel instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel} Panel instance + */ + Panel.create = function create(properties) { + return new Panel(properties); + }; + + /** + * Encodes the specified Panel message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel} message Panel message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Panel.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); + if (message.candidates != null && message.candidates.length) + for (var i = 0; i < message.candidates.length; ++i) + $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.encode(message.candidates[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.defaultCandidate != null && Object.hasOwnProperty.call(message, "defaultCandidate")) + $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.encode(message.defaultCandidate, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Panel message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.IPanel} message Panel message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Panel.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Panel message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel} Panel + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Panel.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.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.displayName = reader.string(); + break; + } + case 2: { + if (!(message.candidates && message.candidates.length)) + message.candidates = []; + message.candidates.push($root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.decode(reader, reader.uint32())); + break; + } + case 3: { + message.defaultCandidate = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Panel message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel} Panel + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Panel.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Panel message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Panel.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.candidates != null && message.hasOwnProperty("candidates")) { + if (!Array.isArray(message.candidates)) + return "candidates: array expected"; + for (var i = 0; i < message.candidates.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify(message.candidates[i]); + if (error) + return "candidates." + error; + } + } + if (message.defaultCandidate != null && message.hasOwnProperty("defaultCandidate")) { + var error = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.verify(message.defaultCandidate); + if (error) + return "defaultCandidate." + error; + } + return null; + }; + + /** + * Creates a Panel message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel} Panel + */ + Panel.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel) + return object; + var message = new $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel(); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.candidates) { + if (!Array.isArray(object.candidates)) + throw TypeError(".google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.candidates: array expected"); + message.candidates = []; + for (var i = 0; i < object.candidates.length; ++i) { + if (typeof object.candidates[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.candidates: object expected"); + message.candidates[i] = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.fromObject(object.candidates[i]); + } + } + if (object.defaultCandidate != null) { + if (typeof object.defaultCandidate !== "object") + throw TypeError(".google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel.defaultCandidate: object expected"); + message.defaultCandidate = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.fromObject(object.defaultCandidate); + } + return message; + }; + + /** + * Creates a plain object from a Panel message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel} message Panel + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Panel.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.candidates = []; + if (options.defaults) { + object.displayName = ""; + object.defaultCandidate = null; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.candidates && message.candidates.length) { + object.candidates = []; + for (var j = 0; j < message.candidates.length; ++j) + object.candidates[j] = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.toObject(message.candidates[j], options); + } + if (message.defaultCandidate != null && message.hasOwnProperty("defaultCandidate")) + object.defaultCandidate = $root.google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Candidate.toObject(message.defaultCandidate, options); + return object; + }; + + /** + * Converts this Panel to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @instance + * @returns {Object.} JSON object + */ + Panel.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Panel + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Panel.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Panel"; + }; + + return Panel; + })(); + + /** + * Restriction enum. + * @name google.cloud.retail.v2alpha.Model.PageOptimizationConfig.Restriction + * @enum {number} + * @property {number} RESTRICTION_UNSPECIFIED=0 RESTRICTION_UNSPECIFIED value + * @property {number} NO_RESTRICTION=1 NO_RESTRICTION value + * @property {number} UNIQUE_SERVING_CONFIG_RESTRICTION=2 UNIQUE_SERVING_CONFIG_RESTRICTION value + * @property {number} UNIQUE_MODEL_RESTRICTION=3 UNIQUE_MODEL_RESTRICTION value + * @property {number} UNIQUE_MODEL_TYPE_RESTRICTION=4 UNIQUE_MODEL_TYPE_RESTRICTION value + */ + PageOptimizationConfig.Restriction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RESTRICTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "NO_RESTRICTION"] = 1; + values[valuesById[2] = "UNIQUE_SERVING_CONFIG_RESTRICTION"] = 2; + values[valuesById[3] = "UNIQUE_MODEL_RESTRICTION"] = 3; + values[valuesById[4] = "UNIQUE_MODEL_TYPE_RESTRICTION"] = 4; + return values; + })(); + + return PageOptimizationConfig; + })(); + + Model.ServingConfigList = (function() { + + /** + * Properties of a ServingConfigList. + * @memberof google.cloud.retail.v2alpha.Model + * @interface IServingConfigList + * @property {Array.|null} [servingConfigIds] ServingConfigList servingConfigIds + */ + + /** + * Constructs a new ServingConfigList. + * @memberof google.cloud.retail.v2alpha.Model + * @classdesc Represents a ServingConfigList. + * @implements IServingConfigList + * @constructor + * @param {google.cloud.retail.v2alpha.Model.IServingConfigList=} [properties] Properties to set + */ + function ServingConfigList(properties) { + this.servingConfigIds = []; + 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]]; + } + + /** + * ServingConfigList servingConfigIds. + * @member {Array.} servingConfigIds + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @instance + */ + ServingConfigList.prototype.servingConfigIds = $util.emptyArray; + + /** + * Creates a new ServingConfigList instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2alpha.Model.IServingConfigList=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.Model.ServingConfigList} ServingConfigList instance + */ + ServingConfigList.create = function create(properties) { + return new ServingConfigList(properties); + }; + + /** + * Encodes the specified ServingConfigList message. Does not implicitly {@link google.cloud.retail.v2alpha.Model.ServingConfigList.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2alpha.Model.IServingConfigList} message ServingConfigList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfigList.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigIds != null && message.servingConfigIds.length) + for (var i = 0; i < message.servingConfigIds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfigIds[i]); + return writer; + }; + + /** + * Encodes the specified ServingConfigList message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.Model.ServingConfigList.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2alpha.Model.IServingConfigList} message ServingConfigList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfigList.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.Model.ServingConfigList} ServingConfigList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfigList.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.cloud.retail.v2alpha.Model.ServingConfigList(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.servingConfigIds && message.servingConfigIds.length)) + message.servingConfigIds = []; + message.servingConfigIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.Model.ServingConfigList} ServingConfigList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfigList.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServingConfigList message. + * @function verify + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServingConfigList.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfigIds != null && message.hasOwnProperty("servingConfigIds")) { + if (!Array.isArray(message.servingConfigIds)) + return "servingConfigIds: array expected"; + for (var i = 0; i < message.servingConfigIds.length; ++i) + if (!$util.isString(message.servingConfigIds[i])) + return "servingConfigIds: string[] expected"; + } + return null; + }; + + /** + * Creates a ServingConfigList message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.Model.ServingConfigList} ServingConfigList + */ + ServingConfigList.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.Model.ServingConfigList) + return object; + var message = new $root.google.cloud.retail.v2alpha.Model.ServingConfigList(); + if (object.servingConfigIds) { + if (!Array.isArray(object.servingConfigIds)) + throw TypeError(".google.cloud.retail.v2alpha.Model.ServingConfigList.servingConfigIds: array expected"); + message.servingConfigIds = []; + for (var i = 0; i < object.servingConfigIds.length; ++i) + message.servingConfigIds[i] = String(object.servingConfigIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a ServingConfigList message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2alpha.Model.ServingConfigList} message ServingConfigList + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServingConfigList.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigIds = []; + if (message.servingConfigIds && message.servingConfigIds.length) { + object.servingConfigIds = []; + for (var j = 0; j < message.servingConfigIds.length; ++j) + object.servingConfigIds[j] = message.servingConfigIds[j]; + } + return object; + }; + + /** + * Converts this ServingConfigList to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @instance + * @returns {Object.} JSON object + */ + ServingConfigList.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServingConfigList + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.Model.ServingConfigList + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServingConfigList.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.Model.ServingConfigList"; + }; + + return ServingConfigList; + })(); + + /** + * ServingState enum. + * @name google.cloud.retail.v2alpha.Model.ServingState + * @enum {number} + * @property {number} SERVING_STATE_UNSPECIFIED=0 SERVING_STATE_UNSPECIFIED value + * @property {number} INACTIVE=1 INACTIVE value + * @property {number} ACTIVE=2 ACTIVE value + * @property {number} TUNED=3 TUNED value + */ + Model.ServingState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INACTIVE"] = 1; + values[valuesById[2] = "ACTIVE"] = 2; + values[valuesById[3] = "TUNED"] = 3; + return values; + })(); + + /** + * TrainingState enum. + * @name google.cloud.retail.v2alpha.Model.TrainingState + * @enum {number} + * @property {number} TRAINING_STATE_UNSPECIFIED=0 TRAINING_STATE_UNSPECIFIED value + * @property {number} PAUSED=1 PAUSED value + * @property {number} TRAINING=2 TRAINING value + */ + Model.TrainingState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TRAINING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PAUSED"] = 1; + values[valuesById[2] = "TRAINING"] = 2; + return values; + })(); + + /** + * PeriodicTuningState enum. + * @name google.cloud.retail.v2alpha.Model.PeriodicTuningState + * @enum {number} + * @property {number} PERIODIC_TUNING_STATE_UNSPECIFIED=0 PERIODIC_TUNING_STATE_UNSPECIFIED value + * @property {number} PERIODIC_TUNING_DISABLED=1 PERIODIC_TUNING_DISABLED value + * @property {number} ALL_TUNING_DISABLED=3 ALL_TUNING_DISABLED value + * @property {number} PERIODIC_TUNING_ENABLED=2 PERIODIC_TUNING_ENABLED value + */ + Model.PeriodicTuningState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "PERIODIC_TUNING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PERIODIC_TUNING_DISABLED"] = 1; + values[valuesById[3] = "ALL_TUNING_DISABLED"] = 3; + values[valuesById[2] = "PERIODIC_TUNING_ENABLED"] = 2; + return values; + })(); + + /** + * DataState enum. + * @name google.cloud.retail.v2alpha.Model.DataState + * @enum {number} + * @property {number} DATA_STATE_UNSPECIFIED=0 DATA_STATE_UNSPECIFIED value + * @property {number} DATA_OK=1 DATA_OK value + * @property {number} DATA_ERROR=2 DATA_ERROR value + */ + Model.DataState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DATA_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DATA_OK"] = 1; + values[valuesById[2] = "DATA_ERROR"] = 2; + return values; + })(); + + return Model; + })(); + + v2alpha.ModelService = (function() { + + /** + * Constructs a new ModelService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ModelService + * @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 ModelService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ModelService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ModelService; + + /** + * Creates new ModelService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.ModelService + * @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 {ModelService} RPC service. Useful where requests and/or responses are streamed. + */ + ModelService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|createModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef CreateModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateModel. + * @function createModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateModelRequest} request CreateModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.CreateModelCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.createModel = function createModel(request, callback) { + return this.rpcCall(createModel, $root.google.cloud.retail.v2alpha.CreateModelRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateModel" }); + + /** + * Calls CreateModel. + * @function createModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateModelRequest} request CreateModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|pauseModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef PauseModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Model} [response] Model + */ + + /** + * Calls PauseModel. + * @function pauseModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IPauseModelRequest} request PauseModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.PauseModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.pauseModel = function pauseModel(request, callback) { + return this.rpcCall(pauseModel, $root.google.cloud.retail.v2alpha.PauseModelRequest, $root.google.cloud.retail.v2alpha.Model, request, callback); + }, "name", { value: "PauseModel" }); + + /** + * Calls PauseModel. + * @function pauseModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IPauseModelRequest} request PauseModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|resumeModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef ResumeModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Model} [response] Model + */ + + /** + * Calls ResumeModel. + * @function resumeModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IResumeModelRequest} request ResumeModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.ResumeModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.resumeModel = function resumeModel(request, callback) { + return this.rpcCall(resumeModel, $root.google.cloud.retail.v2alpha.ResumeModelRequest, $root.google.cloud.retail.v2alpha.Model, request, callback); + }, "name", { value: "ResumeModel" }); + + /** + * Calls ResumeModel. + * @function resumeModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IResumeModelRequest} request ResumeModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|deleteModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef DeleteModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteModel. + * @function deleteModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest} request DeleteModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.DeleteModelCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.deleteModel = function deleteModel(request, callback) { + return this.rpcCall(deleteModel, $root.google.cloud.retail.v2alpha.DeleteModelRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteModel" }); + + /** + * Calls DeleteModel. + * @function deleteModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest} request DeleteModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|listModels}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef ListModelsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ListModelsResponse} [response] ListModelsResponse + */ + + /** + * Calls ListModels. + * @function listModels + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IListModelsRequest} request ListModelsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.ListModelsCallback} callback Node-style callback called with the error, if any, and ListModelsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.listModels = function listModels(request, callback) { + return this.rpcCall(listModels, $root.google.cloud.retail.v2alpha.ListModelsRequest, $root.google.cloud.retail.v2alpha.ListModelsResponse, request, callback); + }, "name", { value: "ListModels" }); + + /** + * Calls ListModels. + * @function listModels + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IListModelsRequest} request ListModelsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|updateModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef UpdateModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Model} [response] Model + */ + + /** + * Calls UpdateModel. + * @function updateModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest} request UpdateModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.UpdateModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.updateModel = function updateModel(request, callback) { + return this.rpcCall(updateModel, $root.google.cloud.retail.v2alpha.UpdateModelRequest, $root.google.cloud.retail.v2alpha.Model, request, callback); + }, "name", { value: "UpdateModel" }); + + /** + * Calls UpdateModel. + * @function updateModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest} request UpdateModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ModelService|tuneModel}. + * @memberof google.cloud.retail.v2alpha.ModelService + * @typedef TuneModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls TuneModel. + * @function tuneModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.ITuneModelRequest} request TuneModelRequest message or plain object + * @param {google.cloud.retail.v2alpha.ModelService.TuneModelCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.tuneModel = function tuneModel(request, callback) { + return this.rpcCall(tuneModel, $root.google.cloud.retail.v2alpha.TuneModelRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "TuneModel" }); + + /** + * Calls TuneModel. + * @function tuneModel + * @memberof google.cloud.retail.v2alpha.ModelService + * @instance + * @param {google.cloud.retail.v2alpha.ITuneModelRequest} request TuneModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ModelService; + })(); + + v2alpha.CreateModelRequest = (function() { + + /** + * Properties of a CreateModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICreateModelRequest + * @property {string|null} [parent] CreateModelRequest parent + * @property {google.cloud.retail.v2alpha.IModel|null} [model] CreateModelRequest model + * @property {boolean|null} [dryRun] CreateModelRequest dryRun + */ + + /** + * Constructs a new CreateModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CreateModelRequest. + * @implements ICreateModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICreateModelRequest=} [properties] Properties to set + */ + function CreateModelRequest(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]]; + } + + /** + * CreateModelRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.parent = ""; + + /** + * CreateModelRequest model. + * @member {google.cloud.retail.v2alpha.IModel|null|undefined} model + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.model = null; + + /** + * CreateModelRequest dryRun. + * @member {boolean} dryRun + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.dryRun = false; + + /** + * Creates a new CreateModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CreateModelRequest} CreateModelRequest instance + */ + CreateModelRequest.create = function create(properties) { + return new CreateModelRequest(properties); + }; + + /** + * Encodes the specified CreateModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelRequest} message CreateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + $root.google.cloud.retail.v2alpha.Model.encode(message.model, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.dryRun != null && Object.hasOwnProperty.call(message, "dryRun")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.dryRun); + return writer; + }; + + /** + * Encodes the specified CreateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelRequest} message CreateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CreateModelRequest} CreateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelRequest.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.cloud.retail.v2alpha.CreateModelRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.model = $root.google.cloud.retail.v2alpha.Model.decode(reader, reader.uint32()); + break; + } + case 3: { + message.dryRun = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CreateModelRequest} CreateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateModelRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.model != null && message.hasOwnProperty("model")) { + var error = $root.google.cloud.retail.v2alpha.Model.verify(message.model); + if (error) + return "model." + error; + } + if (message.dryRun != null && message.hasOwnProperty("dryRun")) + if (typeof message.dryRun !== "boolean") + return "dryRun: boolean expected"; + return null; + }; + + /** + * Creates a CreateModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CreateModelRequest} CreateModelRequest + */ + CreateModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CreateModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CreateModelRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.model != null) { + if (typeof object.model !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CreateModelRequest.model: object expected"); + message.model = $root.google.cloud.retail.v2alpha.Model.fromObject(object.model); + } + if (object.dryRun != null) + message.dryRun = Boolean(object.dryRun); + return message; + }; + + /** + * Creates a plain object from a CreateModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.CreateModelRequest} message CreateModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateModelRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.model = null; + object.dryRun = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.model != null && message.hasOwnProperty("model")) + object.model = $root.google.cloud.retail.v2alpha.Model.toObject(message.model, options); + if (message.dryRun != null && message.hasOwnProperty("dryRun")) + object.dryRun = message.dryRun; + return object; + }; + + /** + * Converts this CreateModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @instance + * @returns {Object.} JSON object + */ + CreateModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CreateModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CreateModelRequest"; + }; + + return CreateModelRequest; + })(); + + v2alpha.UpdateModelRequest = (function() { + + /** + * Properties of an UpdateModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateModelRequest + * @property {google.cloud.retail.v2alpha.IModel|null} [model] UpdateModelRequest model + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateModelRequest updateMask + */ + + /** + * Constructs a new UpdateModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateModelRequest. + * @implements IUpdateModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest=} [properties] Properties to set + */ + function UpdateModelRequest(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]]; + } + + /** + * UpdateModelRequest model. + * @member {google.cloud.retail.v2alpha.IModel|null|undefined} model + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @instance + */ + UpdateModelRequest.prototype.model = null; + + /** + * UpdateModelRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @instance + */ + UpdateModelRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateModelRequest} UpdateModelRequest instance + */ + UpdateModelRequest.create = function create(properties) { + return new UpdateModelRequest(properties); + }; + + /** + * Encodes the specified UpdateModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest} message UpdateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateModelRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + $root.google.cloud.retail.v2alpha.Model.encode(message.model, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateModelRequest} message UpdateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateModelRequest} UpdateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateModelRequest.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.cloud.retail.v2alpha.UpdateModelRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = $root.google.cloud.retail.v2alpha.Model.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateModelRequest} UpdateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateModelRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) { + var error = $root.google.cloud.retail.v2alpha.Model.verify(message.model); + if (error) + return "model." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateModelRequest} UpdateModelRequest + */ + UpdateModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateModelRequest(); + if (object.model != null) { + if (typeof object.model !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateModelRequest.model: object expected"); + message.model = $root.google.cloud.retail.v2alpha.Model.fromObject(object.model); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateModelRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateModelRequest} message UpdateModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateModelRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.model = null; + object.updateMask = null; + } + if (message.model != null && message.hasOwnProperty("model")) + object.model = $root.google.cloud.retail.v2alpha.Model.toObject(message.model, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateModelRequest"; + }; + + return UpdateModelRequest; + })(); + + v2alpha.PauseModelRequest = (function() { + + /** + * Properties of a PauseModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IPauseModelRequest + * @property {string|null} [name] PauseModelRequest name + */ + + /** + * Constructs a new PauseModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PauseModelRequest. + * @implements IPauseModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IPauseModelRequest=} [properties] Properties to set + */ + function PauseModelRequest(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]]; + } + + /** + * PauseModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @instance + */ + PauseModelRequest.prototype.name = ""; + + /** + * Creates a new PauseModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IPauseModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PauseModelRequest} PauseModelRequest instance + */ + PauseModelRequest.create = function create(properties) { + return new PauseModelRequest(properties); + }; + + /** + * Encodes the specified PauseModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PauseModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IPauseModelRequest} message PauseModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PauseModelRequest.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 PauseModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PauseModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IPauseModelRequest} message PauseModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PauseModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PauseModelRequest} PauseModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PauseModelRequest.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.cloud.retail.v2alpha.PauseModelRequest(); + 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 PauseModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PauseModelRequest} PauseModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PauseModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PauseModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PauseModelRequest.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 PauseModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PauseModelRequest} PauseModelRequest + */ + PauseModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PauseModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.PauseModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a PauseModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {google.cloud.retail.v2alpha.PauseModelRequest} message PauseModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PauseModelRequest.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 PauseModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @instance + * @returns {Object.} JSON object + */ + PauseModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PauseModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PauseModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PauseModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PauseModelRequest"; + }; + + return PauseModelRequest; + })(); + + v2alpha.ResumeModelRequest = (function() { + + /** + * Properties of a ResumeModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IResumeModelRequest + * @property {string|null} [name] ResumeModelRequest name + */ + + /** + * Constructs a new ResumeModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ResumeModelRequest. + * @implements IResumeModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IResumeModelRequest=} [properties] Properties to set + */ + function ResumeModelRequest(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]]; + } + + /** + * ResumeModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @instance + */ + ResumeModelRequest.prototype.name = ""; + + /** + * Creates a new ResumeModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IResumeModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ResumeModelRequest} ResumeModelRequest instance + */ + ResumeModelRequest.create = function create(properties) { + return new ResumeModelRequest(properties); + }; + + /** + * Encodes the specified ResumeModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ResumeModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IResumeModelRequest} message ResumeModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResumeModelRequest.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 ResumeModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ResumeModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IResumeModelRequest} message ResumeModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResumeModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ResumeModelRequest} ResumeModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResumeModelRequest.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.cloud.retail.v2alpha.ResumeModelRequest(); + 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 ResumeModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ResumeModelRequest} ResumeModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResumeModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResumeModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResumeModelRequest.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 ResumeModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ResumeModelRequest} ResumeModelRequest + */ + ResumeModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ResumeModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ResumeModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a ResumeModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ResumeModelRequest} message ResumeModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResumeModelRequest.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 ResumeModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @instance + * @returns {Object.} JSON object + */ + ResumeModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResumeModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ResumeModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResumeModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ResumeModelRequest"; + }; + + return ResumeModelRequest; + })(); + + v2alpha.ListModelsRequest = (function() { + + /** + * Properties of a ListModelsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IListModelsRequest + * @property {string|null} [parent] ListModelsRequest parent + * @property {number|null} [pageSize] ListModelsRequest pageSize + * @property {string|null} [pageToken] ListModelsRequest pageToken + */ + + /** + * Constructs a new ListModelsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListModelsRequest. + * @implements IListModelsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IListModelsRequest=} [properties] Properties to set + */ + function ListModelsRequest(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]]; + } + + /** + * ListModelsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.parent = ""; + + /** + * ListModelsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.pageSize = 0; + + /** + * ListModelsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListModelsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListModelsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListModelsRequest} ListModelsRequest instance + */ + ListModelsRequest.create = function create(properties) { + return new ListModelsRequest(properties); + }; + + /** + * Encodes the specified ListModelsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListModelsRequest} message ListModelsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListModelsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListModelsRequest} message ListModelsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListModelsRequest} ListModelsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsRequest.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.cloud.retail.v2alpha.ListModelsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListModelsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListModelsRequest} ListModelsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListModelsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListModelsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListModelsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListModelsRequest} ListModelsRequest + */ + ListModelsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListModelsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListModelsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListModelsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {google.cloud.retail.v2alpha.ListModelsRequest} message ListModelsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListModelsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListModelsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @instance + * @returns {Object.} JSON object + */ + ListModelsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListModelsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListModelsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListModelsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListModelsRequest"; + }; + + return ListModelsRequest; + })(); + + v2alpha.DeleteModelRequest = (function() { + + /** + * Properties of a DeleteModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IDeleteModelRequest + * @property {string|null} [name] DeleteModelRequest name + */ + + /** + * Constructs a new DeleteModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a DeleteModelRequest. + * @implements IDeleteModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest=} [properties] Properties to set + */ + function DeleteModelRequest(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]]; + } + + /** + * DeleteModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @instance + */ + DeleteModelRequest.prototype.name = ""; + + /** + * Creates a new DeleteModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.DeleteModelRequest} DeleteModelRequest instance + */ + DeleteModelRequest.create = function create(properties) { + return new DeleteModelRequest(properties); + }; + + /** + * Encodes the specified DeleteModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest} message DeleteModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteModelRequest.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 DeleteModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteModelRequest} message DeleteModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.DeleteModelRequest} DeleteModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteModelRequest.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.cloud.retail.v2alpha.DeleteModelRequest(); + 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 DeleteModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.DeleteModelRequest} DeleteModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteModelRequest.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 DeleteModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.DeleteModelRequest} DeleteModelRequest + */ + DeleteModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.DeleteModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.DeleteModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2alpha.DeleteModelRequest} message DeleteModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteModelRequest.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 DeleteModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.DeleteModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.DeleteModelRequest"; + }; + + return DeleteModelRequest; + })(); + + v2alpha.ListModelsResponse = (function() { + + /** + * Properties of a ListModelsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IListModelsResponse + * @property {Array.|null} [models] ListModelsResponse models + * @property {string|null} [nextPageToken] ListModelsResponse nextPageToken + */ + + /** + * Constructs a new ListModelsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListModelsResponse. + * @implements IListModelsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IListModelsResponse=} [properties] Properties to set + */ + function ListModelsResponse(properties) { + this.models = []; + 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]]; + } + + /** + * ListModelsResponse models. + * @member {Array.} models + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @instance + */ + ListModelsResponse.prototype.models = $util.emptyArray; + + /** + * ListModelsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @instance + */ + ListModelsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListModelsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListModelsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListModelsResponse} ListModelsResponse instance + */ + ListModelsResponse.create = function create(properties) { + return new ListModelsResponse(properties); + }; + + /** + * Encodes the specified ListModelsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListModelsResponse} message ListModelsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.models != null && message.models.length) + for (var i = 0; i < message.models.length; ++i) + $root.google.cloud.retail.v2alpha.Model.encode(message.models[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 ListModelsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListModelsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListModelsResponse} message ListModelsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListModelsResponse} ListModelsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsResponse.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.cloud.retail.v2alpha.ListModelsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.models && message.models.length)) + message.models = []; + message.models.push($root.google.cloud.retail.v2alpha.Model.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListModelsResponse} ListModelsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListModelsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListModelsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.models != null && message.hasOwnProperty("models")) { + if (!Array.isArray(message.models)) + return "models: array expected"; + for (var i = 0; i < message.models.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Model.verify(message.models[i]); + if (error) + return "models." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListModelsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListModelsResponse} ListModelsResponse + */ + ListModelsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListModelsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListModelsResponse(); + if (object.models) { + if (!Array.isArray(object.models)) + throw TypeError(".google.cloud.retail.v2alpha.ListModelsResponse.models: array expected"); + message.models = []; + for (var i = 0; i < object.models.length; ++i) { + if (typeof object.models[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListModelsResponse.models: object expected"); + message.models[i] = $root.google.cloud.retail.v2alpha.Model.fromObject(object.models[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListModelsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {google.cloud.retail.v2alpha.ListModelsResponse} message ListModelsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListModelsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.models = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.models && message.models.length) { + object.models = []; + for (var j = 0; j < message.models.length; ++j) + object.models[j] = $root.google.cloud.retail.v2alpha.Model.toObject(message.models[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListModelsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @instance + * @returns {Object.} JSON object + */ + ListModelsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListModelsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListModelsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListModelsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListModelsResponse"; + }; + + return ListModelsResponse; + })(); + + v2alpha.TuneModelRequest = (function() { + + /** + * Properties of a TuneModelRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ITuneModelRequest + * @property {string|null} [name] TuneModelRequest name + */ + + /** + * Constructs a new TuneModelRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a TuneModelRequest. + * @implements ITuneModelRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ITuneModelRequest=} [properties] Properties to set + */ + function TuneModelRequest(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]]; + } + + /** + * TuneModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @instance + */ + TuneModelRequest.prototype.name = ""; + + /** + * Creates a new TuneModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.TuneModelRequest} TuneModelRequest instance + */ + TuneModelRequest.create = function create(properties) { + return new TuneModelRequest(properties); + }; + + /** + * Encodes the specified TuneModelRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelRequest} message TuneModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelRequest.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 TuneModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelRequest} message TuneModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.TuneModelRequest} TuneModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelRequest.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.cloud.retail.v2alpha.TuneModelRequest(); + 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 TuneModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.TuneModelRequest} TuneModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelRequest.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 TuneModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.TuneModelRequest} TuneModelRequest + */ + TuneModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.TuneModelRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.TuneModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a TuneModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {google.cloud.retail.v2alpha.TuneModelRequest} message TuneModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelRequest.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 TuneModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @instance + * @returns {Object.} JSON object + */ + TuneModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.TuneModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.TuneModelRequest"; + }; + + return TuneModelRequest; + })(); + + v2alpha.CreateModelMetadata = (function() { + + /** + * Properties of a CreateModelMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface ICreateModelMetadata + * @property {string|null} [model] CreateModelMetadata model + */ + + /** + * Constructs a new CreateModelMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CreateModelMetadata. + * @implements ICreateModelMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.ICreateModelMetadata=} [properties] Properties to set + */ + function CreateModelMetadata(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]]; + } + + /** + * CreateModelMetadata model. + * @member {string} model + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @instance + */ + CreateModelMetadata.prototype.model = ""; + + /** + * Creates a new CreateModelMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CreateModelMetadata} CreateModelMetadata instance + */ + CreateModelMetadata.create = function create(properties) { + return new CreateModelMetadata(properties); + }; + + /** + * Encodes the specified CreateModelMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelMetadata} message CreateModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.model); + return writer; + }; + + /** + * Encodes the specified CreateModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateModelMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ICreateModelMetadata} message CreateModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CreateModelMetadata} CreateModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelMetadata.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.cloud.retail.v2alpha.CreateModelMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CreateModelMetadata} CreateModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateModelMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateModelMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + return null; + }; + + /** + * Creates a CreateModelMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CreateModelMetadata} CreateModelMetadata + */ + CreateModelMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CreateModelMetadata) + return object; + var message = new $root.google.cloud.retail.v2alpha.CreateModelMetadata(); + if (object.model != null) + message.model = String(object.model); + return message; + }; + + /** + * Creates a plain object from a CreateModelMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.CreateModelMetadata} message CreateModelMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateModelMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.model = ""; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + return object; + }; + + /** + * Converts this CreateModelMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @instance + * @returns {Object.} JSON object + */ + CreateModelMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateModelMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CreateModelMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateModelMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CreateModelMetadata"; + }; + + return CreateModelMetadata; + })(); + + v2alpha.TuneModelMetadata = (function() { + + /** + * Properties of a TuneModelMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface ITuneModelMetadata + * @property {string|null} [model] TuneModelMetadata model + */ + + /** + * Constructs a new TuneModelMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a TuneModelMetadata. + * @implements ITuneModelMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.ITuneModelMetadata=} [properties] Properties to set + */ + function TuneModelMetadata(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]]; + } + + /** + * TuneModelMetadata model. + * @member {string} model + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @instance + */ + TuneModelMetadata.prototype.model = ""; + + /** + * Creates a new TuneModelMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.TuneModelMetadata} TuneModelMetadata instance + */ + TuneModelMetadata.create = function create(properties) { + return new TuneModelMetadata(properties); + }; + + /** + * Encodes the specified TuneModelMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelMetadata} message TuneModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.model); + return writer; + }; + + /** + * Encodes the specified TuneModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelMetadata} message TuneModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.TuneModelMetadata} TuneModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelMetadata.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.cloud.retail.v2alpha.TuneModelMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.TuneModelMetadata} TuneModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + return null; + }; + + /** + * Creates a TuneModelMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.TuneModelMetadata} TuneModelMetadata + */ + TuneModelMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.TuneModelMetadata) + return object; + var message = new $root.google.cloud.retail.v2alpha.TuneModelMetadata(); + if (object.model != null) + message.model = String(object.model); + return message; + }; + + /** + * Creates a plain object from a TuneModelMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2alpha.TuneModelMetadata} message TuneModelMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.model = ""; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + return object; + }; + + /** + * Converts this TuneModelMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @instance + * @returns {Object.} JSON object + */ + TuneModelMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.TuneModelMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.TuneModelMetadata"; + }; + + return TuneModelMetadata; + })(); + + v2alpha.TuneModelResponse = (function() { + + /** + * Properties of a TuneModelResponse. + * @memberof google.cloud.retail.v2alpha + * @interface ITuneModelResponse + */ + + /** + * Constructs a new TuneModelResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a TuneModelResponse. + * @implements ITuneModelResponse + * @constructor + * @param {google.cloud.retail.v2alpha.ITuneModelResponse=} [properties] Properties to set + */ + function TuneModelResponse(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 TuneModelResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.TuneModelResponse} TuneModelResponse instance + */ + TuneModelResponse.create = function create(properties) { + return new TuneModelResponse(properties); + }; + + /** + * Encodes the specified TuneModelResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelResponse} message TuneModelResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified TuneModelResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.TuneModelResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {google.cloud.retail.v2alpha.ITuneModelResponse} message TuneModelResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.TuneModelResponse} TuneModelResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelResponse.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.cloud.retail.v2alpha.TuneModelResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.TuneModelResponse} TuneModelResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a TuneModelResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.TuneModelResponse} TuneModelResponse + */ + TuneModelResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.TuneModelResponse) + return object; + return new $root.google.cloud.retail.v2alpha.TuneModelResponse(); + }; + + /** + * Creates a plain object from a TuneModelResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {google.cloud.retail.v2alpha.TuneModelResponse} message TuneModelResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this TuneModelResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @instance + * @returns {Object.} JSON object + */ + TuneModelResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.TuneModelResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.TuneModelResponse"; + }; + + return TuneModelResponse; + })(); + + v2alpha.PredictionService = (function() { + + /** + * Constructs a new PredictionService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PredictionService + * @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 PredictionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (PredictionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = PredictionService; + + /** + * Creates new PredictionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.PredictionService + * @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 {PredictionService} RPC service. Useful where requests and/or responses are streamed. + */ + PredictionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.PredictionService|predict}. + * @memberof google.cloud.retail.v2alpha.PredictionService + * @typedef PredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.PredictResponse} [response] PredictResponse + */ + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2alpha.PredictionService + * @instance + * @param {google.cloud.retail.v2alpha.IPredictRequest} request PredictRequest message or plain object + * @param {google.cloud.retail.v2alpha.PredictionService.PredictCallback} callback Node-style callback called with the error, if any, and PredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.predict = function predict(request, callback) { + return this.rpcCall(predict, $root.google.cloud.retail.v2alpha.PredictRequest, $root.google.cloud.retail.v2alpha.PredictResponse, request, callback); + }, "name", { value: "Predict" }); + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2alpha.PredictionService + * @instance + * @param {google.cloud.retail.v2alpha.IPredictRequest} request PredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return PredictionService; + })(); + + v2alpha.PredictRequest = (function() { + + /** + * Properties of a PredictRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IPredictRequest + * @property {string|null} [placement] PredictRequest placement + * @property {google.cloud.retail.v2alpha.IUserEvent|null} [userEvent] PredictRequest userEvent + * @property {number|null} [pageSize] PredictRequest pageSize + * @property {string|null} [pageToken] PredictRequest pageToken + * @property {string|null} [filter] PredictRequest filter + * @property {boolean|null} [validateOnly] PredictRequest validateOnly + * @property {Object.|null} [params] PredictRequest params + * @property {Object.|null} [labels] PredictRequest labels + */ + + /** + * Constructs a new PredictRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PredictRequest. + * @implements IPredictRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IPredictRequest=} [properties] Properties to set + */ + function PredictRequest(properties) { + this.params = {}; + 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]]; + } + + /** + * PredictRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.placement = ""; + + /** + * PredictRequest userEvent. + * @member {google.cloud.retail.v2alpha.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.userEvent = null; + + /** + * PredictRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.pageSize = 0; + + /** + * PredictRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.pageToken = ""; + + /** + * PredictRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.filter = ""; + + /** + * PredictRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.validateOnly = false; + + /** + * PredictRequest params. + * @member {Object.} params + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.params = $util.emptyObject; + + /** + * PredictRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + */ + PredictRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {google.cloud.retail.v2alpha.IPredictRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PredictRequest} PredictRequest instance + */ + PredictRequest.create = function create(properties) { + return new PredictRequest(properties); + }; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {google.cloud.retail.v2alpha.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2alpha.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.filter); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.validateOnly); + if (message.params != null && Object.hasOwnProperty.call(message, "params")) + for (var keys = Object.keys(message.params), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.Value.encode(message.params[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + 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 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {google.cloud.retail.v2alpha.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.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.cloud.retail.v2alpha.PredictRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.decode(reader, reader.uint32()); + break; + } + case 3: { + message.pageSize = reader.int32(); + break; + } + case 4: { + message.pageToken = reader.string(); + break; + } + case 5: { + message.filter = reader.string(); + break; + } + case 6: { + message.validateOnly = reader.bool(); + break; + } + case 7: { + if (message.params === $util.emptyObject) + message.params = {}; + 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.params[key] = value; + break; + } + case 8: { + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2alpha.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.params != null && message.hasOwnProperty("params")) { + if (!$util.isObject(message.params)) + return "params: object expected"; + var key = Object.keys(message.params); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.params[key[i]]); + if (error) + return "params." + error; + } + } + 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"; + } + return null; + }; + + /** + * Creates a PredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PredictRequest} PredictRequest + */ + PredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PredictRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.PredictRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.fromObject(object.userEvent); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.params) { + if (typeof object.params !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictRequest.params: object expected"); + message.params = {}; + for (var keys = Object.keys(object.params), i = 0; i < keys.length; ++i) { + if (typeof object.params[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictRequest.params: object expected"); + message.params[keys[i]] = $root.google.protobuf.Value.fromObject(object.params[keys[i]]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictRequest.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]]); + } + return message; + }; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {google.cloud.retail.v2alpha.PredictRequest} message PredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.params = {}; + object.labels = {}; + } + if (options.defaults) { + object.placement = ""; + object.userEvent = null; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.validateOnly = false; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.toObject(message.userEvent, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + var keys2; + if (message.params && (keys2 = Object.keys(message.params)).length) { + object.params = {}; + for (var j = 0; j < keys2.length; ++j) + object.params[keys2[j]] = $root.google.protobuf.Value.toObject(message.params[keys2[j]], options); + } + 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]]; + } + return object; + }; + + /** + * Converts this PredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @instance + * @returns {Object.} JSON object + */ + PredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PredictRequest"; + }; + + return PredictRequest; + })(); + + v2alpha.PredictResponse = (function() { + + /** + * Properties of a PredictResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IPredictResponse + * @property {Array.|null} [results] PredictResponse results + * @property {string|null} [attributionToken] PredictResponse attributionToken + * @property {Array.|null} [missingIds] PredictResponse missingIds + * @property {boolean|null} [validateOnly] PredictResponse validateOnly + */ + + /** + * Constructs a new PredictResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PredictResponse. + * @implements IPredictResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IPredictResponse=} [properties] Properties to set + */ + function PredictResponse(properties) { + this.results = []; + this.missingIds = []; + 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]]; + } + + /** + * PredictResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @instance + */ + PredictResponse.prototype.results = $util.emptyArray; + + /** + * PredictResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @instance + */ + PredictResponse.prototype.attributionToken = ""; + + /** + * PredictResponse missingIds. + * @member {Array.} missingIds + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @instance + */ + PredictResponse.prototype.missingIds = $util.emptyArray; + + /** + * PredictResponse validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @instance + */ + PredictResponse.prototype.validateOnly = false; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {google.cloud.retail.v2alpha.IPredictResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PredictResponse} PredictResponse instance + */ + PredictResponse.create = function create(properties) { + return new PredictResponse(properties); + }; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {google.cloud.retail.v2alpha.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.missingIds != null && message.missingIds.length) + for (var i = 0; i < message.missingIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.missingIds[i]); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {google.cloud.retail.v2alpha.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.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.cloud.retail.v2alpha.PredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.missingIds && message.missingIds.length)) + message.missingIds = []; + message.missingIds.push(reader.string()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.missingIds != null && message.hasOwnProperty("missingIds")) { + if (!Array.isArray(message.missingIds)) + return "missingIds: array expected"; + for (var i = 0; i < message.missingIds.length; ++i) + if (!$util.isString(message.missingIds[i])) + return "missingIds: string[] expected"; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a PredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PredictResponse} PredictResponse + */ + PredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PredictResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.PredictResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2alpha.PredictResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult.fromObject(object.results[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.missingIds) { + if (!Array.isArray(object.missingIds)) + throw TypeError(".google.cloud.retail.v2alpha.PredictResponse.missingIds: array expected"); + message.missingIds = []; + for (var i = 0; i < object.missingIds.length; ++i) + message.missingIds[i] = String(object.missingIds[i]); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {google.cloud.retail.v2alpha.PredictResponse} message PredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.missingIds = []; + } + if (options.defaults) { + object.attributionToken = ""; + object.validateOnly = false; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult.toObject(message.results[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.missingIds && message.missingIds.length) { + object.missingIds = []; + for (var j = 0; j < message.missingIds.length; ++j) + object.missingIds[j] = message.missingIds[j]; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this PredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @instance + * @returns {Object.} JSON object + */ + PredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PredictResponse"; + }; + + PredictResponse.PredictionResult = (function() { + + /** + * Properties of a PredictionResult. + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @interface IPredictionResult + * @property {string|null} [id] PredictionResult id + * @property {Object.|null} [metadata] PredictionResult metadata + */ + + /** + * Constructs a new PredictionResult. + * @memberof google.cloud.retail.v2alpha.PredictResponse + * @classdesc Represents a PredictionResult. + * @implements IPredictionResult + * @constructor + * @param {google.cloud.retail.v2alpha.PredictResponse.IPredictionResult=} [properties] Properties to set + */ + function PredictionResult(properties) { + this.metadata = {}; + 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]]; + } + + /** + * PredictionResult id. + * @member {string} id + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.id = ""; + + /** + * PredictionResult metadata. + * @member {Object.} metadata + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.metadata = $util.emptyObject; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2alpha.PredictResponse.IPredictionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PredictResponse.PredictionResult} PredictionResult instance + */ + PredictionResult.create = function create(properties) { + return new PredictionResult(properties); + }; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.PredictionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2alpha.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + for (var keys = Object.keys(message.metadata), 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.protobuf.Value.encode(message.metadata[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PredictResponse.PredictionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2alpha.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.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.cloud.retail.v2alpha.PredictResponse.PredictionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + if (message.metadata === $util.emptyObject) + message.metadata = {}; + 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.metadata[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictionResult message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.metadata != null && message.hasOwnProperty("metadata")) { + if (!$util.isObject(message.metadata)) + return "metadata: object expected"; + var key = Object.keys(message.metadata); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.metadata[key[i]]); + if (error) + return "metadata." + error; + } + } + return null; + }; + + /** + * Creates a PredictionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PredictResponse.PredictionResult} PredictionResult + */ + PredictionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult) + return object; + var message = new $root.google.cloud.retail.v2alpha.PredictResponse.PredictionResult(); + if (object.id != null) + message.id = String(object.id); + if (object.metadata) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata = {}; + for (var keys = Object.keys(object.metadata), i = 0; i < keys.length; ++i) { + if (typeof object.metadata[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata[keys[i]] = $root.google.protobuf.Value.fromObject(object.metadata[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2alpha.PredictResponse.PredictionResult} message PredictionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.metadata = {}; + if (options.defaults) + object.id = ""; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + var keys2; + if (message.metadata && (keys2 = Object.keys(message.metadata)).length) { + object.metadata = {}; + for (var j = 0; j < keys2.length; ++j) + object.metadata[keys2[j]] = $root.google.protobuf.Value.toObject(message.metadata[keys2[j]], options); + } + return object; + }; + + /** + * Converts this PredictionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @instance + * @returns {Object.} JSON object + */ + PredictionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PredictResponse.PredictionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PredictResponse.PredictionResult"; + }; + + return PredictionResult; + })(); + + return PredictResponse; + })(); + + v2alpha.ProductService = (function() { + + /** + * Constructs a new ProductService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ProductService + * @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 ProductService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ProductService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ProductService; + + /** + * Creates new ProductService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.ProductService + * @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 {ProductService} RPC service. Useful where requests and/or responses are streamed. + */ + ProductService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|createProduct}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef CreateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Product} [response] Product + */ + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateProductRequest} request CreateProductRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.CreateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.createProduct = function createProduct(request, callback) { + return this.rpcCall(createProduct, $root.google.cloud.retail.v2alpha.CreateProductRequest, $root.google.cloud.retail.v2alpha.Product, request, callback); + }, "name", { value: "CreateProduct" }); + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateProductRequest} request CreateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|getProduct}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef GetProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Product} [response] Product + */ + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IGetProductRequest} request GetProductRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.GetProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.getProduct = function getProduct(request, callback) { + return this.rpcCall(getProduct, $root.google.cloud.retail.v2alpha.GetProductRequest, $root.google.cloud.retail.v2alpha.Product, request, callback); + }, "name", { value: "GetProduct" }); + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IGetProductRequest} request GetProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|listProducts}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef ListProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ListProductsResponse} [response] ListProductsResponse + */ + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IListProductsRequest} request ListProductsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.ListProductsCallback} callback Node-style callback called with the error, if any, and ListProductsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.listProducts = function listProducts(request, callback) { + return this.rpcCall(listProducts, $root.google.cloud.retail.v2alpha.ListProductsRequest, $root.google.cloud.retail.v2alpha.ListProductsResponse, request, callback); + }, "name", { value: "ListProducts" }); + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IListProductsRequest} request ListProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|updateProduct}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef UpdateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.Product} [response] Product + */ + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.UpdateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.updateProduct = function updateProduct(request, callback) { + return this.rpcCall(updateProduct, $root.google.cloud.retail.v2alpha.UpdateProductRequest, $root.google.cloud.retail.v2alpha.Product, request, callback); + }, "name", { value: "UpdateProduct" }); + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|deleteProduct}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef DeleteProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.DeleteProductCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.deleteProduct = function deleteProduct(request, callback) { + return this.rpcCall(deleteProduct, $root.google.cloud.retail.v2alpha.DeleteProductRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteProduct" }); + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|purgeProducts}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef PurgeProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls PurgeProducts. + * @function purgeProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest} request PurgeProductsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.PurgeProductsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.purgeProducts = function purgeProducts(request, callback) { + return this.rpcCall(purgeProducts, $root.google.cloud.retail.v2alpha.PurgeProductsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "PurgeProducts" }); + + /** + * Calls PurgeProducts. + * @function purgeProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest} request PurgeProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|importProducts}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef ImportProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IImportProductsRequest} request ImportProductsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.ImportProductsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.importProducts = function importProducts(request, callback) { + return this.rpcCall(importProducts, $root.google.cloud.retail.v2alpha.ImportProductsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportProducts" }); + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IImportProductsRequest} request ImportProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|setInventory}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef SetInventoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.SetInventoryCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.setInventory = function setInventory(request, callback) { + return this.rpcCall(setInventory, $root.google.cloud.retail.v2alpha.SetInventoryRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "SetInventory" }); + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|addFulfillmentPlaces}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef AddFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addFulfillmentPlaces = function addFulfillmentPlaces(request, callback) { + return this.rpcCall(addFulfillmentPlaces, $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddFulfillmentPlaces" }); + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|removeFulfillmentPlaces}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef RemoveFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeFulfillmentPlaces = function removeFulfillmentPlaces(request, callback) { + return this.rpcCall(removeFulfillmentPlaces, $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveFulfillmentPlaces" }); + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|addLocalInventories}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef AddLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.AddLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addLocalInventories = function addLocalInventories(request, callback) { + return this.rpcCall(addLocalInventories, $root.google.cloud.retail.v2alpha.AddLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddLocalInventories" }); + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ProductService|removeLocalInventories}. + * @memberof google.cloud.retail.v2alpha.ProductService + * @typedef RemoveLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2alpha.ProductService.RemoveLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeLocalInventories = function removeLocalInventories(request, callback) { + return this.rpcCall(removeLocalInventories, $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveLocalInventories" }); + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2alpha.ProductService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ProductService; + })(); + + v2alpha.CreateProductRequest = (function() { + + /** + * Properties of a CreateProductRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICreateProductRequest + * @property {string|null} [parent] CreateProductRequest parent + * @property {google.cloud.retail.v2alpha.IProduct|null} [product] CreateProductRequest product + * @property {string|null} [productId] CreateProductRequest productId + */ + + /** + * Constructs a new CreateProductRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CreateProductRequest. + * @implements ICreateProductRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICreateProductRequest=} [properties] Properties to set + */ + function CreateProductRequest(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]]; + } + + /** + * CreateProductRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.parent = ""; + + /** + * CreateProductRequest product. + * @member {google.cloud.retail.v2alpha.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.product = null; + + /** + * CreateProductRequest productId. + * @member {string} productId + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.productId = ""; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CreateProductRequest} CreateProductRequest instance + */ + CreateProductRequest.create = function create(properties) { + return new CreateProductRequest(properties); + }; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2alpha.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.productId != null && Object.hasOwnProperty.call(message, "productId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.productId); + return writer; + }; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.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.cloud.retail.v2alpha.CreateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.productId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.productId != null && message.hasOwnProperty("productId")) + if (!$util.isString(message.productId)) + return "productId: string expected"; + return null; + }; + + /** + * Creates a CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CreateProductRequest} CreateProductRequest + */ + CreateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CreateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CreateProductRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CreateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2alpha.Product.fromObject(object.product); + } + if (object.productId != null) + message.productId = String(object.productId); + return message; + }; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.CreateProductRequest} message CreateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.product = null; + object.productId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2alpha.Product.toObject(message.product, options); + if (message.productId != null && message.hasOwnProperty("productId")) + object.productId = message.productId; + return object; + }; + + /** + * Converts this CreateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @instance + * @returns {Object.} JSON object + */ + CreateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CreateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CreateProductRequest"; + }; + + return CreateProductRequest; + })(); + + v2alpha.GetProductRequest = (function() { + + /** + * Properties of a GetProductRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetProductRequest + * @property {string|null} [name] GetProductRequest name + */ + + /** + * Constructs a new GetProductRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetProductRequest. + * @implements IGetProductRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetProductRequest=} [properties] Properties to set + */ + function GetProductRequest(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]]; + } + + /** + * GetProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @instance + */ + GetProductRequest.prototype.name = ""; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetProductRequest} GetProductRequest instance + */ + GetProductRequest.create = function create(properties) { + return new GetProductRequest(properties); + }; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.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 GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.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.cloud.retail.v2alpha.GetProductRequest(); + 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 GetProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetProductRequest.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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetProductRequest} GetProductRequest + */ + GetProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetProductRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {google.cloud.retail.v2alpha.GetProductRequest} message GetProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetProductRequest.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 GetProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @instance + * @returns {Object.} JSON object + */ + GetProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetProductRequest"; + }; + + return GetProductRequest; + })(); + + v2alpha.UpdateProductRequest = (function() { + + /** + * Properties of an UpdateProductRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateProductRequest + * @property {google.cloud.retail.v2alpha.IProduct|null} [product] UpdateProductRequest product + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateProductRequest updateMask + * @property {boolean|null} [allowMissing] UpdateProductRequest allowMissing + */ + + /** + * Constructs a new UpdateProductRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateProductRequest. + * @implements IUpdateProductRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest=} [properties] Properties to set + */ + function UpdateProductRequest(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]]; + } + + /** + * UpdateProductRequest product. + * @member {google.cloud.retail.v2alpha.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.product = null; + + /** + * UpdateProductRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.updateMask = null; + + /** + * UpdateProductRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.allowMissing = false; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateProductRequest} UpdateProductRequest instance + */ + UpdateProductRequest.create = function create(properties) { + return new UpdateProductRequest(properties); + }; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2alpha.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.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.cloud.retail.v2alpha.UpdateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateProductRequest} UpdateProductRequest + */ + UpdateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateProductRequest(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2alpha.Product.fromObject(object.product); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateProductRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateProductRequest} message UpdateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.updateMask = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2alpha.Product.toObject(message.product, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this UpdateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateProductRequest"; + }; + + return UpdateProductRequest; + })(); + + v2alpha.DeleteProductRequest = (function() { + + /** + * Properties of a DeleteProductRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IDeleteProductRequest + * @property {string|null} [name] DeleteProductRequest name + */ + + /** + * Constructs a new DeleteProductRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a DeleteProductRequest. + * @implements IDeleteProductRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest=} [properties] Properties to set + */ + function DeleteProductRequest(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]]; + } + + /** + * DeleteProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @instance + */ + DeleteProductRequest.prototype.name = ""; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.DeleteProductRequest} DeleteProductRequest instance + */ + DeleteProductRequest.create = function create(properties) { + return new DeleteProductRequest(properties); + }; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.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 DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.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.cloud.retail.v2alpha.DeleteProductRequest(); + 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 DeleteProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteProductRequest.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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.DeleteProductRequest} DeleteProductRequest + */ + DeleteProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.DeleteProductRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.DeleteProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2alpha.DeleteProductRequest} message DeleteProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteProductRequest.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 DeleteProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.DeleteProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.DeleteProductRequest"; + }; + + return DeleteProductRequest; + })(); + + v2alpha.ListProductsRequest = (function() { + + /** + * Properties of a ListProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IListProductsRequest + * @property {string|null} [parent] ListProductsRequest parent + * @property {number|null} [pageSize] ListProductsRequest pageSize + * @property {string|null} [pageToken] ListProductsRequest pageToken + * @property {string|null} [filter] ListProductsRequest filter + * @property {google.protobuf.IFieldMask|null} [readMask] ListProductsRequest readMask + * @property {boolean|null} [requireTotalSize] ListProductsRequest requireTotalSize + */ + + /** + * Constructs a new ListProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListProductsRequest. + * @implements IListProductsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IListProductsRequest=} [properties] Properties to set + */ + function ListProductsRequest(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]]; + } + + /** + * ListProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.parent = ""; + + /** + * ListProductsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageSize = 0; + + /** + * ListProductsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageToken = ""; + + /** + * ListProductsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.filter = ""; + + /** + * ListProductsRequest readMask. + * @member {google.protobuf.IFieldMask|null|undefined} readMask + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.readMask = null; + + /** + * ListProductsRequest requireTotalSize. + * @member {boolean} requireTotalSize + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.requireTotalSize = false; + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListProductsRequest} ListProductsRequest instance + */ + ListProductsRequest.create = function create(properties) { + return new ListProductsRequest(properties); + }; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + if (message.readMask != null && Object.hasOwnProperty.call(message, "readMask")) + $root.google.protobuf.FieldMask.encode(message.readMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.requireTotalSize != null && Object.hasOwnProperty.call(message, "requireTotalSize")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.requireTotalSize); + return writer; + }; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.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.cloud.retail.v2alpha.ListProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + case 5: { + message.readMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 6: { + message.requireTotalSize = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.readMask != null && message.hasOwnProperty("readMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.readMask); + if (error) + return "readMask." + error; + } + if (message.requireTotalSize != null && message.hasOwnProperty("requireTotalSize")) + if (typeof message.requireTotalSize !== "boolean") + return "requireTotalSize: boolean expected"; + return null; + }; + + /** + * Creates a ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListProductsRequest} ListProductsRequest + */ + ListProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.readMask != null) { + if (typeof object.readMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListProductsRequest.readMask: object expected"); + message.readMask = $root.google.protobuf.FieldMask.fromObject(object.readMask); + } + if (object.requireTotalSize != null) + message.requireTotalSize = Boolean(object.requireTotalSize); + return message; + }; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.ListProductsRequest} message ListProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.readMask = null; + object.requireTotalSize = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.readMask != null && message.hasOwnProperty("readMask")) + object.readMask = $root.google.protobuf.FieldMask.toObject(message.readMask, options); + if (message.requireTotalSize != null && message.hasOwnProperty("requireTotalSize")) + object.requireTotalSize = message.requireTotalSize; + return object; + }; + + /** + * Converts this ListProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ListProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListProductsRequest"; + }; + + return ListProductsRequest; + })(); + + v2alpha.ListProductsResponse = (function() { + + /** + * Properties of a ListProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IListProductsResponse + * @property {Array.|null} [products] ListProductsResponse products + * @property {string|null} [nextPageToken] ListProductsResponse nextPageToken + * @property {number|null} [totalSize] ListProductsResponse totalSize + */ + + /** + * Constructs a new ListProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListProductsResponse. + * @implements IListProductsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IListProductsResponse=} [properties] Properties to set + */ + function ListProductsResponse(properties) { + this.products = []; + 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]]; + } + + /** + * ListProductsResponse products. + * @member {Array.} products + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.products = $util.emptyArray; + + /** + * ListProductsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.nextPageToken = ""; + + /** + * ListProductsResponse totalSize. + * @member {number} totalSize + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.totalSize = 0; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListProductsResponse} ListProductsResponse instance + */ + ListProductsResponse.create = function create(properties) { + return new ListProductsResponse(properties); + }; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2alpha.Product.encode(message.products[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); + if (message.totalSize != null && Object.hasOwnProperty.call(message, "totalSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.totalSize); + return writer; + }; + + /** + * Encodes the specified ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.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.cloud.retail.v2alpha.ListProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + case 3: { + message.totalSize = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + if (!$util.isInteger(message.totalSize)) + return "totalSize: integer expected"; + return null; + }; + + /** + * Creates a ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListProductsResponse} ListProductsResponse + */ + ListProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListProductsResponse(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2alpha.ListProductsResponse.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListProductsResponse.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2alpha.Product.fromObject(object.products[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + if (object.totalSize != null) + message.totalSize = object.totalSize | 0; + return message; + }; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.ListProductsResponse} message ListProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (options.defaults) { + object.nextPageToken = ""; + object.totalSize = 0; + } + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2alpha.Product.toObject(message.products[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + object.totalSize = message.totalSize; + return object; + }; + + /** + * Converts this ListProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ListProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListProductsResponse"; + }; + + return ListProductsResponse; + })(); + + v2alpha.SetInventoryRequest = (function() { + + /** + * Properties of a SetInventoryRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ISetInventoryRequest + * @property {google.cloud.retail.v2alpha.IProduct|null} [inventory] SetInventoryRequest inventory + * @property {google.protobuf.IFieldMask|null} [setMask] SetInventoryRequest setMask + * @property {google.protobuf.ITimestamp|null} [setTime] SetInventoryRequest setTime + * @property {boolean|null} [allowMissing] SetInventoryRequest allowMissing + */ + + /** + * Constructs a new SetInventoryRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SetInventoryRequest. + * @implements ISetInventoryRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest=} [properties] Properties to set + */ + function SetInventoryRequest(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]]; + } + + /** + * SetInventoryRequest inventory. + * @member {google.cloud.retail.v2alpha.IProduct|null|undefined} inventory + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.inventory = null; + + /** + * SetInventoryRequest setMask. + * @member {google.protobuf.IFieldMask|null|undefined} setMask + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setMask = null; + + /** + * SetInventoryRequest setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setTime = null; + + /** + * SetInventoryRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.allowMissing = false; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SetInventoryRequest} SetInventoryRequest instance + */ + SetInventoryRequest.create = function create(properties) { + return new SetInventoryRequest(properties); + }; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inventory != null && Object.hasOwnProperty.call(message, "inventory")) + $root.google.cloud.retail.v2alpha.Product.encode(message.inventory, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.setMask != null && Object.hasOwnProperty.call(message, "setMask")) + $root.google.protobuf.FieldMask.encode(message.setMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.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.cloud.retail.v2alpha.SetInventoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inventory = $root.google.cloud.retail.v2alpha.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.setMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inventory != null && message.hasOwnProperty("inventory")) { + var error = $root.google.cloud.retail.v2alpha.Product.verify(message.inventory); + if (error) + return "inventory." + error; + } + if (message.setMask != null && message.hasOwnProperty("setMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.setMask); + if (error) + return "setMask." + error; + } + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SetInventoryRequest} SetInventoryRequest + */ + SetInventoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SetInventoryRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.SetInventoryRequest(); + if (object.inventory != null) { + if (typeof object.inventory !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SetInventoryRequest.inventory: object expected"); + message.inventory = $root.google.cloud.retail.v2alpha.Product.fromObject(object.inventory); + } + if (object.setMask != null) { + if (typeof object.setMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SetInventoryRequest.setMask: object expected"); + message.setMask = $root.google.protobuf.FieldMask.fromObject(object.setMask); + } + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.SetInventoryRequest.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2alpha.SetInventoryRequest} message SetInventoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.inventory = null; + object.setMask = null; + object.setTime = null; + object.allowMissing = false; + } + if (message.inventory != null && message.hasOwnProperty("inventory")) + object.inventory = $root.google.cloud.retail.v2alpha.Product.toObject(message.inventory, options); + if (message.setMask != null && message.hasOwnProperty("setMask")) + object.setMask = $root.google.protobuf.FieldMask.toObject(message.setMask, options); + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this SetInventoryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @instance + * @returns {Object.} JSON object + */ + SetInventoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SetInventoryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SetInventoryRequest"; + }; + + return SetInventoryRequest; + })(); + + v2alpha.SetInventoryMetadata = (function() { + + /** + * Properties of a SetInventoryMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface ISetInventoryMetadata + */ + + /** + * Constructs a new SetInventoryMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SetInventoryMetadata. + * @implements ISetInventoryMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.ISetInventoryMetadata=} [properties] Properties to set + */ + function SetInventoryMetadata(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 SetInventoryMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SetInventoryMetadata} SetInventoryMetadata instance + */ + SetInventoryMetadata.create = function create(properties) { + return new SetInventoryMetadata(properties); + }; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.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.cloud.retail.v2alpha.SetInventoryMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SetInventoryMetadata} SetInventoryMetadata + */ + SetInventoryMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SetInventoryMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.SetInventoryMetadata(); + }; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2alpha.SetInventoryMetadata} message SetInventoryMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @instance + * @returns {Object.} JSON object + */ + SetInventoryMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SetInventoryMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SetInventoryMetadata"; + }; + + return SetInventoryMetadata; + })(); + + v2alpha.SetInventoryResponse = (function() { + + /** + * Properties of a SetInventoryResponse. + * @memberof google.cloud.retail.v2alpha + * @interface ISetInventoryResponse + */ + + /** + * Constructs a new SetInventoryResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a SetInventoryResponse. + * @implements ISetInventoryResponse + * @constructor + * @param {google.cloud.retail.v2alpha.ISetInventoryResponse=} [properties] Properties to set + */ + function SetInventoryResponse(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 SetInventoryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.SetInventoryResponse} SetInventoryResponse instance + */ + SetInventoryResponse.create = function create(properties) { + return new SetInventoryResponse(properties); + }; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.SetInventoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2alpha.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.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.cloud.retail.v2alpha.SetInventoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.SetInventoryResponse} SetInventoryResponse + */ + SetInventoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.SetInventoryResponse) + return object; + return new $root.google.cloud.retail.v2alpha.SetInventoryResponse(); + }; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2alpha.SetInventoryResponse} message SetInventoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @instance + * @returns {Object.} JSON object + */ + SetInventoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.SetInventoryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.SetInventoryResponse"; + }; + + return SetInventoryResponse; + })(); + + v2alpha.AddFulfillmentPlacesRequest = (function() { + + /** + * Properties of an AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IAddFulfillmentPlacesRequest + * @property {string|null} [product] AddFulfillmentPlacesRequest product + * @property {string|null} [type] AddFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] AddFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [addTime] AddFulfillmentPlacesRequest addTime + * @property {boolean|null} [allowMissing] AddFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddFulfillmentPlacesRequest. + * @implements IAddFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest=} [properties] Properties to set + */ + function AddFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * AddFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.product = ""; + + /** + * AddFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.type = ""; + + /** + * AddFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * AddFulfillmentPlacesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.addTime = null; + + /** + * AddFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest instance + */ + AddFulfillmentPlacesRequest.create = function create(properties) { + return new AddFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.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.cloud.retail.v2alpha.AddFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + */ + AddFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest"; + }; + + return AddFulfillmentPlacesRequest; + })(); + + v2alpha.AddFulfillmentPlacesMetadata = (function() { + + /** + * Properties of an AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IAddFulfillmentPlacesMetadata + */ + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddFulfillmentPlacesMetadata. + * @implements IAddFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function AddFulfillmentPlacesMetadata(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 AddFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata instance + */ + AddFulfillmentPlacesMetadata.create = function create(properties) { + return new AddFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.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.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + */ + AddFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata"; + }; + + return AddFulfillmentPlacesMetadata; + })(); + + v2alpha.AddFulfillmentPlacesResponse = (function() { + + /** + * Properties of an AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IAddFulfillmentPlacesResponse + */ + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddFulfillmentPlacesResponse. + * @implements IAddFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse=} [properties] Properties to set + */ + function AddFulfillmentPlacesResponse(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 AddFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse instance + */ + AddFulfillmentPlacesResponse.create = function create(properties) { + return new AddFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.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.cloud.retail.v2alpha.AddFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + */ + AddFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse"; + }; + + return AddFulfillmentPlacesResponse; + })(); + + v2alpha.AddLocalInventoriesRequest = (function() { + + /** + * Properties of an AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IAddLocalInventoriesRequest + * @property {string|null} [product] AddLocalInventoriesRequest product + * @property {Array.|null} [localInventories] AddLocalInventoriesRequest localInventories + * @property {google.protobuf.IFieldMask|null} [addMask] AddLocalInventoriesRequest addMask + * @property {google.protobuf.ITimestamp|null} [addTime] AddLocalInventoriesRequest addTime + * @property {boolean|null} [allowMissing] AddLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddLocalInventoriesRequest. + * @implements IAddLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest=} [properties] Properties to set + */ + function AddLocalInventoriesRequest(properties) { + this.localInventories = []; + 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]]; + } + + /** + * AddLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.product = ""; + + /** + * AddLocalInventoriesRequest localInventories. + * @member {Array.} localInventories + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.localInventories = $util.emptyArray; + + /** + * AddLocalInventoriesRequest addMask. + * @member {google.protobuf.IFieldMask|null|undefined} addMask + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addMask = null; + + /** + * AddLocalInventoriesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addTime = null; + + /** + * AddLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesRequest} AddLocalInventoriesRequest instance + */ + AddLocalInventoriesRequest.create = function create(properties) { + return new AddLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.localInventories != null && message.localInventories.length) + for (var i = 0; i < message.localInventories.length; ++i) + $root.google.cloud.retail.v2alpha.LocalInventory.encode(message.localInventories[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.addMask != null && Object.hasOwnProperty.call(message, "addMask")) + $root.google.protobuf.FieldMask.encode(message.addMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.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.cloud.retail.v2alpha.AddLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.localInventories && message.localInventories.length)) + message.localInventories = []; + message.localInventories.push($root.google.cloud.retail.v2alpha.LocalInventory.decode(reader, reader.uint32())); + break; + } + case 4: { + message.addMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.localInventories != null && message.hasOwnProperty("localInventories")) { + if (!Array.isArray(message.localInventories)) + return "localInventories: array expected"; + for (var i = 0; i < message.localInventories.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.LocalInventory.verify(message.localInventories[i]); + if (error) + return "localInventories." + error; + } + } + if (message.addMask != null && message.hasOwnProperty("addMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.addMask); + if (error) + return "addMask." + error; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesRequest} AddLocalInventoriesRequest + */ + AddLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.AddLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.localInventories) { + if (!Array.isArray(object.localInventories)) + throw TypeError(".google.cloud.retail.v2alpha.AddLocalInventoriesRequest.localInventories: array expected"); + message.localInventories = []; + for (var i = 0; i < object.localInventories.length; ++i) { + if (typeof object.localInventories[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AddLocalInventoriesRequest.localInventories: object expected"); + message.localInventories[i] = $root.google.cloud.retail.v2alpha.LocalInventory.fromObject(object.localInventories[i]); + } + } + if (object.addMask != null) { + if (typeof object.addMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AddLocalInventoriesRequest.addMask: object expected"); + message.addMask = $root.google.protobuf.FieldMask.fromObject(object.addMask); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.AddLocalInventoriesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.AddLocalInventoriesRequest} message AddLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.localInventories = []; + if (options.defaults) { + object.product = ""; + object.addMask = null; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.localInventories && message.localInventories.length) { + object.localInventories = []; + for (var j = 0; j < message.localInventories.length; ++j) + object.localInventories[j] = $root.google.cloud.retail.v2alpha.LocalInventory.toObject(message.localInventories[j], options); + } + if (message.addMask != null && message.hasOwnProperty("addMask")) + object.addMask = $root.google.protobuf.FieldMask.toObject(message.addMask, options); + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddLocalInventoriesRequest"; + }; + + return AddLocalInventoriesRequest; + })(); + + v2alpha.AddLocalInventoriesMetadata = (function() { + + /** + * Properties of an AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IAddLocalInventoriesMetadata + */ + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddLocalInventoriesMetadata. + * @implements IAddLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata=} [properties] Properties to set + */ + function AddLocalInventoriesMetadata(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 AddLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata instance + */ + AddLocalInventoriesMetadata.create = function create(properties) { + return new AddLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.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.cloud.retail.v2alpha.AddLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + */ + AddLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.AddLocalInventoriesMetadata} message AddLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddLocalInventoriesMetadata"; + }; + + return AddLocalInventoriesMetadata; + })(); + + v2alpha.AddLocalInventoriesResponse = (function() { + + /** + * Properties of an AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IAddLocalInventoriesResponse + */ + + /** + * Constructs a new AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddLocalInventoriesResponse. + * @implements IAddLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesResponse=} [properties] Properties to set + */ + function AddLocalInventoriesResponse(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 AddLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesResponse} AddLocalInventoriesResponse instance + */ + AddLocalInventoriesResponse.create = function create(properties) { + return new AddLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.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.cloud.retail.v2alpha.AddLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddLocalInventoriesResponse} AddLocalInventoriesResponse + */ + AddLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2alpha.AddLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.AddLocalInventoriesResponse} message AddLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddLocalInventoriesResponse"; + }; + + return AddLocalInventoriesResponse; + })(); + + v2alpha.RemoveLocalInventoriesRequest = (function() { + + /** + * Properties of a RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveLocalInventoriesRequest + * @property {string|null} [product] RemoveLocalInventoriesRequest product + * @property {Array.|null} [placeIds] RemoveLocalInventoriesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveLocalInventoriesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveLocalInventoriesRequest. + * @implements IRemoveLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest=} [properties] Properties to set + */ + function RemoveLocalInventoriesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.product = ""; + + /** + * RemoveLocalInventoriesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveLocalInventoriesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.removeTime = null; + + /** + * RemoveLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest instance + */ + RemoveLocalInventoriesRequest.create = function create(properties) { + return new RemoveLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.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.cloud.retail.v2alpha.RemoveLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 5: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + */ + RemoveLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.allowMissing = false; + object.removeTime = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + return object; + }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest"; + }; + + return RemoveLocalInventoriesRequest; + })(); + + v2alpha.RemoveLocalInventoriesMetadata = (function() { + + /** + * Properties of a RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveLocalInventoriesMetadata + */ + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveLocalInventoriesMetadata. + * @implements IRemoveLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + */ + function RemoveLocalInventoriesMetadata(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 RemoveLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata instance + */ + RemoveLocalInventoriesMetadata.create = function create(properties) { + return new RemoveLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.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.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + */ + RemoveLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata"; + }; + + return RemoveLocalInventoriesMetadata; + })(); + + v2alpha.RemoveLocalInventoriesResponse = (function() { + + /** + * Properties of a RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveLocalInventoriesResponse + */ + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveLocalInventoriesResponse. + * @implements IRemoveLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse=} [properties] Properties to set + */ + function RemoveLocalInventoriesResponse(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 RemoveLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse instance + */ + RemoveLocalInventoriesResponse.create = function create(properties) { + return new RemoveLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.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.cloud.retail.v2alpha.RemoveLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + */ + RemoveLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse"; + }; + + return RemoveLocalInventoriesResponse; + })(); + + v2alpha.RemoveFulfillmentPlacesRequest = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveFulfillmentPlacesRequest + * @property {string|null} [product] RemoveFulfillmentPlacesRequest product + * @property {string|null} [type] RemoveFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] RemoveFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveFulfillmentPlacesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveFulfillmentPlacesRequest. + * @implements IRemoveFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.product = ""; + + /** + * RemoveFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.type = ""; + + /** + * RemoveFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveFulfillmentPlacesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.removeTime = null; + + /** + * RemoveFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest instance + */ + RemoveFulfillmentPlacesRequest.create = function create(properties) { + return new RemoveFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.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.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + */ + RemoveFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.removeTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest"; + }; + + return RemoveFulfillmentPlacesRequest; + })(); + + v2alpha.RemoveFulfillmentPlacesMetadata = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveFulfillmentPlacesMetadata + */ + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveFulfillmentPlacesMetadata. + * @implements IRemoveFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesMetadata(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 RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata instance + */ + RemoveFulfillmentPlacesMetadata.create = function create(properties) { + return new RemoveFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.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.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + */ + RemoveFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata"; + }; + + return RemoveFulfillmentPlacesMetadata; + })(); + + v2alpha.RemoveFulfillmentPlacesResponse = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveFulfillmentPlacesResponse + */ + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveFulfillmentPlacesResponse. + * @implements IRemoveFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesResponse(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 RemoveFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse instance + */ + RemoveFulfillmentPlacesResponse.create = function create(properties) { + return new RemoveFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.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.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + */ + RemoveFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse"; + }; + + return RemoveFulfillmentPlacesResponse; + })(); + + v2alpha.PurgeMetadata = (function() { + + /** + * Properties of a PurgeMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeMetadata + */ + + /** + * Constructs a new PurgeMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeMetadata. + * @implements IPurgeMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeMetadata=} [properties] Properties to set + */ + function PurgeMetadata(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 PurgeMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeMetadata} PurgeMetadata instance + */ + PurgeMetadata.create = function create(properties) { + return new PurgeMetadata(properties); + }; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.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.cloud.retail.v2alpha.PurgeMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeMetadata} PurgeMetadata + */ + PurgeMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.PurgeMetadata(); + }; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {google.cloud.retail.v2alpha.PurgeMetadata} message PurgeMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this PurgeMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @instance + * @returns {Object.} JSON object + */ + PurgeMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeMetadata"; + }; + + return PurgeMetadata; + })(); + + v2alpha.PurgeProductsMetadata = (function() { + + /** + * Properties of a PurgeProductsMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeProductsMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] PurgeProductsMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] PurgeProductsMetadata updateTime + * @property {number|Long|null} [successCount] PurgeProductsMetadata successCount + * @property {number|Long|null} [failureCount] PurgeProductsMetadata failureCount + */ + + /** + * Constructs a new PurgeProductsMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeProductsMetadata. + * @implements IPurgeProductsMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeProductsMetadata=} [properties] Properties to set + */ + function PurgeProductsMetadata(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]]; + } + + /** + * PurgeProductsMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @instance + */ + PurgeProductsMetadata.prototype.createTime = null; + + /** + * PurgeProductsMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @instance + */ + PurgeProductsMetadata.prototype.updateTime = null; + + /** + * PurgeProductsMetadata successCount. + * @member {number|Long} successCount + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @instance + */ + PurgeProductsMetadata.prototype.successCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * PurgeProductsMetadata failureCount. + * @member {number|Long} failureCount + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @instance + */ + PurgeProductsMetadata.prototype.failureCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PurgeProductsMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeProductsMetadata} PurgeProductsMetadata instance + */ + PurgeProductsMetadata.create = function create(properties) { + return new PurgeProductsMetadata(properties); + }; + + /** + * Encodes the specified PurgeProductsMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsMetadata} message PurgeProductsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.successCount != null && Object.hasOwnProperty.call(message, "successCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.successCount); + if (message.failureCount != null && Object.hasOwnProperty.call(message, "failureCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.failureCount); + return writer; + }; + + /** + * Encodes the specified PurgeProductsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsMetadata} message PurgeProductsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeProductsMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeProductsMetadata} PurgeProductsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsMetadata.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.cloud.retail.v2alpha.PurgeProductsMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.successCount = reader.int64(); + break; + } + case 4: { + message.failureCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeProductsMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeProductsMetadata} PurgeProductsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeProductsMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeProductsMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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.successCount != null && message.hasOwnProperty("successCount")) + if (!$util.isInteger(message.successCount) && !(message.successCount && $util.isInteger(message.successCount.low) && $util.isInteger(message.successCount.high))) + return "successCount: integer|Long expected"; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (!$util.isInteger(message.failureCount) && !(message.failureCount && $util.isInteger(message.failureCount.low) && $util.isInteger(message.failureCount.high))) + return "failureCount: integer|Long expected"; + return null; + }; + + /** + * Creates a PurgeProductsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeProductsMetadata} PurgeProductsMetadata + */ + PurgeProductsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeProductsMetadata) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurgeProductsMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PurgeProductsMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2alpha.PurgeProductsMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.successCount != null) + if ($util.Long) + (message.successCount = $util.Long.fromValue(object.successCount)).unsigned = false; + else if (typeof object.successCount === "string") + message.successCount = parseInt(object.successCount, 10); + else if (typeof object.successCount === "number") + message.successCount = object.successCount; + else if (typeof object.successCount === "object") + message.successCount = new $util.LongBits(object.successCount.low >>> 0, object.successCount.high >>> 0).toNumber(); + if (object.failureCount != null) + if ($util.Long) + (message.failureCount = $util.Long.fromValue(object.failureCount)).unsigned = false; + else if (typeof object.failureCount === "string") + message.failureCount = parseInt(object.failureCount, 10); + else if (typeof object.failureCount === "number") + message.failureCount = object.failureCount; + else if (typeof object.failureCount === "object") + message.failureCount = new $util.LongBits(object.failureCount.low >>> 0, object.failureCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PurgeProductsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {google.cloud.retail.v2alpha.PurgeProductsMetadata} message PurgeProductsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeProductsMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.successCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.successCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failureCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failureCount = options.longs === String ? "0" : 0; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.successCount != null && message.hasOwnProperty("successCount")) + if (typeof message.successCount === "number") + object.successCount = options.longs === String ? String(message.successCount) : message.successCount; + else + object.successCount = options.longs === String ? $util.Long.prototype.toString.call(message.successCount) : options.longs === Number ? new $util.LongBits(message.successCount.low >>> 0, message.successCount.high >>> 0).toNumber() : message.successCount; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (typeof message.failureCount === "number") + object.failureCount = options.longs === String ? String(message.failureCount) : message.failureCount; + else + object.failureCount = options.longs === String ? $util.Long.prototype.toString.call(message.failureCount) : options.longs === Number ? new $util.LongBits(message.failureCount.low >>> 0, message.failureCount.high >>> 0).toNumber() : message.failureCount; + return object; + }; + + /** + * Converts this PurgeProductsMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @instance + * @returns {Object.} JSON object + */ + PurgeProductsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeProductsMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeProductsMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeProductsMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeProductsMetadata"; + }; + + return PurgeProductsMetadata; + })(); + + v2alpha.PurgeProductsRequest = (function() { + + /** + * Properties of a PurgeProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeProductsRequest + * @property {string|null} [parent] PurgeProductsRequest parent + * @property {string|null} [filter] PurgeProductsRequest filter + * @property {boolean|null} [force] PurgeProductsRequest force + */ + + /** + * Constructs a new PurgeProductsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeProductsRequest. + * @implements IPurgeProductsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest=} [properties] Properties to set + */ + function PurgeProductsRequest(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]]; + } + + /** + * PurgeProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @instance + */ + PurgeProductsRequest.prototype.parent = ""; + + /** + * PurgeProductsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @instance + */ + PurgeProductsRequest.prototype.filter = ""; + + /** + * PurgeProductsRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @instance + */ + PurgeProductsRequest.prototype.force = false; + + /** + * Creates a new PurgeProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeProductsRequest} PurgeProductsRequest instance + */ + PurgeProductsRequest.create = function create(properties) { + return new PurgeProductsRequest(properties); + }; + + /** + * Encodes the specified PurgeProductsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest} message PurgeProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.force); + return writer; + }; + + /** + * Encodes the specified PurgeProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsRequest} message PurgeProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeProductsRequest} PurgeProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsRequest.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.cloud.retail.v2alpha.PurgeProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.filter = reader.string(); + break; + } + case 3: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeProductsRequest} PurgeProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a PurgeProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeProductsRequest} PurgeProductsRequest + */ + PurgeProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurgeProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a PurgeProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {google.cloud.retail.v2alpha.PurgeProductsRequest} message PurgeProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.force = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this PurgeProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @instance + * @returns {Object.} JSON object + */ + PurgeProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeProductsRequest"; + }; + + return PurgeProductsRequest; + })(); + + v2alpha.PurgeProductsResponse = (function() { + + /** + * Properties of a PurgeProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeProductsResponse + * @property {number|Long|null} [purgeCount] PurgeProductsResponse purgeCount + * @property {Array.|null} [purgeSample] PurgeProductsResponse purgeSample + */ + + /** + * Constructs a new PurgeProductsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeProductsResponse. + * @implements IPurgeProductsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeProductsResponse=} [properties] Properties to set + */ + function PurgeProductsResponse(properties) { + this.purgeSample = []; + 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]]; + } + + /** + * PurgeProductsResponse purgeCount. + * @member {number|Long} purgeCount + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @instance + */ + PurgeProductsResponse.prototype.purgeCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * PurgeProductsResponse purgeSample. + * @member {Array.} purgeSample + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @instance + */ + PurgeProductsResponse.prototype.purgeSample = $util.emptyArray; + + /** + * Creates a new PurgeProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeProductsResponse} PurgeProductsResponse instance + */ + PurgeProductsResponse.create = function create(properties) { + return new PurgeProductsResponse(properties); + }; + + /** + * Encodes the specified PurgeProductsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsResponse} message PurgeProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.purgeCount != null && Object.hasOwnProperty.call(message, "purgeCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.purgeCount); + if (message.purgeSample != null && message.purgeSample.length) + for (var i = 0; i < message.purgeSample.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.purgeSample[i]); + return writer; + }; + + /** + * Encodes the specified PurgeProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeProductsResponse} message PurgeProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeProductsResponse} PurgeProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsResponse.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.cloud.retail.v2alpha.PurgeProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.purgeCount = reader.int64(); + break; + } + case 2: { + if (!(message.purgeSample && message.purgeSample.length)) + message.purgeSample = []; + message.purgeSample.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeProductsResponse} PurgeProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.purgeCount != null && message.hasOwnProperty("purgeCount")) + if (!$util.isInteger(message.purgeCount) && !(message.purgeCount && $util.isInteger(message.purgeCount.low) && $util.isInteger(message.purgeCount.high))) + return "purgeCount: integer|Long expected"; + if (message.purgeSample != null && message.hasOwnProperty("purgeSample")) { + if (!Array.isArray(message.purgeSample)) + return "purgeSample: array expected"; + for (var i = 0; i < message.purgeSample.length; ++i) + if (!$util.isString(message.purgeSample[i])) + return "purgeSample: string[] expected"; + } + return null; + }; + + /** + * Creates a PurgeProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeProductsResponse} PurgeProductsResponse + */ + PurgeProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurgeProductsResponse(); + if (object.purgeCount != null) + if ($util.Long) + (message.purgeCount = $util.Long.fromValue(object.purgeCount)).unsigned = false; + else if (typeof object.purgeCount === "string") + message.purgeCount = parseInt(object.purgeCount, 10); + else if (typeof object.purgeCount === "number") + message.purgeCount = object.purgeCount; + else if (typeof object.purgeCount === "object") + message.purgeCount = new $util.LongBits(object.purgeCount.low >>> 0, object.purgeCount.high >>> 0).toNumber(); + if (object.purgeSample) { + if (!Array.isArray(object.purgeSample)) + throw TypeError(".google.cloud.retail.v2alpha.PurgeProductsResponse.purgeSample: array expected"); + message.purgeSample = []; + for (var i = 0; i < object.purgeSample.length; ++i) + message.purgeSample[i] = String(object.purgeSample[i]); + } + return message; + }; + + /** + * Creates a plain object from a PurgeProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {google.cloud.retail.v2alpha.PurgeProductsResponse} message PurgeProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.purgeSample = []; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.purgeCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.purgeCount = options.longs === String ? "0" : 0; + if (message.purgeCount != null && message.hasOwnProperty("purgeCount")) + if (typeof message.purgeCount === "number") + object.purgeCount = options.longs === String ? String(message.purgeCount) : message.purgeCount; + else + object.purgeCount = options.longs === String ? $util.Long.prototype.toString.call(message.purgeCount) : options.longs === Number ? new $util.LongBits(message.purgeCount.low >>> 0, message.purgeCount.high >>> 0).toNumber() : message.purgeCount; + if (message.purgeSample && message.purgeSample.length) { + object.purgeSample = []; + for (var j = 0; j < message.purgeSample.length; ++j) + object.purgeSample[j] = message.purgeSample[j]; + } + return object; + }; + + /** + * Converts this PurgeProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @instance + * @returns {Object.} JSON object + */ + PurgeProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeProductsResponse"; + }; + + return PurgeProductsResponse; + })(); + + v2alpha.PurgeUserEventsRequest = (function() { + + /** + * Properties of a PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeUserEventsRequest + * @property {string|null} [parent] PurgeUserEventsRequest parent + * @property {string|null} [filter] PurgeUserEventsRequest filter + * @property {boolean|null} [force] PurgeUserEventsRequest force + */ + + /** + * Constructs a new PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeUserEventsRequest. + * @implements IPurgeUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest=} [properties] Properties to set + */ + function PurgeUserEventsRequest(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]]; + } + + /** + * PurgeUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.parent = ""; + + /** + * PurgeUserEventsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.filter = ""; + + /** + * PurgeUserEventsRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.force = false; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsRequest} PurgeUserEventsRequest instance + */ + PurgeUserEventsRequest.create = function create(properties) { + return new PurgeUserEventsRequest(properties); + }; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.force); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.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.cloud.retail.v2alpha.PurgeUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.filter = reader.string(); + break; + } + case 3: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsRequest} PurgeUserEventsRequest + */ + PurgeUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurgeUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.PurgeUserEventsRequest} message PurgeUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.force = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeUserEventsRequest"; + }; + + return PurgeUserEventsRequest; + })(); + + v2alpha.PurgeUserEventsResponse = (function() { + + /** + * Properties of a PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IPurgeUserEventsResponse + * @property {number|Long|null} [purgedEventsCount] PurgeUserEventsResponse purgedEventsCount + */ + + /** + * Constructs a new PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a PurgeUserEventsResponse. + * @implements IPurgeUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsResponse=} [properties] Properties to set + */ + function PurgeUserEventsResponse(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]]; + } + + /** + * PurgeUserEventsResponse purgedEventsCount. + * @member {number|Long} purgedEventsCount + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @instance + */ + PurgeUserEventsResponse.prototype.purgedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsResponse} PurgeUserEventsResponse instance + */ + PurgeUserEventsResponse.create = function create(properties) { + return new PurgeUserEventsResponse(properties); + }; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.purgedEventsCount != null && Object.hasOwnProperty.call(message, "purgedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.purgedEventsCount); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.PurgeUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.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.cloud.retail.v2alpha.PurgeUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.purgedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (!$util.isInteger(message.purgedEventsCount) && !(message.purgedEventsCount && $util.isInteger(message.purgedEventsCount.low) && $util.isInteger(message.purgedEventsCount.high))) + return "purgedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.PurgeUserEventsResponse} PurgeUserEventsResponse + */ + PurgeUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.PurgeUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.PurgeUserEventsResponse(); + if (object.purgedEventsCount != null) + if ($util.Long) + (message.purgedEventsCount = $util.Long.fromValue(object.purgedEventsCount)).unsigned = false; + else if (typeof object.purgedEventsCount === "string") + message.purgedEventsCount = parseInt(object.purgedEventsCount, 10); + else if (typeof object.purgedEventsCount === "number") + message.purgedEventsCount = object.purgedEventsCount; + else if (typeof object.purgedEventsCount === "object") + message.purgedEventsCount = new $util.LongBits(object.purgedEventsCount.low >>> 0, object.purgedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.PurgeUserEventsResponse} message PurgeUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsResponse.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.purgedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.purgedEventsCount = options.longs === String ? "0" : 0; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (typeof message.purgedEventsCount === "number") + object.purgedEventsCount = options.longs === String ? String(message.purgedEventsCount) : message.purgedEventsCount; + else + object.purgedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.purgedEventsCount) : options.longs === Number ? new $util.LongBits(message.purgedEventsCount.low >>> 0, message.purgedEventsCount.high >>> 0).toNumber() : message.purgedEventsCount; + return object; + }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.PurgeUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.PurgeUserEventsResponse"; + }; + + return PurgeUserEventsResponse; + })(); + + v2alpha.ServingConfig = (function() { + + /** + * Properties of a ServingConfig. + * @memberof google.cloud.retail.v2alpha + * @interface IServingConfig + * @property {string|null} [name] ServingConfig name + * @property {string|null} [displayName] ServingConfig displayName + * @property {string|null} [modelId] ServingConfig modelId + * @property {string|null} [priceRerankingLevel] ServingConfig priceRerankingLevel + * @property {Array.|null} [facetControlIds] ServingConfig facetControlIds + * @property {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] ServingConfig dynamicFacetSpec + * @property {Array.|null} [boostControlIds] ServingConfig boostControlIds + * @property {Array.|null} [filterControlIds] ServingConfig filterControlIds + * @property {Array.|null} [redirectControlIds] ServingConfig redirectControlIds + * @property {Array.|null} [twowaySynonymsControlIds] ServingConfig twowaySynonymsControlIds + * @property {Array.|null} [onewaySynonymsControlIds] ServingConfig onewaySynonymsControlIds + * @property {Array.|null} [doNotAssociateControlIds] ServingConfig doNotAssociateControlIds + * @property {Array.|null} [replacementControlIds] ServingConfig replacementControlIds + * @property {Array.|null} [ignoreControlIds] ServingConfig ignoreControlIds + * @property {string|null} [diversityLevel] ServingConfig diversityLevel + * @property {string|null} [enableCategoryFilterLevel] ServingConfig enableCategoryFilterLevel + * @property {Array.|null} [solutionTypes] ServingConfig solutionTypes + */ + + /** + * Constructs a new ServingConfig. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ServingConfig. + * @implements IServingConfig + * @constructor + * @param {google.cloud.retail.v2alpha.IServingConfig=} [properties] Properties to set + */ + function ServingConfig(properties) { + this.facetControlIds = []; + this.boostControlIds = []; + this.filterControlIds = []; + this.redirectControlIds = []; + this.twowaySynonymsControlIds = []; + this.onewaySynonymsControlIds = []; + this.doNotAssociateControlIds = []; + this.replacementControlIds = []; + this.ignoreControlIds = []; + this.solutionTypes = []; + 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]]; + } + + /** + * ServingConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.name = ""; + + /** + * ServingConfig displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.displayName = ""; + + /** + * ServingConfig modelId. + * @member {string} modelId + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.modelId = ""; + + /** + * ServingConfig priceRerankingLevel. + * @member {string} priceRerankingLevel + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.priceRerankingLevel = ""; + + /** + * ServingConfig facetControlIds. + * @member {Array.} facetControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.facetControlIds = $util.emptyArray; + + /** + * ServingConfig dynamicFacetSpec. + * @member {google.cloud.retail.v2alpha.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.dynamicFacetSpec = null; + + /** + * ServingConfig boostControlIds. + * @member {Array.} boostControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.boostControlIds = $util.emptyArray; + + /** + * ServingConfig filterControlIds. + * @member {Array.} filterControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.filterControlIds = $util.emptyArray; + + /** + * ServingConfig redirectControlIds. + * @member {Array.} redirectControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.redirectControlIds = $util.emptyArray; + + /** + * ServingConfig twowaySynonymsControlIds. + * @member {Array.} twowaySynonymsControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.twowaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig onewaySynonymsControlIds. + * @member {Array.} onewaySynonymsControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.onewaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig doNotAssociateControlIds. + * @member {Array.} doNotAssociateControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.doNotAssociateControlIds = $util.emptyArray; + + /** + * ServingConfig replacementControlIds. + * @member {Array.} replacementControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.replacementControlIds = $util.emptyArray; + + /** + * ServingConfig ignoreControlIds. + * @member {Array.} ignoreControlIds + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.ignoreControlIds = $util.emptyArray; + + /** + * ServingConfig diversityLevel. + * @member {string} diversityLevel + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.diversityLevel = ""; + + /** + * ServingConfig enableCategoryFilterLevel. + * @member {string} enableCategoryFilterLevel + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.enableCategoryFilterLevel = ""; + + /** + * ServingConfig solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + */ + ServingConfig.prototype.solutionTypes = $util.emptyArray; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {google.cloud.retail.v2alpha.IServingConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ServingConfig} ServingConfig instance + */ + ServingConfig.create = function create(properties) { + return new ServingConfig(properties); + }; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2alpha.ServingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {google.cloud.retail.v2alpha.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.modelId != null && Object.hasOwnProperty.call(message, "modelId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.modelId); + if (message.priceRerankingLevel != null && Object.hasOwnProperty.call(message, "priceRerankingLevel")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.priceRerankingLevel); + if (message.facetControlIds != null && message.facetControlIds.length) + for (var i = 0; i < message.facetControlIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.facetControlIds[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.boostControlIds != null && message.boostControlIds.length) + for (var i = 0; i < message.boostControlIds.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.boostControlIds[i]); + if (message.diversityLevel != null && Object.hasOwnProperty.call(message, "diversityLevel")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.diversityLevel); + if (message.filterControlIds != null && message.filterControlIds.length) + for (var i = 0; i < message.filterControlIds.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.filterControlIds[i]); + if (message.redirectControlIds != null && message.redirectControlIds.length) + for (var i = 0; i < message.redirectControlIds.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectControlIds[i]); + if (message.onewaySynonymsControlIds != null && message.onewaySynonymsControlIds.length) + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.onewaySynonymsControlIds[i]); + if (message.doNotAssociateControlIds != null && message.doNotAssociateControlIds.length) + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.doNotAssociateControlIds[i]); + if (message.replacementControlIds != null && message.replacementControlIds.length) + for (var i = 0; i < message.replacementControlIds.length; ++i) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.replacementControlIds[i]); + if (message.ignoreControlIds != null && message.ignoreControlIds.length) + for (var i = 0; i < message.ignoreControlIds.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.ignoreControlIds[i]); + if (message.enableCategoryFilterLevel != null && Object.hasOwnProperty.call(message, "enableCategoryFilterLevel")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.enableCategoryFilterLevel); + if (message.twowaySynonymsControlIds != null && message.twowaySynonymsControlIds.length) + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + writer.uint32(/* id 18, wireType 2 =*/146).string(message.twowaySynonymsControlIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 19, wireType 2 =*/154).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ServingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {google.cloud.retail.v2alpha.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.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.cloud.retail.v2alpha.ServingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 3: { + message.modelId = reader.string(); + break; + } + case 4: { + message.priceRerankingLevel = reader.string(); + break; + } + case 5: { + if (!(message.facetControlIds && message.facetControlIds.length)) + message.facetControlIds = []; + message.facetControlIds.push(reader.string()); + break; + } + case 6: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 7: { + if (!(message.boostControlIds && message.boostControlIds.length)) + message.boostControlIds = []; + message.boostControlIds.push(reader.string()); + break; + } + case 9: { + if (!(message.filterControlIds && message.filterControlIds.length)) + message.filterControlIds = []; + message.filterControlIds.push(reader.string()); + break; + } + case 10: { + if (!(message.redirectControlIds && message.redirectControlIds.length)) + message.redirectControlIds = []; + message.redirectControlIds.push(reader.string()); + break; + } + case 18: { + if (!(message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length)) + message.twowaySynonymsControlIds = []; + message.twowaySynonymsControlIds.push(reader.string()); + break; + } + case 12: { + if (!(message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length)) + message.onewaySynonymsControlIds = []; + message.onewaySynonymsControlIds.push(reader.string()); + break; + } + case 13: { + if (!(message.doNotAssociateControlIds && message.doNotAssociateControlIds.length)) + message.doNotAssociateControlIds = []; + message.doNotAssociateControlIds.push(reader.string()); + break; + } + case 14: { + if (!(message.replacementControlIds && message.replacementControlIds.length)) + message.replacementControlIds = []; + message.replacementControlIds.push(reader.string()); + break; + } + case 15: { + if (!(message.ignoreControlIds && message.ignoreControlIds.length)) + message.ignoreControlIds = []; + message.ignoreControlIds.push(reader.string()); + break; + } + case 8: { + message.diversityLevel = reader.string(); + break; + } + case 16: { + message.enableCategoryFilterLevel = reader.string(); + break; + } + case 19: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServingConfig message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServingConfig.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.modelId != null && message.hasOwnProperty("modelId")) + if (!$util.isString(message.modelId)) + return "modelId: string expected"; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + if (!$util.isString(message.priceRerankingLevel)) + return "priceRerankingLevel: string expected"; + if (message.facetControlIds != null && message.hasOwnProperty("facetControlIds")) { + if (!Array.isArray(message.facetControlIds)) + return "facetControlIds: array expected"; + for (var i = 0; i < message.facetControlIds.length; ++i) + if (!$util.isString(message.facetControlIds[i])) + return "facetControlIds: string[] expected"; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostControlIds != null && message.hasOwnProperty("boostControlIds")) { + if (!Array.isArray(message.boostControlIds)) + return "boostControlIds: array expected"; + for (var i = 0; i < message.boostControlIds.length; ++i) + if (!$util.isString(message.boostControlIds[i])) + return "boostControlIds: string[] expected"; + } + if (message.filterControlIds != null && message.hasOwnProperty("filterControlIds")) { + if (!Array.isArray(message.filterControlIds)) + return "filterControlIds: array expected"; + for (var i = 0; i < message.filterControlIds.length; ++i) + if (!$util.isString(message.filterControlIds[i])) + return "filterControlIds: string[] expected"; + } + if (message.redirectControlIds != null && message.hasOwnProperty("redirectControlIds")) { + if (!Array.isArray(message.redirectControlIds)) + return "redirectControlIds: array expected"; + for (var i = 0; i < message.redirectControlIds.length; ++i) + if (!$util.isString(message.redirectControlIds[i])) + return "redirectControlIds: string[] expected"; + } + if (message.twowaySynonymsControlIds != null && message.hasOwnProperty("twowaySynonymsControlIds")) { + if (!Array.isArray(message.twowaySynonymsControlIds)) + return "twowaySynonymsControlIds: array expected"; + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + if (!$util.isString(message.twowaySynonymsControlIds[i])) + return "twowaySynonymsControlIds: string[] expected"; + } + if (message.onewaySynonymsControlIds != null && message.hasOwnProperty("onewaySynonymsControlIds")) { + if (!Array.isArray(message.onewaySynonymsControlIds)) + return "onewaySynonymsControlIds: array expected"; + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + if (!$util.isString(message.onewaySynonymsControlIds[i])) + return "onewaySynonymsControlIds: string[] expected"; + } + if (message.doNotAssociateControlIds != null && message.hasOwnProperty("doNotAssociateControlIds")) { + if (!Array.isArray(message.doNotAssociateControlIds)) + return "doNotAssociateControlIds: array expected"; + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + if (!$util.isString(message.doNotAssociateControlIds[i])) + return "doNotAssociateControlIds: string[] expected"; + } + if (message.replacementControlIds != null && message.hasOwnProperty("replacementControlIds")) { + if (!Array.isArray(message.replacementControlIds)) + return "replacementControlIds: array expected"; + for (var i = 0; i < message.replacementControlIds.length; ++i) + if (!$util.isString(message.replacementControlIds[i])) + return "replacementControlIds: string[] expected"; + } + if (message.ignoreControlIds != null && message.hasOwnProperty("ignoreControlIds")) { + if (!Array.isArray(message.ignoreControlIds)) + return "ignoreControlIds: array expected"; + for (var i = 0; i < message.ignoreControlIds.length; ++i) + if (!$util.isString(message.ignoreControlIds[i])) + return "ignoreControlIds: string[] expected"; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + if (!$util.isString(message.diversityLevel)) + return "diversityLevel: string expected"; + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + if (!$util.isString(message.enableCategoryFilterLevel)) + return "enableCategoryFilterLevel: string expected"; + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a ServingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ServingConfig} ServingConfig + */ + ServingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ServingConfig) + return object; + var message = new $root.google.cloud.retail.v2alpha.ServingConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.modelId != null) + message.modelId = String(object.modelId); + if (object.priceRerankingLevel != null) + message.priceRerankingLevel = String(object.priceRerankingLevel); + if (object.facetControlIds) { + if (!Array.isArray(object.facetControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.facetControlIds: array expected"); + message.facetControlIds = []; + for (var i = 0; i < object.facetControlIds.length; ++i) + message.facetControlIds[i] = String(object.facetControlIds[i]); + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostControlIds) { + if (!Array.isArray(object.boostControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.boostControlIds: array expected"); + message.boostControlIds = []; + for (var i = 0; i < object.boostControlIds.length; ++i) + message.boostControlIds[i] = String(object.boostControlIds[i]); + } + if (object.filterControlIds) { + if (!Array.isArray(object.filterControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.filterControlIds: array expected"); + message.filterControlIds = []; + for (var i = 0; i < object.filterControlIds.length; ++i) + message.filterControlIds[i] = String(object.filterControlIds[i]); + } + if (object.redirectControlIds) { + if (!Array.isArray(object.redirectControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.redirectControlIds: array expected"); + message.redirectControlIds = []; + for (var i = 0; i < object.redirectControlIds.length; ++i) + message.redirectControlIds[i] = String(object.redirectControlIds[i]); + } + if (object.twowaySynonymsControlIds) { + if (!Array.isArray(object.twowaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.twowaySynonymsControlIds: array expected"); + message.twowaySynonymsControlIds = []; + for (var i = 0; i < object.twowaySynonymsControlIds.length; ++i) + message.twowaySynonymsControlIds[i] = String(object.twowaySynonymsControlIds[i]); + } + if (object.onewaySynonymsControlIds) { + if (!Array.isArray(object.onewaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.onewaySynonymsControlIds: array expected"); + message.onewaySynonymsControlIds = []; + for (var i = 0; i < object.onewaySynonymsControlIds.length; ++i) + message.onewaySynonymsControlIds[i] = String(object.onewaySynonymsControlIds[i]); + } + if (object.doNotAssociateControlIds) { + if (!Array.isArray(object.doNotAssociateControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.doNotAssociateControlIds: array expected"); + message.doNotAssociateControlIds = []; + for (var i = 0; i < object.doNotAssociateControlIds.length; ++i) + message.doNotAssociateControlIds[i] = String(object.doNotAssociateControlIds[i]); + } + if (object.replacementControlIds) { + if (!Array.isArray(object.replacementControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.replacementControlIds: array expected"); + message.replacementControlIds = []; + for (var i = 0; i < object.replacementControlIds.length; ++i) + message.replacementControlIds[i] = String(object.replacementControlIds[i]); + } + if (object.ignoreControlIds) { + if (!Array.isArray(object.ignoreControlIds)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.ignoreControlIds: array expected"); + message.ignoreControlIds = []; + for (var i = 0; i < object.ignoreControlIds.length; ++i) + message.ignoreControlIds[i] = String(object.ignoreControlIds[i]); + } + if (object.diversityLevel != null) + message.diversityLevel = String(object.diversityLevel); + if (object.enableCategoryFilterLevel != null) + message.enableCategoryFilterLevel = String(object.enableCategoryFilterLevel); + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2alpha.ServingConfig.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {google.cloud.retail.v2alpha.ServingConfig} message ServingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetControlIds = []; + object.boostControlIds = []; + object.filterControlIds = []; + object.redirectControlIds = []; + object.onewaySynonymsControlIds = []; + object.doNotAssociateControlIds = []; + object.replacementControlIds = []; + object.ignoreControlIds = []; + object.twowaySynonymsControlIds = []; + object.solutionTypes = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.modelId = ""; + object.priceRerankingLevel = ""; + object.dynamicFacetSpec = null; + object.diversityLevel = ""; + object.enableCategoryFilterLevel = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.modelId != null && message.hasOwnProperty("modelId")) + object.modelId = message.modelId; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + object.priceRerankingLevel = message.priceRerankingLevel; + if (message.facetControlIds && message.facetControlIds.length) { + object.facetControlIds = []; + for (var j = 0; j < message.facetControlIds.length; ++j) + object.facetControlIds[j] = message.facetControlIds[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.boostControlIds && message.boostControlIds.length) { + object.boostControlIds = []; + for (var j = 0; j < message.boostControlIds.length; ++j) + object.boostControlIds[j] = message.boostControlIds[j]; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + object.diversityLevel = message.diversityLevel; + if (message.filterControlIds && message.filterControlIds.length) { + object.filterControlIds = []; + for (var j = 0; j < message.filterControlIds.length; ++j) + object.filterControlIds[j] = message.filterControlIds[j]; + } + if (message.redirectControlIds && message.redirectControlIds.length) { + object.redirectControlIds = []; + for (var j = 0; j < message.redirectControlIds.length; ++j) + object.redirectControlIds[j] = message.redirectControlIds[j]; + } + if (message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length) { + object.onewaySynonymsControlIds = []; + for (var j = 0; j < message.onewaySynonymsControlIds.length; ++j) + object.onewaySynonymsControlIds[j] = message.onewaySynonymsControlIds[j]; + } + if (message.doNotAssociateControlIds && message.doNotAssociateControlIds.length) { + object.doNotAssociateControlIds = []; + for (var j = 0; j < message.doNotAssociateControlIds.length; ++j) + object.doNotAssociateControlIds[j] = message.doNotAssociateControlIds[j]; + } + if (message.replacementControlIds && message.replacementControlIds.length) { + object.replacementControlIds = []; + for (var j = 0; j < message.replacementControlIds.length; ++j) + object.replacementControlIds[j] = message.replacementControlIds[j]; + } + if (message.ignoreControlIds && message.ignoreControlIds.length) { + object.ignoreControlIds = []; + for (var j = 0; j < message.ignoreControlIds.length; ++j) + object.ignoreControlIds[j] = message.ignoreControlIds[j]; + } + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + object.enableCategoryFilterLevel = message.enableCategoryFilterLevel; + if (message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length) { + object.twowaySynonymsControlIds = []; + for (var j = 0; j < message.twowaySynonymsControlIds.length; ++j) + object.twowaySynonymsControlIds[j] = message.twowaySynonymsControlIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2alpha.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2alpha.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + return object; + }; + + /** + * Converts this ServingConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @instance + * @returns {Object.} JSON object + */ + ServingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServingConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ServingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ServingConfig"; + }; + + return ServingConfig; + })(); + + v2alpha.ServingConfigService = (function() { + + /** + * Constructs a new ServingConfigService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ServingConfigService + * @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 ServingConfigService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ServingConfigService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ServingConfigService; + + /** + * Creates new ServingConfigService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @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 {ServingConfigService} RPC service. Useful where requests and/or responses are streamed. + */ + ServingConfigService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|createServingConfig}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef CreateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ServingConfig} [response] ServingConfig + */ + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.createServingConfig = function createServingConfig(request, callback) { + return this.rpcCall(createServingConfig, $root.google.cloud.retail.v2alpha.CreateServingConfigRequest, $root.google.cloud.retail.v2alpha.ServingConfig, request, callback); + }, "name", { value: "CreateServingConfig" }); + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|deleteServingConfig}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef DeleteServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfigCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.deleteServingConfig = function deleteServingConfig(request, callback) { + return this.rpcCall(deleteServingConfig, $root.google.cloud.retail.v2alpha.DeleteServingConfigRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteServingConfig" }); + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|updateServingConfig}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef UpdateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ServingConfig} [response] ServingConfig + */ + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.updateServingConfig = function updateServingConfig(request, callback) { + return this.rpcCall(updateServingConfig, $root.google.cloud.retail.v2alpha.UpdateServingConfigRequest, $root.google.cloud.retail.v2alpha.ServingConfig, request, callback); + }, "name", { value: "UpdateServingConfig" }); + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|getServingConfig}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef GetServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ServingConfig} [response] ServingConfig + */ + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.GetServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.getServingConfig = function getServingConfig(request, callback) { + return this.rpcCall(getServingConfig, $root.google.cloud.retail.v2alpha.GetServingConfigRequest, $root.google.cloud.retail.v2alpha.ServingConfig, request, callback); + }, "name", { value: "GetServingConfig" }); + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|listServingConfigs}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef ListServingConfigsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ListServingConfigsResponse} [response] ListServingConfigsResponse + */ + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigsCallback} callback Node-style callback called with the error, if any, and ListServingConfigsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.listServingConfigs = function listServingConfigs(request, callback) { + return this.rpcCall(listServingConfigs, $root.google.cloud.retail.v2alpha.ListServingConfigsRequest, $root.google.cloud.retail.v2alpha.ListServingConfigsResponse, request, callback); + }, "name", { value: "ListServingConfigs" }); + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|addControl}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef AddControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ServingConfig} [response] ServingConfig + */ + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IAddControlRequest} request AddControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.AddControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.addControl = function addControl(request, callback) { + return this.rpcCall(addControl, $root.google.cloud.retail.v2alpha.AddControlRequest, $root.google.cloud.retail.v2alpha.ServingConfig, request, callback); + }, "name", { value: "AddControl" }); + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IAddControlRequest} request AddControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.ServingConfigService|removeControl}. + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @typedef RemoveControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.ServingConfig} [response] ServingConfig + */ + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @param {google.cloud.retail.v2alpha.ServingConfigService.RemoveControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.removeControl = function removeControl(request, callback) { + return this.rpcCall(removeControl, $root.google.cloud.retail.v2alpha.RemoveControlRequest, $root.google.cloud.retail.v2alpha.ServingConfig, request, callback); + }, "name", { value: "RemoveControl" }); + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2alpha.ServingConfigService + * @instance + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ServingConfigService; + })(); + + v2alpha.CreateServingConfigRequest = (function() { + + /** + * Properties of a CreateServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICreateServingConfigRequest + * @property {string|null} [parent] CreateServingConfigRequest parent + * @property {google.cloud.retail.v2alpha.IServingConfig|null} [servingConfig] CreateServingConfigRequest servingConfig + * @property {string|null} [servingConfigId] CreateServingConfigRequest servingConfigId + */ + + /** + * Constructs a new CreateServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CreateServingConfigRequest. + * @implements ICreateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest=} [properties] Properties to set + */ + function CreateServingConfigRequest(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]]; + } + + /** + * CreateServingConfigRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.parent = ""; + + /** + * CreateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2alpha.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfig = null; + + /** + * CreateServingConfigRequest servingConfigId. + * @member {string} servingConfigId + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfigId = ""; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CreateServingConfigRequest} CreateServingConfigRequest instance + */ + CreateServingConfigRequest.create = function create(properties) { + return new CreateServingConfigRequest(properties); + }; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CreateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2alpha.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.servingConfigId != null && Object.hasOwnProperty.call(message, "servingConfigId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.servingConfigId); + return writer; + }; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CreateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.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.cloud.retail.v2alpha.CreateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.servingConfigId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2alpha.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + if (!$util.isString(message.servingConfigId)) + return "servingConfigId: string expected"; + return null; + }; + + /** + * Creates a CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CreateServingConfigRequest} CreateServingConfigRequest + */ + CreateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CreateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CreateServingConfigRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.CreateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.fromObject(object.servingConfig); + } + if (object.servingConfigId != null) + message.servingConfigId = String(object.servingConfigId); + return message; + }; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.CreateServingConfigRequest} message CreateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.servingConfig = null; + object.servingConfigId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.toObject(message.servingConfig, options); + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + object.servingConfigId = message.servingConfigId; + return object; + }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + CreateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CreateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CreateServingConfigRequest"; + }; + + return CreateServingConfigRequest; + })(); + + v2alpha.UpdateServingConfigRequest = (function() { + + /** + * Properties of an UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IUpdateServingConfigRequest + * @property {google.cloud.retail.v2alpha.IServingConfig|null} [servingConfig] UpdateServingConfigRequest servingConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateServingConfigRequest updateMask + */ + + /** + * Constructs a new UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an UpdateServingConfigRequest. + * @implements IUpdateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest=} [properties] Properties to set + */ + function UpdateServingConfigRequest(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]]; + } + + /** + * UpdateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2alpha.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.servingConfig = null; + + /** + * UpdateServingConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.UpdateServingConfigRequest} UpdateServingConfigRequest instance + */ + UpdateServingConfigRequest.create = function create(properties) { + return new UpdateServingConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2alpha.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.UpdateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.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.cloud.retail.v2alpha.UpdateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2alpha.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.UpdateServingConfigRequest} UpdateServingConfigRequest + */ + UpdateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.UpdateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.UpdateServingConfigRequest(); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.fromObject(object.servingConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2alpha.UpdateServingConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.UpdateServingConfigRequest} message UpdateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = null; + object.updateMask = null; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2alpha.ServingConfig.toObject(message.servingConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.UpdateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.UpdateServingConfigRequest"; + }; + + return UpdateServingConfigRequest; + })(); + + v2alpha.DeleteServingConfigRequest = (function() { + + /** + * Properties of a DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IDeleteServingConfigRequest + * @property {string|null} [name] DeleteServingConfigRequest name + */ + + /** + * Constructs a new DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a DeleteServingConfigRequest. + * @implements IDeleteServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest=} [properties] Properties to set + */ + function DeleteServingConfigRequest(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]]; + } + + /** + * DeleteServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @instance + */ + DeleteServingConfigRequest.prototype.name = ""; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.DeleteServingConfigRequest} DeleteServingConfigRequest instance + */ + DeleteServingConfigRequest.create = function create(properties) { + return new DeleteServingConfigRequest(properties); + }; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.DeleteServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.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.cloud.retail.v2alpha.DeleteServingConfigRequest(); + 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 DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.DeleteServingConfigRequest} DeleteServingConfigRequest + */ + DeleteServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.DeleteServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.DeleteServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.DeleteServingConfigRequest} message DeleteServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.DeleteServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.DeleteServingConfigRequest"; + }; + + return DeleteServingConfigRequest; + })(); + + v2alpha.GetServingConfigRequest = (function() { + + /** + * Properties of a GetServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IGetServingConfigRequest + * @property {string|null} [name] GetServingConfigRequest name + */ + + /** + * Constructs a new GetServingConfigRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a GetServingConfigRequest. + * @implements IGetServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest=} [properties] Properties to set + */ + function GetServingConfigRequest(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]]; + } + + /** + * GetServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @instance + */ + GetServingConfigRequest.prototype.name = ""; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.GetServingConfigRequest} GetServingConfigRequest instance + */ + GetServingConfigRequest.create = function create(properties) { + return new GetServingConfigRequest(properties); + }; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.GetServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.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 GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.GetServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.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.cloud.retail.v2alpha.GetServingConfigRequest(); + 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 GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetServingConfigRequest.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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.GetServingConfigRequest} GetServingConfigRequest + */ + GetServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.GetServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.GetServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2alpha.GetServingConfigRequest} message GetServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetServingConfigRequest.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 GetServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.GetServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.GetServingConfigRequest"; + }; + + return GetServingConfigRequest; + })(); + + v2alpha.ListServingConfigsRequest = (function() { + + /** + * Properties of a ListServingConfigsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IListServingConfigsRequest + * @property {string|null} [parent] ListServingConfigsRequest parent + * @property {number|null} [pageSize] ListServingConfigsRequest pageSize + * @property {string|null} [pageToken] ListServingConfigsRequest pageToken + */ + + /** + * Constructs a new ListServingConfigsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListServingConfigsRequest. + * @implements IListServingConfigsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest=} [properties] Properties to set + */ + function ListServingConfigsRequest(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]]; + } + + /** + * ListServingConfigsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.parent = ""; + + /** + * ListServingConfigsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageSize = 0; + + /** + * ListServingConfigsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListServingConfigsRequest} ListServingConfigsRequest instance + */ + ListServingConfigsRequest.create = function create(properties) { + return new ListServingConfigsRequest(properties); + }; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.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.cloud.retail.v2alpha.ListServingConfigsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListServingConfigsRequest} ListServingConfigsRequest + */ + ListServingConfigsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListServingConfigsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListServingConfigsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListServingConfigsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2alpha.ListServingConfigsRequest} message ListServingConfigsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListServingConfigsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListServingConfigsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListServingConfigsRequest"; + }; + + return ListServingConfigsRequest; + })(); + + v2alpha.ListServingConfigsResponse = (function() { + + /** + * Properties of a ListServingConfigsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IListServingConfigsResponse + * @property {Array.|null} [servingConfigs] ListServingConfigsResponse servingConfigs + * @property {string|null} [nextPageToken] ListServingConfigsResponse nextPageToken + */ + + /** + * Constructs a new ListServingConfigsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a ListServingConfigsResponse. + * @implements IListServingConfigsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IListServingConfigsResponse=} [properties] Properties to set + */ + function ListServingConfigsResponse(properties) { + this.servingConfigs = []; + 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]]; + } + + /** + * ListServingConfigsResponse servingConfigs. + * @member {Array.} servingConfigs + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.servingConfigs = $util.emptyArray; + + /** + * ListServingConfigsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.ListServingConfigsResponse} ListServingConfigsResponse instance + */ + ListServingConfigsResponse.create = function create(properties) { + return new ListServingConfigsResponse(properties); + }; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigs != null && message.servingConfigs.length) + for (var i = 0; i < message.servingConfigs.length; ++i) + $root.google.cloud.retail.v2alpha.ServingConfig.encode(message.servingConfigs[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 ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.ListServingConfigsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2alpha.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.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.cloud.retail.v2alpha.ListServingConfigsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.servingConfigs && message.servingConfigs.length)) + message.servingConfigs = []; + message.servingConfigs.push($root.google.cloud.retail.v2alpha.ServingConfig.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfigs != null && message.hasOwnProperty("servingConfigs")) { + if (!Array.isArray(message.servingConfigs)) + return "servingConfigs: array expected"; + for (var i = 0; i < message.servingConfigs.length; ++i) { + var error = $root.google.cloud.retail.v2alpha.ServingConfig.verify(message.servingConfigs[i]); + if (error) + return "servingConfigs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.ListServingConfigsResponse} ListServingConfigsResponse + */ + ListServingConfigsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.ListServingConfigsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.ListServingConfigsResponse(); + if (object.servingConfigs) { + if (!Array.isArray(object.servingConfigs)) + throw TypeError(".google.cloud.retail.v2alpha.ListServingConfigsResponse.servingConfigs: array expected"); + message.servingConfigs = []; + for (var i = 0; i < object.servingConfigs.length; ++i) { + if (typeof object.servingConfigs[i] !== "object") + throw TypeError(".google.cloud.retail.v2alpha.ListServingConfigsResponse.servingConfigs: object expected"); + message.servingConfigs[i] = $root.google.cloud.retail.v2alpha.ServingConfig.fromObject(object.servingConfigs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2alpha.ListServingConfigsResponse} message ListServingConfigsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.servingConfigs && message.servingConfigs.length) { + object.servingConfigs = []; + for (var j = 0; j < message.servingConfigs.length; ++j) + object.servingConfigs[j] = $root.google.cloud.retail.v2alpha.ServingConfig.toObject(message.servingConfigs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.ListServingConfigsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.ListServingConfigsResponse"; + }; + + return ListServingConfigsResponse; + })(); + + v2alpha.AddControlRequest = (function() { + + /** + * Properties of an AddControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IAddControlRequest + * @property {string|null} [servingConfig] AddControlRequest servingConfig + * @property {string|null} [controlId] AddControlRequest controlId + */ + + /** + * Constructs a new AddControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents an AddControlRequest. + * @implements IAddControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IAddControlRequest=} [properties] Properties to set + */ + function AddControlRequest(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]]; + } + + /** + * AddControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @instance + */ + AddControlRequest.prototype.servingConfig = ""; + + /** + * AddControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @instance + */ + AddControlRequest.prototype.controlId = ""; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.AddControlRequest} AddControlRequest instance + */ + AddControlRequest.create = function create(properties) { + return new AddControlRequest(properties); + }; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.AddControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.AddControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.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.cloud.retail.v2alpha.AddControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates an AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.AddControlRequest} AddControlRequest + */ + AddControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.AddControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.AddControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {google.cloud.retail.v2alpha.AddControlRequest} message AddControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this AddControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @instance + * @returns {Object.} JSON object + */ + AddControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.AddControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.AddControlRequest"; + }; + + return AddControlRequest; + })(); + + v2alpha.RemoveControlRequest = (function() { + + /** + * Properties of a RemoveControlRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IRemoveControlRequest + * @property {string|null} [servingConfig] RemoveControlRequest servingConfig + * @property {string|null} [controlId] RemoveControlRequest controlId + */ + + /** + * Constructs a new RemoveControlRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RemoveControlRequest. + * @implements IRemoveControlRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest=} [properties] Properties to set + */ + function RemoveControlRequest(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]]; + } + + /** + * RemoveControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.servingConfig = ""; + + /** + * RemoveControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.controlId = ""; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RemoveControlRequest} RemoveControlRequest instance + */ + RemoveControlRequest.create = function create(properties) { + return new RemoveControlRequest(properties); + }; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RemoveControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2alpha.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.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.cloud.retail.v2alpha.RemoveControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RemoveControlRequest} RemoveControlRequest + */ + RemoveControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RemoveControlRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.RemoveControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2alpha.RemoveControlRequest} message RemoveControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this RemoveControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RemoveControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RemoveControlRequest"; + }; + + return RemoveControlRequest; + })(); + + v2alpha.UserEventService = (function() { + + /** + * Constructs a new UserEventService service. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a UserEventService + * @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 UserEventService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (UserEventService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = UserEventService; + + /** + * Creates new UserEventService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2alpha.UserEventService + * @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 {UserEventService} RPC service. Useful where requests and/or responses are streamed. + */ + UserEventService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|writeUserEvent}. + * @memberof google.cloud.retail.v2alpha.UserEventService + * @typedef WriteUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2alpha.UserEvent} [response] UserEvent + */ + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @param {google.cloud.retail.v2alpha.UserEventService.WriteUserEventCallback} callback Node-style callback called with the error, if any, and UserEvent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.writeUserEvent = function writeUserEvent(request, callback) { + return this.rpcCall(writeUserEvent, $root.google.cloud.retail.v2alpha.WriteUserEventRequest, $root.google.cloud.retail.v2alpha.UserEvent, request, callback); + }, "name", { value: "WriteUserEvent" }); + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|collectUserEvent}. + * @memberof google.cloud.retail.v2alpha.UserEventService + * @typedef CollectUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.api.HttpBody} [response] HttpBody + */ + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @param {google.cloud.retail.v2alpha.UserEventService.CollectUserEventCallback} callback Node-style callback called with the error, if any, and HttpBody + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.collectUserEvent = function collectUserEvent(request, callback) { + return this.rpcCall(collectUserEvent, $root.google.cloud.retail.v2alpha.CollectUserEventRequest, $root.google.api.HttpBody, request, callback); + }, "name", { value: "CollectUserEvent" }); + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|purgeUserEvents}. + * @memberof google.cloud.retail.v2alpha.UserEventService + * @typedef PurgeUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @param {google.cloud.retail.v2alpha.UserEventService.PurgeUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.purgeUserEvents = function purgeUserEvents(request, callback) { + return this.rpcCall(purgeUserEvents, $root.google.cloud.retail.v2alpha.PurgeUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "PurgeUserEvents" }); + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|importUserEvents}. + * @memberof google.cloud.retail.v2alpha.UserEventService + * @typedef ImportUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @param {google.cloud.retail.v2alpha.UserEventService.ImportUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.importUserEvents = function importUserEvents(request, callback) { + return this.rpcCall(importUserEvents, $root.google.cloud.retail.v2alpha.ImportUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportUserEvents" }); + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2alpha.UserEventService|rejoinUserEvents}. + * @memberof google.cloud.retail.v2alpha.UserEventService + * @typedef RejoinUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @param {google.cloud.retail.v2alpha.UserEventService.RejoinUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.rejoinUserEvents = function rejoinUserEvents(request, callback) { + return this.rpcCall(rejoinUserEvents, $root.google.cloud.retail.v2alpha.RejoinUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RejoinUserEvents" }); + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2alpha.UserEventService + * @instance + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return UserEventService; + })(); + + v2alpha.WriteUserEventRequest = (function() { + + /** + * Properties of a WriteUserEventRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IWriteUserEventRequest + * @property {string|null} [parent] WriteUserEventRequest parent + * @property {google.cloud.retail.v2alpha.IUserEvent|null} [userEvent] WriteUserEventRequest userEvent + */ + + /** + * Constructs a new WriteUserEventRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a WriteUserEventRequest. + * @implements IWriteUserEventRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest=} [properties] Properties to set + */ + function WriteUserEventRequest(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]]; + } + + /** + * WriteUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.parent = ""; + + /** + * WriteUserEventRequest userEvent. + * @member {google.cloud.retail.v2alpha.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.userEvent = null; + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.WriteUserEventRequest} WriteUserEventRequest instance + */ + WriteUserEventRequest.create = function create(properties) { + return new WriteUserEventRequest(properties); + }; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.WriteUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2alpha.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.WriteUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.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.cloud.retail.v2alpha.WriteUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2alpha.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + return null; + }; + + /** + * Creates a WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.WriteUserEventRequest} WriteUserEventRequest + */ + WriteUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.WriteUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.WriteUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2alpha.WriteUserEventRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.fromObject(object.userEvent); + } + return message; + }; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.WriteUserEventRequest} message WriteUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2alpha.UserEvent.toObject(message.userEvent, options); + return object; + }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + WriteUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WriteUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.WriteUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WriteUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.WriteUserEventRequest"; + }; + + return WriteUserEventRequest; + })(); + + v2alpha.CollectUserEventRequest = (function() { + + /** + * Properties of a CollectUserEventRequest. + * @memberof google.cloud.retail.v2alpha + * @interface ICollectUserEventRequest + * @property {string|null} [parent] CollectUserEventRequest parent + * @property {string|null} [userEvent] CollectUserEventRequest userEvent + * @property {string|null} [uri] CollectUserEventRequest uri + * @property {number|Long|null} [ets] CollectUserEventRequest ets + */ + + /** + * Constructs a new CollectUserEventRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a CollectUserEventRequest. + * @implements ICollectUserEventRequest + * @constructor + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest=} [properties] Properties to set + */ + function CollectUserEventRequest(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]]; + } + + /** + * CollectUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.parent = ""; + + /** + * CollectUserEventRequest userEvent. + * @member {string} userEvent + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.userEvent = ""; + + /** + * CollectUserEventRequest uri. + * @member {string} uri + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.uri = ""; + + /** + * CollectUserEventRequest ets. + * @member {number|Long} ets + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.ets = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.CollectUserEventRequest} CollectUserEventRequest instance + */ + CollectUserEventRequest.create = function create(properties) { + return new CollectUserEventRequest(properties); + }; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.CollectUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.userEvent); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); + if (message.ets != null && Object.hasOwnProperty.call(message, "ets")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.ets); + return writer; + }; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.CollectUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.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.cloud.retail.v2alpha.CollectUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = reader.string(); + break; + } + case 3: { + message.uri = reader.string(); + break; + } + case 4: { + message.ets = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CollectUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CollectUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + if (!$util.isString(message.userEvent)) + return "userEvent: string expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.ets != null && message.hasOwnProperty("ets")) + if (!$util.isInteger(message.ets) && !(message.ets && $util.isInteger(message.ets.low) && $util.isInteger(message.ets.high))) + return "ets: integer|Long expected"; + return null; + }; + + /** + * Creates a CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.CollectUserEventRequest} CollectUserEventRequest + */ + CollectUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.CollectUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.CollectUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) + message.userEvent = String(object.userEvent); + if (object.uri != null) + message.uri = String(object.uri); + if (object.ets != null) + if ($util.Long) + (message.ets = $util.Long.fromValue(object.ets)).unsigned = false; + else if (typeof object.ets === "string") + message.ets = parseInt(object.ets, 10); + else if (typeof object.ets === "number") + message.ets = object.ets; + else if (typeof object.ets === "object") + message.ets = new $util.LongBits(object.ets.low >>> 0, object.ets.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2alpha.CollectUserEventRequest} message CollectUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CollectUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = ""; + object.uri = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.ets = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.ets = options.longs === String ? "0" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = message.userEvent; + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.ets != null && message.hasOwnProperty("ets")) + if (typeof message.ets === "number") + object.ets = options.longs === String ? String(message.ets) : message.ets; + else + object.ets = options.longs === String ? $util.Long.prototype.toString.call(message.ets) : options.longs === Number ? new $util.LongBits(message.ets.low >>> 0, message.ets.high >>> 0).toNumber() : message.ets; + return object; + }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + CollectUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CollectUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.CollectUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CollectUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.CollectUserEventRequest"; + }; + + return CollectUserEventRequest; + })(); + + v2alpha.RejoinUserEventsRequest = (function() { + + /** + * Properties of a RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @interface IRejoinUserEventsRequest + * @property {string|null} [parent] RejoinUserEventsRequest parent + * @property {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope|null} [userEventRejoinScope] RejoinUserEventsRequest userEventRejoinScope + */ + + /** + * Constructs a new RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RejoinUserEventsRequest. + * @implements IRejoinUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest=} [properties] Properties to set + */ + function RejoinUserEventsRequest(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]]; + } + + /** + * RejoinUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.parent = ""; + + /** + * RejoinUserEventsRequest userEventRejoinScope. + * @member {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} userEventRejoinScope + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.userEventRejoinScope = 0; + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsRequest} RejoinUserEventsRequest instance + */ + RejoinUserEventsRequest.create = function create(properties) { + return new RejoinUserEventsRequest(properties); + }; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEventRejoinScope != null && Object.hasOwnProperty.call(message, "userEventRejoinScope")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.userEventRejoinScope); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.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.cloud.retail.v2alpha.RejoinUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEventRejoinScope = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + switch (message.userEventRejoinScope) { + default: + return "userEventRejoinScope: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsRequest} RejoinUserEventsRequest + */ + RejoinUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RejoinUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2alpha.RejoinUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + switch (object.userEventRejoinScope) { + default: + if (typeof object.userEventRejoinScope === "number") { + message.userEventRejoinScope = object.userEventRejoinScope; + break; + } + break; + case "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": + case 0: + message.userEventRejoinScope = 0; + break; + case "JOINED_EVENTS": + case 1: + message.userEventRejoinScope = 1; + break; + case "UNJOINED_EVENTS": + case 2: + message.userEventRejoinScope = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest} message RejoinUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEventRejoinScope = options.enums === String ? "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + object.userEventRejoinScope = options.enums === String ? $root.google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] === undefined ? message.userEventRejoinScope : $root.google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] : message.userEventRejoinScope; + return object; + }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RejoinUserEventsRequest"; + }; + + /** + * UserEventRejoinScope enum. + * @name google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope + * @enum {number} + * @property {number} USER_EVENT_REJOIN_SCOPE_UNSPECIFIED=0 USER_EVENT_REJOIN_SCOPE_UNSPECIFIED value + * @property {number} JOINED_EVENTS=1 JOINED_EVENTS value + * @property {number} UNJOINED_EVENTS=2 UNJOINED_EVENTS value + */ + RejoinUserEventsRequest.UserEventRejoinScope = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "JOINED_EVENTS"] = 1; + values[valuesById[2] = "UNJOINED_EVENTS"] = 2; + return values; + })(); + + return RejoinUserEventsRequest; + })(); + + v2alpha.RejoinUserEventsResponse = (function() { + + /** + * Properties of a RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @interface IRejoinUserEventsResponse + * @property {number|Long|null} [rejoinedUserEventsCount] RejoinUserEventsResponse rejoinedUserEventsCount + */ + + /** + * Constructs a new RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RejoinUserEventsResponse. + * @implements IRejoinUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsResponse=} [properties] Properties to set + */ + function RejoinUserEventsResponse(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]]; + } + + /** + * RejoinUserEventsResponse rejoinedUserEventsCount. + * @member {number|Long} rejoinedUserEventsCount + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @instance + */ + RejoinUserEventsResponse.prototype.rejoinedUserEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsResponse} RejoinUserEventsResponse instance + */ + RejoinUserEventsResponse.create = function create(properties) { + return new RejoinUserEventsResponse(properties); + }; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rejoinedUserEventsCount != null && Object.hasOwnProperty.call(message, "rejoinedUserEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.rejoinedUserEventsCount); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.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.cloud.retail.v2alpha.RejoinUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.rejoinedUserEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (!$util.isInteger(message.rejoinedUserEventsCount) && !(message.rejoinedUserEventsCount && $util.isInteger(message.rejoinedUserEventsCount.low) && $util.isInteger(message.rejoinedUserEventsCount.high))) + return "rejoinedUserEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsResponse} RejoinUserEventsResponse + */ + RejoinUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RejoinUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2alpha.RejoinUserEventsResponse(); + if (object.rejoinedUserEventsCount != null) + if ($util.Long) + (message.rejoinedUserEventsCount = $util.Long.fromValue(object.rejoinedUserEventsCount)).unsigned = false; + else if (typeof object.rejoinedUserEventsCount === "string") + message.rejoinedUserEventsCount = parseInt(object.rejoinedUserEventsCount, 10); + else if (typeof object.rejoinedUserEventsCount === "number") + message.rejoinedUserEventsCount = object.rejoinedUserEventsCount; + else if (typeof object.rejoinedUserEventsCount === "object") + message.rejoinedUserEventsCount = new $util.LongBits(object.rejoinedUserEventsCount.low >>> 0, object.rejoinedUserEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2alpha.RejoinUserEventsResponse} message RejoinUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsResponse.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.rejoinedUserEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.rejoinedUserEventsCount = options.longs === String ? "0" : 0; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (typeof message.rejoinedUserEventsCount === "number") + object.rejoinedUserEventsCount = options.longs === String ? String(message.rejoinedUserEventsCount) : message.rejoinedUserEventsCount; + else + object.rejoinedUserEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.rejoinedUserEventsCount) : options.longs === Number ? new $util.LongBits(message.rejoinedUserEventsCount.low >>> 0, message.rejoinedUserEventsCount.high >>> 0).toNumber() : message.rejoinedUserEventsCount; + return object; + }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RejoinUserEventsResponse"; + }; + + return RejoinUserEventsResponse; + })(); + + v2alpha.RejoinUserEventsMetadata = (function() { + + /** + * Properties of a RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2alpha + * @interface IRejoinUserEventsMetadata + */ + + /** + * Constructs a new RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2alpha + * @classdesc Represents a RejoinUserEventsMetadata. + * @implements IRejoinUserEventsMetadata + * @constructor + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsMetadata=} [properties] Properties to set + */ + function RejoinUserEventsMetadata(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 RejoinUserEventsMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsMetadata} RejoinUserEventsMetadata instance + */ + RejoinUserEventsMetadata.create = function create(properties) { + return new RejoinUserEventsMetadata(properties); + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2alpha.RejoinUserEventsMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2alpha.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.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.cloud.retail.v2alpha.RejoinUserEventsMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsMetadata message. + * @function verify + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2alpha.RejoinUserEventsMetadata} RejoinUserEventsMetadata + */ + RejoinUserEventsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2alpha.RejoinUserEventsMetadata) + return object; + return new $root.google.cloud.retail.v2alpha.RejoinUserEventsMetadata(); + }; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2alpha.RejoinUserEventsMetadata} message RejoinUserEventsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2alpha.RejoinUserEventsMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2alpha.RejoinUserEventsMetadata"; + }; + + return RejoinUserEventsMetadata; + })(); + + return v2alpha; + })(); + + retail.v2beta = (function() { + + /** + * Namespace v2beta. + * @memberof google.cloud.retail + * @namespace + */ + var v2beta = {}; + + v2beta.ProductLevelConfig = (function() { + + /** + * Properties of a ProductLevelConfig. + * @memberof google.cloud.retail.v2beta + * @interface IProductLevelConfig + * @property {string|null} [ingestionProductType] ProductLevelConfig ingestionProductType + * @property {string|null} [merchantCenterProductIdField] ProductLevelConfig merchantCenterProductIdField + */ + + /** + * Constructs a new ProductLevelConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ProductLevelConfig. + * @implements IProductLevelConfig + * @constructor + * @param {google.cloud.retail.v2beta.IProductLevelConfig=} [properties] Properties to set + */ + function ProductLevelConfig(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]]; + } + + /** + * ProductLevelConfig ingestionProductType. + * @member {string} ingestionProductType + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.ingestionProductType = ""; + + /** + * ProductLevelConfig merchantCenterProductIdField. + * @member {string} merchantCenterProductIdField + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @instance + */ + ProductLevelConfig.prototype.merchantCenterProductIdField = ""; + + /** + * Creates a new ProductLevelConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2beta.IProductLevelConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ProductLevelConfig} ProductLevelConfig instance + */ + ProductLevelConfig.create = function create(properties) { + return new ProductLevelConfig(properties); + }; + + /** + * Encodes the specified ProductLevelConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ProductLevelConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2beta.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ingestionProductType != null && Object.hasOwnProperty.call(message, "ingestionProductType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ingestionProductType); + if (message.merchantCenterProductIdField != null && Object.hasOwnProperty.call(message, "merchantCenterProductIdField")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.merchantCenterProductIdField); + return writer; + }; + + /** + * Encodes the specified ProductLevelConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductLevelConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2beta.IProductLevelConfig} message ProductLevelConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductLevelConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.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.cloud.retail.v2beta.ProductLevelConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ingestionProductType = reader.string(); + break; + } + case 2: { + message.merchantCenterProductIdField = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductLevelConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ProductLevelConfig} ProductLevelConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductLevelConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductLevelConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductLevelConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + if (!$util.isString(message.ingestionProductType)) + return "ingestionProductType: string expected"; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + if (!$util.isString(message.merchantCenterProductIdField)) + return "merchantCenterProductIdField: string expected"; + return null; + }; + + /** + * Creates a ProductLevelConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ProductLevelConfig} ProductLevelConfig + */ + ProductLevelConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ProductLevelConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.ProductLevelConfig(); + if (object.ingestionProductType != null) + message.ingestionProductType = String(object.ingestionProductType); + if (object.merchantCenterProductIdField != null) + message.merchantCenterProductIdField = String(object.merchantCenterProductIdField); + return message; + }; + + /** + * Creates a plain object from a ProductLevelConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {google.cloud.retail.v2beta.ProductLevelConfig} message ProductLevelConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductLevelConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.ingestionProductType = ""; + object.merchantCenterProductIdField = ""; + } + if (message.ingestionProductType != null && message.hasOwnProperty("ingestionProductType")) + object.ingestionProductType = message.ingestionProductType; + if (message.merchantCenterProductIdField != null && message.hasOwnProperty("merchantCenterProductIdField")) + object.merchantCenterProductIdField = message.merchantCenterProductIdField; + return object; + }; + + /** + * Converts this ProductLevelConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @instance + * @returns {Object.} JSON object + */ + ProductLevelConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductLevelConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ProductLevelConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductLevelConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ProductLevelConfig"; + }; + + return ProductLevelConfig; + })(); + + v2beta.CatalogAttribute = (function() { + + /** + * Properties of a CatalogAttribute. + * @memberof google.cloud.retail.v2beta + * @interface ICatalogAttribute + * @property {string|null} [key] CatalogAttribute key + * @property {boolean|null} [inUse] CatalogAttribute inUse + * @property {google.cloud.retail.v2beta.CatalogAttribute.AttributeType|null} [type] CatalogAttribute type + * @property {google.cloud.retail.v2beta.CatalogAttribute.IndexableOption|null} [indexableOption] CatalogAttribute indexableOption + * @property {google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption|null} [dynamicFacetableOption] CatalogAttribute dynamicFacetableOption + * @property {google.cloud.retail.v2beta.CatalogAttribute.SearchableOption|null} [searchableOption] CatalogAttribute searchableOption + * @property {google.cloud.retail.v2beta.RecommendationsFilteringOption|null} [recommendationsFilteringOption] CatalogAttribute recommendationsFilteringOption + * @property {google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption|null} [exactSearchableOption] CatalogAttribute exactSearchableOption + */ + + /** + * Constructs a new CatalogAttribute. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CatalogAttribute. + * @implements ICatalogAttribute + * @constructor + * @param {google.cloud.retail.v2beta.ICatalogAttribute=} [properties] Properties to set + */ + function CatalogAttribute(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]]; + } + + /** + * CatalogAttribute key. + * @member {string} key + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.key = ""; + + /** + * CatalogAttribute inUse. + * @member {boolean} inUse + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.inUse = false; + + /** + * CatalogAttribute type. + * @member {google.cloud.retail.v2beta.CatalogAttribute.AttributeType} type + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.type = 0; + + /** + * CatalogAttribute indexableOption. + * @member {google.cloud.retail.v2beta.CatalogAttribute.IndexableOption} indexableOption + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.indexableOption = 0; + + /** + * CatalogAttribute dynamicFacetableOption. + * @member {google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption} dynamicFacetableOption + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.dynamicFacetableOption = 0; + + /** + * CatalogAttribute searchableOption. + * @member {google.cloud.retail.v2beta.CatalogAttribute.SearchableOption} searchableOption + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.searchableOption = 0; + + /** + * CatalogAttribute recommendationsFilteringOption. + * @member {google.cloud.retail.v2beta.RecommendationsFilteringOption} recommendationsFilteringOption + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.recommendationsFilteringOption = 0; + + /** + * CatalogAttribute exactSearchableOption. + * @member {google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption} exactSearchableOption + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + */ + CatalogAttribute.prototype.exactSearchableOption = 0; + + /** + * Creates a new CatalogAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {google.cloud.retail.v2beta.ICatalogAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CatalogAttribute} CatalogAttribute instance + */ + CatalogAttribute.create = function create(properties) { + return new CatalogAttribute(properties); + }; + + /** + * Encodes the specified CatalogAttribute message. Does not implicitly {@link google.cloud.retail.v2beta.CatalogAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {google.cloud.retail.v2beta.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.indexableOption != null && Object.hasOwnProperty.call(message, "indexableOption")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.indexableOption); + if (message.dynamicFacetableOption != null && Object.hasOwnProperty.call(message, "dynamicFacetableOption")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.dynamicFacetableOption); + if (message.searchableOption != null && Object.hasOwnProperty.call(message, "searchableOption")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.searchableOption); + if (message.recommendationsFilteringOption != null && Object.hasOwnProperty.call(message, "recommendationsFilteringOption")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.recommendationsFilteringOption); + if (message.inUse != null && Object.hasOwnProperty.call(message, "inUse")) + writer.uint32(/* id 9, wireType 0 =*/72).bool(message.inUse); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.type); + if (message.exactSearchableOption != null && Object.hasOwnProperty.call(message, "exactSearchableOption")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.exactSearchableOption); + return writer; + }; + + /** + * Encodes the specified CatalogAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CatalogAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {google.cloud.retail.v2beta.ICatalogAttribute} message CatalogAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CatalogAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.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.cloud.retail.v2beta.CatalogAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 9: { + message.inUse = reader.bool(); + break; + } + case 10: { + message.type = reader.int32(); + break; + } + case 5: { + message.indexableOption = reader.int32(); + break; + } + case 6: { + message.dynamicFacetableOption = reader.int32(); + break; + } + case 7: { + message.searchableOption = reader.int32(); + break; + } + case 8: { + message.recommendationsFilteringOption = reader.int32(); + break; + } + case 11: { + message.exactSearchableOption = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CatalogAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CatalogAttribute} CatalogAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CatalogAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CatalogAttribute message. + * @function verify + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CatalogAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.inUse != null && message.hasOwnProperty("inUse")) + if (typeof message.inUse !== "boolean") + return "inUse: boolean expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + switch (message.indexableOption) { + default: + return "indexableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + switch (message.dynamicFacetableOption) { + default: + return "dynamicFacetableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + switch (message.searchableOption) { + default: + return "searchableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.recommendationsFilteringOption != null && message.hasOwnProperty("recommendationsFilteringOption")) + switch (message.recommendationsFilteringOption) { + default: + return "recommendationsFilteringOption: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.exactSearchableOption != null && message.hasOwnProperty("exactSearchableOption")) + switch (message.exactSearchableOption) { + default: + return "exactSearchableOption: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a CatalogAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CatalogAttribute} CatalogAttribute + */ + CatalogAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CatalogAttribute) + return object; + var message = new $root.google.cloud.retail.v2beta.CatalogAttribute(); + if (object.key != null) + message.key = String(object.key); + if (object.inUse != null) + message.inUse = Boolean(object.inUse); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "UNKNOWN": + case 0: + message.type = 0; + break; + case "TEXTUAL": + case 1: + message.type = 1; + break; + case "NUMERICAL": + case 2: + message.type = 2; + break; + } + switch (object.indexableOption) { + default: + if (typeof object.indexableOption === "number") { + message.indexableOption = object.indexableOption; + break; + } + break; + case "INDEXABLE_OPTION_UNSPECIFIED": + case 0: + message.indexableOption = 0; + break; + case "INDEXABLE_ENABLED": + case 1: + message.indexableOption = 1; + break; + case "INDEXABLE_DISABLED": + case 2: + message.indexableOption = 2; + break; + } + switch (object.dynamicFacetableOption) { + default: + if (typeof object.dynamicFacetableOption === "number") { + message.dynamicFacetableOption = object.dynamicFacetableOption; + break; + } + break; + case "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": + case 0: + message.dynamicFacetableOption = 0; + break; + case "DYNAMIC_FACETABLE_ENABLED": + case 1: + message.dynamicFacetableOption = 1; + break; + case "DYNAMIC_FACETABLE_DISABLED": + case 2: + message.dynamicFacetableOption = 2; + break; + } + switch (object.searchableOption) { + default: + if (typeof object.searchableOption === "number") { + message.searchableOption = object.searchableOption; + break; + } + break; + case "SEARCHABLE_OPTION_UNSPECIFIED": + case 0: + message.searchableOption = 0; + break; + case "SEARCHABLE_ENABLED": + case 1: + message.searchableOption = 1; + break; + case "SEARCHABLE_DISABLED": + case 2: + message.searchableOption = 2; + break; + } + switch (object.recommendationsFilteringOption) { + default: + if (typeof object.recommendationsFilteringOption === "number") { + message.recommendationsFilteringOption = object.recommendationsFilteringOption; + break; + } + break; + case "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": + case 0: + message.recommendationsFilteringOption = 0; + break; + case "RECOMMENDATIONS_FILTERING_DISABLED": + case 1: + message.recommendationsFilteringOption = 1; + break; + case "RECOMMENDATIONS_FILTERING_ENABLED": + case 3: + message.recommendationsFilteringOption = 3; + break; + } + switch (object.exactSearchableOption) { + default: + if (typeof object.exactSearchableOption === "number") { + message.exactSearchableOption = object.exactSearchableOption; + break; + } + break; + case "EXACT_SEARCHABLE_OPTION_UNSPECIFIED": + case 0: + message.exactSearchableOption = 0; + break; + case "EXACT_SEARCHABLE_ENABLED": + case 1: + message.exactSearchableOption = 1; + break; + case "EXACT_SEARCHABLE_DISABLED": + case 2: + message.exactSearchableOption = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a CatalogAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {google.cloud.retail.v2beta.CatalogAttribute} message CatalogAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CatalogAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.key = ""; + object.indexableOption = options.enums === String ? "INDEXABLE_OPTION_UNSPECIFIED" : 0; + object.dynamicFacetableOption = options.enums === String ? "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED" : 0; + object.searchableOption = options.enums === String ? "SEARCHABLE_OPTION_UNSPECIFIED" : 0; + object.recommendationsFilteringOption = options.enums === String ? "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED" : 0; + object.inUse = false; + object.type = options.enums === String ? "UNKNOWN" : 0; + object.exactSearchableOption = options.enums === String ? "EXACT_SEARCHABLE_OPTION_UNSPECIFIED" : 0; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.indexableOption != null && message.hasOwnProperty("indexableOption")) + object.indexableOption = options.enums === String ? $root.google.cloud.retail.v2beta.CatalogAttribute.IndexableOption[message.indexableOption] === undefined ? message.indexableOption : $root.google.cloud.retail.v2beta.CatalogAttribute.IndexableOption[message.indexableOption] : message.indexableOption; + if (message.dynamicFacetableOption != null && message.hasOwnProperty("dynamicFacetableOption")) + object.dynamicFacetableOption = options.enums === String ? $root.google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] === undefined ? message.dynamicFacetableOption : $root.google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption[message.dynamicFacetableOption] : message.dynamicFacetableOption; + if (message.searchableOption != null && message.hasOwnProperty("searchableOption")) + object.searchableOption = options.enums === String ? $root.google.cloud.retail.v2beta.CatalogAttribute.SearchableOption[message.searchableOption] === undefined ? message.searchableOption : $root.google.cloud.retail.v2beta.CatalogAttribute.SearchableOption[message.searchableOption] : message.searchableOption; + if (message.recommendationsFilteringOption != null && message.hasOwnProperty("recommendationsFilteringOption")) + object.recommendationsFilteringOption = options.enums === String ? $root.google.cloud.retail.v2beta.RecommendationsFilteringOption[message.recommendationsFilteringOption] === undefined ? message.recommendationsFilteringOption : $root.google.cloud.retail.v2beta.RecommendationsFilteringOption[message.recommendationsFilteringOption] : message.recommendationsFilteringOption; + if (message.inUse != null && message.hasOwnProperty("inUse")) + object.inUse = message.inUse; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2beta.CatalogAttribute.AttributeType[message.type] === undefined ? message.type : $root.google.cloud.retail.v2beta.CatalogAttribute.AttributeType[message.type] : message.type; + if (message.exactSearchableOption != null && message.hasOwnProperty("exactSearchableOption")) + object.exactSearchableOption = options.enums === String ? $root.google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption[message.exactSearchableOption] === undefined ? message.exactSearchableOption : $root.google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption[message.exactSearchableOption] : message.exactSearchableOption; + return object; + }; + + /** + * Converts this CatalogAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @instance + * @returns {Object.} JSON object + */ + CatalogAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CatalogAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CatalogAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CatalogAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CatalogAttribute"; + }; + + /** + * AttributeType enum. + * @name google.cloud.retail.v2beta.CatalogAttribute.AttributeType + * @enum {number} + * @property {number} UNKNOWN=0 UNKNOWN value + * @property {number} TEXTUAL=1 TEXTUAL value + * @property {number} NUMERICAL=2 NUMERICAL value + */ + CatalogAttribute.AttributeType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN"] = 0; + values[valuesById[1] = "TEXTUAL"] = 1; + values[valuesById[2] = "NUMERICAL"] = 2; + return values; + })(); + + /** + * IndexableOption enum. + * @name google.cloud.retail.v2beta.CatalogAttribute.IndexableOption + * @enum {number} + * @property {number} INDEXABLE_OPTION_UNSPECIFIED=0 INDEXABLE_OPTION_UNSPECIFIED value + * @property {number} INDEXABLE_ENABLED=1 INDEXABLE_ENABLED value + * @property {number} INDEXABLE_DISABLED=2 INDEXABLE_DISABLED value + */ + CatalogAttribute.IndexableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "INDEXABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "INDEXABLE_ENABLED"] = 1; + values[valuesById[2] = "INDEXABLE_DISABLED"] = 2; + return values; + })(); + + /** + * DynamicFacetableOption enum. + * @name google.cloud.retail.v2beta.CatalogAttribute.DynamicFacetableOption + * @enum {number} + * @property {number} DYNAMIC_FACETABLE_OPTION_UNSPECIFIED=0 DYNAMIC_FACETABLE_OPTION_UNSPECIFIED value + * @property {number} DYNAMIC_FACETABLE_ENABLED=1 DYNAMIC_FACETABLE_ENABLED value + * @property {number} DYNAMIC_FACETABLE_DISABLED=2 DYNAMIC_FACETABLE_DISABLED value + */ + CatalogAttribute.DynamicFacetableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DYNAMIC_FACETABLE_ENABLED"] = 1; + values[valuesById[2] = "DYNAMIC_FACETABLE_DISABLED"] = 2; + return values; + })(); + + /** + * SearchableOption enum. + * @name google.cloud.retail.v2beta.CatalogAttribute.SearchableOption + * @enum {number} + * @property {number} SEARCHABLE_OPTION_UNSPECIFIED=0 SEARCHABLE_OPTION_UNSPECIFIED value + * @property {number} SEARCHABLE_ENABLED=1 SEARCHABLE_ENABLED value + * @property {number} SEARCHABLE_DISABLED=2 SEARCHABLE_DISABLED value + */ + CatalogAttribute.SearchableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCHABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCHABLE_ENABLED"] = 1; + values[valuesById[2] = "SEARCHABLE_DISABLED"] = 2; + return values; + })(); + + /** + * ExactSearchableOption enum. + * @name google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption + * @enum {number} + * @property {number} EXACT_SEARCHABLE_OPTION_UNSPECIFIED=0 EXACT_SEARCHABLE_OPTION_UNSPECIFIED value + * @property {number} EXACT_SEARCHABLE_ENABLED=1 EXACT_SEARCHABLE_ENABLED value + * @property {number} EXACT_SEARCHABLE_DISABLED=2 EXACT_SEARCHABLE_DISABLED value + */ + CatalogAttribute.ExactSearchableOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "EXACT_SEARCHABLE_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "EXACT_SEARCHABLE_ENABLED"] = 1; + values[valuesById[2] = "EXACT_SEARCHABLE_DISABLED"] = 2; + return values; + })(); + + return CatalogAttribute; + })(); + + v2beta.AttributesConfig = (function() { + + /** + * Properties of an AttributesConfig. + * @memberof google.cloud.retail.v2beta + * @interface IAttributesConfig + * @property {string|null} [name] AttributesConfig name + * @property {Object.|null} [catalogAttributes] AttributesConfig catalogAttributes + * @property {google.cloud.retail.v2beta.AttributeConfigLevel|null} [attributeConfigLevel] AttributesConfig attributeConfigLevel + */ + + /** + * Constructs a new AttributesConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AttributesConfig. + * @implements IAttributesConfig + * @constructor + * @param {google.cloud.retail.v2beta.IAttributesConfig=} [properties] Properties to set + */ + function AttributesConfig(properties) { + this.catalogAttributes = {}; + 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]]; + } + + /** + * AttributesConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @instance + */ + AttributesConfig.prototype.name = ""; + + /** + * AttributesConfig catalogAttributes. + * @member {Object.} catalogAttributes + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @instance + */ + AttributesConfig.prototype.catalogAttributes = $util.emptyObject; + + /** + * AttributesConfig attributeConfigLevel. + * @member {google.cloud.retail.v2beta.AttributeConfigLevel} attributeConfigLevel + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @instance + */ + AttributesConfig.prototype.attributeConfigLevel = 0; + + /** + * Creates a new AttributesConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {google.cloud.retail.v2beta.IAttributesConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AttributesConfig} AttributesConfig instance + */ + AttributesConfig.create = function create(properties) { + return new AttributesConfig(properties); + }; + + /** + * Encodes the specified AttributesConfig message. Does not implicitly {@link google.cloud.retail.v2beta.AttributesConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {google.cloud.retail.v2beta.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.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.catalogAttributes != null && Object.hasOwnProperty.call(message, "catalogAttributes")) + for (var keys = Object.keys(message.catalogAttributes), 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.cloud.retail.v2beta.CatalogAttribute.encode(message.catalogAttributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.attributeConfigLevel != null && Object.hasOwnProperty.call(message, "attributeConfigLevel")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.attributeConfigLevel); + return writer; + }; + + /** + * Encodes the specified AttributesConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AttributesConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {google.cloud.retail.v2beta.IAttributesConfig} message AttributesConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AttributesConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.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.cloud.retail.v2beta.AttributesConfig(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (message.catalogAttributes === $util.emptyObject) + message.catalogAttributes = {}; + 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.cloud.retail.v2beta.CatalogAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.catalogAttributes[key] = value; + break; + } + case 3: { + message.attributeConfigLevel = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AttributesConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AttributesConfig} AttributesConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AttributesConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AttributesConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AttributesConfig.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.catalogAttributes != null && message.hasOwnProperty("catalogAttributes")) { + if (!$util.isObject(message.catalogAttributes)) + return "catalogAttributes: object expected"; + var key = Object.keys(message.catalogAttributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CatalogAttribute.verify(message.catalogAttributes[key[i]]); + if (error) + return "catalogAttributes." + error; + } + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + switch (message.attributeConfigLevel) { + default: + return "attributeConfigLevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an AttributesConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AttributesConfig} AttributesConfig + */ + AttributesConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AttributesConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.AttributesConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.catalogAttributes) { + if (typeof object.catalogAttributes !== "object") + throw TypeError(".google.cloud.retail.v2beta.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes = {}; + for (var keys = Object.keys(object.catalogAttributes), i = 0; i < keys.length; ++i) { + if (typeof object.catalogAttributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.AttributesConfig.catalogAttributes: object expected"); + message.catalogAttributes[keys[i]] = $root.google.cloud.retail.v2beta.CatalogAttribute.fromObject(object.catalogAttributes[keys[i]]); + } + } + switch (object.attributeConfigLevel) { + default: + if (typeof object.attributeConfigLevel === "number") { + message.attributeConfigLevel = object.attributeConfigLevel; + break; + } + break; + case "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": + case 0: + message.attributeConfigLevel = 0; + break; + case "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": + case 1: + message.attributeConfigLevel = 1; + break; + case "CATALOG_LEVEL_ATTRIBUTE_CONFIG": + case 2: + message.attributeConfigLevel = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an AttributesConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {google.cloud.retail.v2beta.AttributesConfig} message AttributesConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AttributesConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.catalogAttributes = {}; + if (options.defaults) { + object.name = ""; + object.attributeConfigLevel = options.enums === String ? "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + var keys2; + if (message.catalogAttributes && (keys2 = Object.keys(message.catalogAttributes)).length) { + object.catalogAttributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.catalogAttributes[keys2[j]] = $root.google.cloud.retail.v2beta.CatalogAttribute.toObject(message.catalogAttributes[keys2[j]], options); + } + if (message.attributeConfigLevel != null && message.hasOwnProperty("attributeConfigLevel")) + object.attributeConfigLevel = options.enums === String ? $root.google.cloud.retail.v2beta.AttributeConfigLevel[message.attributeConfigLevel] === undefined ? message.attributeConfigLevel : $root.google.cloud.retail.v2beta.AttributeConfigLevel[message.attributeConfigLevel] : message.attributeConfigLevel; + return object; + }; + + /** + * Converts this AttributesConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @instance + * @returns {Object.} JSON object + */ + AttributesConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AttributesConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AttributesConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AttributesConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AttributesConfig"; + }; + + return AttributesConfig; + })(); + + v2beta.CompletionConfig = (function() { + + /** + * Properties of a CompletionConfig. + * @memberof google.cloud.retail.v2beta + * @interface ICompletionConfig + * @property {string|null} [name] CompletionConfig name + * @property {string|null} [matchingOrder] CompletionConfig matchingOrder + * @property {number|null} [maxSuggestions] CompletionConfig maxSuggestions + * @property {number|null} [minPrefixLength] CompletionConfig minPrefixLength + * @property {boolean|null} [autoLearning] CompletionConfig autoLearning + * @property {google.cloud.retail.v2beta.ICompletionDataInputConfig|null} [suggestionsInputConfig] CompletionConfig suggestionsInputConfig + * @property {string|null} [lastSuggestionsImportOperation] CompletionConfig lastSuggestionsImportOperation + * @property {google.cloud.retail.v2beta.ICompletionDataInputConfig|null} [denylistInputConfig] CompletionConfig denylistInputConfig + * @property {string|null} [lastDenylistImportOperation] CompletionConfig lastDenylistImportOperation + * @property {google.cloud.retail.v2beta.ICompletionDataInputConfig|null} [allowlistInputConfig] CompletionConfig allowlistInputConfig + * @property {string|null} [lastAllowlistImportOperation] CompletionConfig lastAllowlistImportOperation + */ + + /** + * Constructs a new CompletionConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompletionConfig. + * @implements ICompletionConfig + * @constructor + * @param {google.cloud.retail.v2beta.ICompletionConfig=} [properties] Properties to set + */ + function CompletionConfig(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]]; + } + + /** + * CompletionConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.name = ""; + + /** + * CompletionConfig matchingOrder. + * @member {string} matchingOrder + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.matchingOrder = ""; + + /** + * CompletionConfig maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.maxSuggestions = 0; + + /** + * CompletionConfig minPrefixLength. + * @member {number} minPrefixLength + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.minPrefixLength = 0; + + /** + * CompletionConfig autoLearning. + * @member {boolean} autoLearning + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.autoLearning = false; + + /** + * CompletionConfig suggestionsInputConfig. + * @member {google.cloud.retail.v2beta.ICompletionDataInputConfig|null|undefined} suggestionsInputConfig + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.suggestionsInputConfig = null; + + /** + * CompletionConfig lastSuggestionsImportOperation. + * @member {string} lastSuggestionsImportOperation + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastSuggestionsImportOperation = ""; + + /** + * CompletionConfig denylistInputConfig. + * @member {google.cloud.retail.v2beta.ICompletionDataInputConfig|null|undefined} denylistInputConfig + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.denylistInputConfig = null; + + /** + * CompletionConfig lastDenylistImportOperation. + * @member {string} lastDenylistImportOperation + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastDenylistImportOperation = ""; + + /** + * CompletionConfig allowlistInputConfig. + * @member {google.cloud.retail.v2beta.ICompletionDataInputConfig|null|undefined} allowlistInputConfig + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.allowlistInputConfig = null; + + /** + * CompletionConfig lastAllowlistImportOperation. + * @member {string} lastAllowlistImportOperation + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + */ + CompletionConfig.prototype.lastAllowlistImportOperation = ""; + + /** + * Creates a new CompletionConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompletionConfig} CompletionConfig instance + */ + CompletionConfig.create = function create(properties) { + return new CompletionConfig(properties); + }; + + /** + * Encodes the specified CompletionConfig message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.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.matchingOrder != null && Object.hasOwnProperty.call(message, "matchingOrder")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.matchingOrder); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.maxSuggestions); + if (message.minPrefixLength != null && Object.hasOwnProperty.call(message, "minPrefixLength")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.minPrefixLength); + if (message.suggestionsInputConfig != null && Object.hasOwnProperty.call(message, "suggestionsInputConfig")) + $root.google.cloud.retail.v2beta.CompletionDataInputConfig.encode(message.suggestionsInputConfig, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.lastSuggestionsImportOperation != null && Object.hasOwnProperty.call(message, "lastSuggestionsImportOperation")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.lastSuggestionsImportOperation); + if (message.denylistInputConfig != null && Object.hasOwnProperty.call(message, "denylistInputConfig")) + $root.google.cloud.retail.v2beta.CompletionDataInputConfig.encode(message.denylistInputConfig, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.lastDenylistImportOperation != null && Object.hasOwnProperty.call(message, "lastDenylistImportOperation")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.lastDenylistImportOperation); + if (message.allowlistInputConfig != null && Object.hasOwnProperty.call(message, "allowlistInputConfig")) + $root.google.cloud.retail.v2beta.CompletionDataInputConfig.encode(message.allowlistInputConfig, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.lastAllowlistImportOperation != null && Object.hasOwnProperty.call(message, "lastAllowlistImportOperation")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.lastAllowlistImportOperation); + if (message.autoLearning != null && Object.hasOwnProperty.call(message, "autoLearning")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.autoLearning); + return writer; + }; + + /** + * Encodes the specified CompletionConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionConfig} message CompletionConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.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.cloud.retail.v2beta.CompletionConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.matchingOrder = reader.string(); + break; + } + case 3: { + message.maxSuggestions = reader.int32(); + break; + } + case 4: { + message.minPrefixLength = reader.int32(); + break; + } + case 11: { + message.autoLearning = reader.bool(); + break; + } + case 5: { + message.suggestionsInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 6: { + message.lastSuggestionsImportOperation = reader.string(); + break; + } + case 7: { + message.denylistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 8: { + message.lastDenylistImportOperation = reader.string(); + break; + } + case 9: { + message.allowlistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 10: { + message.lastAllowlistImportOperation = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompletionConfig} CompletionConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionConfig.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.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + if (!$util.isString(message.matchingOrder)) + return "matchingOrder: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + if (!$util.isInteger(message.minPrefixLength)) + return "minPrefixLength: integer expected"; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + if (typeof message.autoLearning !== "boolean") + return "autoLearning: boolean expected"; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) { + var error = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.verify(message.suggestionsInputConfig); + if (error) + return "suggestionsInputConfig." + error; + } + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + if (!$util.isString(message.lastSuggestionsImportOperation)) + return "lastSuggestionsImportOperation: string expected"; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) { + var error = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.verify(message.denylistInputConfig); + if (error) + return "denylistInputConfig." + error; + } + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + if (!$util.isString(message.lastDenylistImportOperation)) + return "lastDenylistImportOperation: string expected"; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) { + var error = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.verify(message.allowlistInputConfig); + if (error) + return "allowlistInputConfig." + error; + } + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + if (!$util.isString(message.lastAllowlistImportOperation)) + return "lastAllowlistImportOperation: string expected"; + return null; + }; + + /** + * Creates a CompletionConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompletionConfig} CompletionConfig + */ + CompletionConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompletionConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.CompletionConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.matchingOrder != null) + message.matchingOrder = String(object.matchingOrder); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + if (object.minPrefixLength != null) + message.minPrefixLength = object.minPrefixLength | 0; + if (object.autoLearning != null) + message.autoLearning = Boolean(object.autoLearning); + if (object.suggestionsInputConfig != null) { + if (typeof object.suggestionsInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompletionConfig.suggestionsInputConfig: object expected"); + message.suggestionsInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.fromObject(object.suggestionsInputConfig); + } + if (object.lastSuggestionsImportOperation != null) + message.lastSuggestionsImportOperation = String(object.lastSuggestionsImportOperation); + if (object.denylistInputConfig != null) { + if (typeof object.denylistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompletionConfig.denylistInputConfig: object expected"); + message.denylistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.fromObject(object.denylistInputConfig); + } + if (object.lastDenylistImportOperation != null) + message.lastDenylistImportOperation = String(object.lastDenylistImportOperation); + if (object.allowlistInputConfig != null) { + if (typeof object.allowlistInputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompletionConfig.allowlistInputConfig: object expected"); + message.allowlistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.fromObject(object.allowlistInputConfig); + } + if (object.lastAllowlistImportOperation != null) + message.lastAllowlistImportOperation = String(object.lastAllowlistImportOperation); + return message; + }; + + /** + * Creates a plain object from a CompletionConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {google.cloud.retail.v2beta.CompletionConfig} message CompletionConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.matchingOrder = ""; + object.maxSuggestions = 0; + object.minPrefixLength = 0; + object.suggestionsInputConfig = null; + object.lastSuggestionsImportOperation = ""; + object.denylistInputConfig = null; + object.lastDenylistImportOperation = ""; + object.allowlistInputConfig = null; + object.lastAllowlistImportOperation = ""; + object.autoLearning = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.matchingOrder != null && message.hasOwnProperty("matchingOrder")) + object.matchingOrder = message.matchingOrder; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.minPrefixLength != null && message.hasOwnProperty("minPrefixLength")) + object.minPrefixLength = message.minPrefixLength; + if (message.suggestionsInputConfig != null && message.hasOwnProperty("suggestionsInputConfig")) + object.suggestionsInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.toObject(message.suggestionsInputConfig, options); + if (message.lastSuggestionsImportOperation != null && message.hasOwnProperty("lastSuggestionsImportOperation")) + object.lastSuggestionsImportOperation = message.lastSuggestionsImportOperation; + if (message.denylistInputConfig != null && message.hasOwnProperty("denylistInputConfig")) + object.denylistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.toObject(message.denylistInputConfig, options); + if (message.lastDenylistImportOperation != null && message.hasOwnProperty("lastDenylistImportOperation")) + object.lastDenylistImportOperation = message.lastDenylistImportOperation; + if (message.allowlistInputConfig != null && message.hasOwnProperty("allowlistInputConfig")) + object.allowlistInputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.toObject(message.allowlistInputConfig, options); + if (message.lastAllowlistImportOperation != null && message.hasOwnProperty("lastAllowlistImportOperation")) + object.lastAllowlistImportOperation = message.lastAllowlistImportOperation; + if (message.autoLearning != null && message.hasOwnProperty("autoLearning")) + object.autoLearning = message.autoLearning; + return object; + }; + + /** + * Converts this CompletionConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompletionConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompletionConfig"; + }; + + return CompletionConfig; + })(); + + v2beta.MerchantCenterLink = (function() { + + /** + * Properties of a MerchantCenterLink. + * @memberof google.cloud.retail.v2beta + * @interface IMerchantCenterLink + * @property {number|Long|null} [merchantCenterAccountId] MerchantCenterLink merchantCenterAccountId + * @property {string|null} [branchId] MerchantCenterLink branchId + * @property {Array.|null} [destinations] MerchantCenterLink destinations + * @property {string|null} [regionCode] MerchantCenterLink regionCode + * @property {string|null} [languageCode] MerchantCenterLink languageCode + */ + + /** + * Constructs a new MerchantCenterLink. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a MerchantCenterLink. + * @implements IMerchantCenterLink + * @constructor + * @param {google.cloud.retail.v2beta.IMerchantCenterLink=} [properties] Properties to set + */ + function MerchantCenterLink(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]]; + } + + /** + * MerchantCenterLink merchantCenterAccountId. + * @member {number|Long} merchantCenterAccountId + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.merchantCenterAccountId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * MerchantCenterLink branchId. + * @member {string} branchId + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.branchId = ""; + + /** + * MerchantCenterLink destinations. + * @member {Array.} destinations + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.destinations = $util.emptyArray; + + /** + * MerchantCenterLink regionCode. + * @member {string} regionCode + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.regionCode = ""; + + /** + * MerchantCenterLink languageCode. + * @member {string} languageCode + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + */ + MerchantCenterLink.prototype.languageCode = ""; + + /** + * Creates a new MerchantCenterLink instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLink=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.MerchantCenterLink} MerchantCenterLink instance + */ + MerchantCenterLink.create = function create(properties) { + return new MerchantCenterLink(properties); + }; + + /** + * Encodes the specified MerchantCenterLink message. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLink.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLink} message MerchantCenterLink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLink.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.merchantCenterAccountId != null && Object.hasOwnProperty.call(message, "merchantCenterAccountId")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.merchantCenterAccountId); + if (message.branchId != null && Object.hasOwnProperty.call(message, "branchId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branchId); + if (message.destinations != null && message.destinations.length) + for (var i = 0; i < message.destinations.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.destinations[i]); + if (message.regionCode != null && Object.hasOwnProperty.call(message, "regionCode")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.regionCode); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.languageCode); + return writer; + }; + + /** + * Encodes the specified MerchantCenterLink message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLink.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLink} message MerchantCenterLink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLink.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.MerchantCenterLink} MerchantCenterLink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLink.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.cloud.retail.v2beta.MerchantCenterLink(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.merchantCenterAccountId = reader.int64(); + break; + } + case 2: { + message.branchId = reader.string(); + break; + } + case 3: { + if (!(message.destinations && message.destinations.length)) + message.destinations = []; + message.destinations.push(reader.string()); + break; + } + case 4: { + message.regionCode = reader.string(); + break; + } + case 5: { + message.languageCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MerchantCenterLink message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.MerchantCenterLink} MerchantCenterLink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLink.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MerchantCenterLink message. + * @function verify + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MerchantCenterLink.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.merchantCenterAccountId != null && message.hasOwnProperty("merchantCenterAccountId")) + if (!$util.isInteger(message.merchantCenterAccountId) && !(message.merchantCenterAccountId && $util.isInteger(message.merchantCenterAccountId.low) && $util.isInteger(message.merchantCenterAccountId.high))) + return "merchantCenterAccountId: integer|Long expected"; + if (message.branchId != null && message.hasOwnProperty("branchId")) + if (!$util.isString(message.branchId)) + return "branchId: 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) + if (!$util.isString(message.destinations[i])) + return "destinations: string[] expected"; + } + if (message.regionCode != null && message.hasOwnProperty("regionCode")) + if (!$util.isString(message.regionCode)) + return "regionCode: string expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + return null; + }; + + /** + * Creates a MerchantCenterLink message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.MerchantCenterLink} MerchantCenterLink + */ + MerchantCenterLink.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.MerchantCenterLink) + return object; + var message = new $root.google.cloud.retail.v2beta.MerchantCenterLink(); + if (object.merchantCenterAccountId != null) + if ($util.Long) + (message.merchantCenterAccountId = $util.Long.fromValue(object.merchantCenterAccountId)).unsigned = false; + else if (typeof object.merchantCenterAccountId === "string") + message.merchantCenterAccountId = parseInt(object.merchantCenterAccountId, 10); + else if (typeof object.merchantCenterAccountId === "number") + message.merchantCenterAccountId = object.merchantCenterAccountId; + else if (typeof object.merchantCenterAccountId === "object") + message.merchantCenterAccountId = new $util.LongBits(object.merchantCenterAccountId.low >>> 0, object.merchantCenterAccountId.high >>> 0).toNumber(); + if (object.branchId != null) + message.branchId = String(object.branchId); + if (object.destinations) { + if (!Array.isArray(object.destinations)) + throw TypeError(".google.cloud.retail.v2beta.MerchantCenterLink.destinations: array expected"); + message.destinations = []; + for (var i = 0; i < object.destinations.length; ++i) + message.destinations[i] = String(object.destinations[i]); + } + if (object.regionCode != null) + message.regionCode = String(object.regionCode); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + return message; + }; + + /** + * Creates a plain object from a MerchantCenterLink message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {google.cloud.retail.v2beta.MerchantCenterLink} message MerchantCenterLink + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MerchantCenterLink.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.destinations = []; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.merchantCenterAccountId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.merchantCenterAccountId = options.longs === String ? "0" : 0; + object.branchId = ""; + object.regionCode = ""; + object.languageCode = ""; + } + if (message.merchantCenterAccountId != null && message.hasOwnProperty("merchantCenterAccountId")) + if (typeof message.merchantCenterAccountId === "number") + object.merchantCenterAccountId = options.longs === String ? String(message.merchantCenterAccountId) : message.merchantCenterAccountId; + else + object.merchantCenterAccountId = options.longs === String ? $util.Long.prototype.toString.call(message.merchantCenterAccountId) : options.longs === Number ? new $util.LongBits(message.merchantCenterAccountId.low >>> 0, message.merchantCenterAccountId.high >>> 0).toNumber() : message.merchantCenterAccountId; + if (message.branchId != null && message.hasOwnProperty("branchId")) + object.branchId = message.branchId; + if (message.destinations && message.destinations.length) { + object.destinations = []; + for (var j = 0; j < message.destinations.length; ++j) + object.destinations[j] = message.destinations[j]; + } + if (message.regionCode != null && message.hasOwnProperty("regionCode")) + object.regionCode = message.regionCode; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + return object; + }; + + /** + * Converts this MerchantCenterLink to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @instance + * @returns {Object.} JSON object + */ + MerchantCenterLink.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MerchantCenterLink + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.MerchantCenterLink + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MerchantCenterLink.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.MerchantCenterLink"; + }; + + return MerchantCenterLink; + })(); + + v2beta.MerchantCenterLinkingConfig = (function() { + + /** + * Properties of a MerchantCenterLinkingConfig. + * @memberof google.cloud.retail.v2beta + * @interface IMerchantCenterLinkingConfig + * @property {Array.|null} [links] MerchantCenterLinkingConfig links + */ + + /** + * Constructs a new MerchantCenterLinkingConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a MerchantCenterLinkingConfig. + * @implements IMerchantCenterLinkingConfig + * @constructor + * @param {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig=} [properties] Properties to set + */ + function MerchantCenterLinkingConfig(properties) { + this.links = []; + 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]]; + } + + /** + * MerchantCenterLinkingConfig links. + * @member {Array.} links + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @instance + */ + MerchantCenterLinkingConfig.prototype.links = $util.emptyArray; + + /** + * Creates a new MerchantCenterLinkingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig instance + */ + MerchantCenterLinkingConfig.create = function create(properties) { + return new MerchantCenterLinkingConfig(properties); + }; + + /** + * Encodes the specified MerchantCenterLinkingConfig message. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLinkingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig} message MerchantCenterLinkingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLinkingConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.links != null && message.links.length) + for (var i = 0; i < message.links.length; ++i) + $root.google.cloud.retail.v2beta.MerchantCenterLink.encode(message.links[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MerchantCenterLinkingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.MerchantCenterLinkingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig} message MerchantCenterLinkingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MerchantCenterLinkingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLinkingConfig.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.cloud.retail.v2beta.MerchantCenterLinkingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.links && message.links.length)) + message.links = []; + message.links.push($root.google.cloud.retail.v2beta.MerchantCenterLink.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MerchantCenterLinkingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MerchantCenterLinkingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MerchantCenterLinkingConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MerchantCenterLinkingConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.links != null && message.hasOwnProperty("links")) { + if (!Array.isArray(message.links)) + return "links: array expected"; + for (var i = 0; i < message.links.length; ++i) { + var error = $root.google.cloud.retail.v2beta.MerchantCenterLink.verify(message.links[i]); + if (error) + return "links." + error; + } + } + return null; + }; + + /** + * Creates a MerchantCenterLinkingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.MerchantCenterLinkingConfig} MerchantCenterLinkingConfig + */ + MerchantCenterLinkingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig(); + if (object.links) { + if (!Array.isArray(object.links)) + throw TypeError(".google.cloud.retail.v2beta.MerchantCenterLinkingConfig.links: array expected"); + message.links = []; + for (var i = 0; i < object.links.length; ++i) { + if (typeof object.links[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.MerchantCenterLinkingConfig.links: object expected"); + message.links[i] = $root.google.cloud.retail.v2beta.MerchantCenterLink.fromObject(object.links[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a MerchantCenterLinkingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {google.cloud.retail.v2beta.MerchantCenterLinkingConfig} message MerchantCenterLinkingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MerchantCenterLinkingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.links = []; + if (message.links && message.links.length) { + object.links = []; + for (var j = 0; j < message.links.length; ++j) + object.links[j] = $root.google.cloud.retail.v2beta.MerchantCenterLink.toObject(message.links[j], options); + } + return object; + }; + + /** + * Converts this MerchantCenterLinkingConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @instance + * @returns {Object.} JSON object + */ + MerchantCenterLinkingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MerchantCenterLinkingConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.MerchantCenterLinkingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MerchantCenterLinkingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.MerchantCenterLinkingConfig"; + }; + + return MerchantCenterLinkingConfig; + })(); + + v2beta.Catalog = (function() { + + /** + * Properties of a Catalog. + * @memberof google.cloud.retail.v2beta + * @interface ICatalog + * @property {string|null} [name] Catalog name + * @property {string|null} [displayName] Catalog displayName + * @property {google.cloud.retail.v2beta.IProductLevelConfig|null} [productLevelConfig] Catalog productLevelConfig + * @property {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig|null} [merchantCenterLinkingConfig] Catalog merchantCenterLinkingConfig + */ + + /** + * Constructs a new Catalog. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Catalog. + * @implements ICatalog + * @constructor + * @param {google.cloud.retail.v2beta.ICatalog=} [properties] Properties to set + */ + function Catalog(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]]; + } + + /** + * Catalog name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.Catalog + * @instance + */ + Catalog.prototype.name = ""; + + /** + * Catalog displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2beta.Catalog + * @instance + */ + Catalog.prototype.displayName = ""; + + /** + * Catalog productLevelConfig. + * @member {google.cloud.retail.v2beta.IProductLevelConfig|null|undefined} productLevelConfig + * @memberof google.cloud.retail.v2beta.Catalog + * @instance + */ + Catalog.prototype.productLevelConfig = null; + + /** + * Catalog merchantCenterLinkingConfig. + * @member {google.cloud.retail.v2beta.IMerchantCenterLinkingConfig|null|undefined} merchantCenterLinkingConfig + * @memberof google.cloud.retail.v2beta.Catalog + * @instance + */ + Catalog.prototype.merchantCenterLinkingConfig = null; + + /** + * Creates a new Catalog instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {google.cloud.retail.v2beta.ICatalog=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Catalog} Catalog instance + */ + Catalog.create = function create(properties) { + return new Catalog(properties); + }; + + /** + * Encodes the specified Catalog message. Does not implicitly {@link google.cloud.retail.v2beta.Catalog.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {google.cloud.retail.v2beta.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.productLevelConfig != null && Object.hasOwnProperty.call(message, "productLevelConfig")) + $root.google.cloud.retail.v2beta.ProductLevelConfig.encode(message.productLevelConfig, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.merchantCenterLinkingConfig != null && Object.hasOwnProperty.call(message, "merchantCenterLinkingConfig")) + $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig.encode(message.merchantCenterLinkingConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Catalog message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Catalog.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {google.cloud.retail.v2beta.ICatalog} message Catalog message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Catalog.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Catalog message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.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.cloud.retail.v2beta.Catalog(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 4: { + message.productLevelConfig = $root.google.cloud.retail.v2beta.ProductLevelConfig.decode(reader, reader.uint32()); + break; + } + case 6: { + message.merchantCenterLinkingConfig = $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Catalog message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Catalog} Catalog + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Catalog.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Catalog message. + * @function verify + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Catalog.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) { + var error = $root.google.cloud.retail.v2beta.ProductLevelConfig.verify(message.productLevelConfig); + if (error) + return "productLevelConfig." + error; + } + if (message.merchantCenterLinkingConfig != null && message.hasOwnProperty("merchantCenterLinkingConfig")) { + var error = $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig.verify(message.merchantCenterLinkingConfig); + if (error) + return "merchantCenterLinkingConfig." + error; + } + return null; + }; + + /** + * Creates a Catalog message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Catalog} Catalog + */ + Catalog.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Catalog) + return object; + var message = new $root.google.cloud.retail.v2beta.Catalog(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.productLevelConfig != null) { + if (typeof object.productLevelConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.Catalog.productLevelConfig: object expected"); + message.productLevelConfig = $root.google.cloud.retail.v2beta.ProductLevelConfig.fromObject(object.productLevelConfig); + } + if (object.merchantCenterLinkingConfig != null) { + if (typeof object.merchantCenterLinkingConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.Catalog.merchantCenterLinkingConfig: object expected"); + message.merchantCenterLinkingConfig = $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig.fromObject(object.merchantCenterLinkingConfig); + } + return message; + }; + + /** + * Creates a plain object from a Catalog message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {google.cloud.retail.v2beta.Catalog} message Catalog + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Catalog.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.productLevelConfig = null; + object.merchantCenterLinkingConfig = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.productLevelConfig != null && message.hasOwnProperty("productLevelConfig")) + object.productLevelConfig = $root.google.cloud.retail.v2beta.ProductLevelConfig.toObject(message.productLevelConfig, options); + if (message.merchantCenterLinkingConfig != null && message.hasOwnProperty("merchantCenterLinkingConfig")) + object.merchantCenterLinkingConfig = $root.google.cloud.retail.v2beta.MerchantCenterLinkingConfig.toObject(message.merchantCenterLinkingConfig, options); + return object; + }; + + /** + * Converts this Catalog to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Catalog + * @instance + * @returns {Object.} JSON object + */ + Catalog.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Catalog + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Catalog + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Catalog.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Catalog"; + }; + + return Catalog; + })(); + + /** + * AttributeConfigLevel enum. + * @name google.cloud.retail.v2beta.AttributeConfigLevel + * @enum {number} + * @property {number} ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED=0 ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED value + * @property {number} PRODUCT_LEVEL_ATTRIBUTE_CONFIG=1 PRODUCT_LEVEL_ATTRIBUTE_CONFIG value + * @property {number} CATALOG_LEVEL_ATTRIBUTE_CONFIG=2 CATALOG_LEVEL_ATTRIBUTE_CONFIG value + */ + v2beta.AttributeConfigLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_LEVEL_ATTRIBUTE_CONFIG"] = 1; + values[valuesById[2] = "CATALOG_LEVEL_ATTRIBUTE_CONFIG"] = 2; + return values; + })(); + + /** + * SolutionType enum. + * @name google.cloud.retail.v2beta.SolutionType + * @enum {number} + * @property {number} SOLUTION_TYPE_UNSPECIFIED=0 SOLUTION_TYPE_UNSPECIFIED value + * @property {number} SOLUTION_TYPE_RECOMMENDATION=1 SOLUTION_TYPE_RECOMMENDATION value + * @property {number} SOLUTION_TYPE_SEARCH=2 SOLUTION_TYPE_SEARCH value + */ + v2beta.SolutionType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SOLUTION_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SOLUTION_TYPE_RECOMMENDATION"] = 1; + values[valuesById[2] = "SOLUTION_TYPE_SEARCH"] = 2; + return values; + })(); + + /** + * RecommendationsFilteringOption enum. + * @name google.cloud.retail.v2beta.RecommendationsFilteringOption + * @enum {number} + * @property {number} RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED=0 RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED value + * @property {number} RECOMMENDATIONS_FILTERING_DISABLED=1 RECOMMENDATIONS_FILTERING_DISABLED value + * @property {number} RECOMMENDATIONS_FILTERING_ENABLED=3 RECOMMENDATIONS_FILTERING_ENABLED value + */ + v2beta.RecommendationsFilteringOption = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "RECOMMENDATIONS_FILTERING_DISABLED"] = 1; + values[valuesById[3] = "RECOMMENDATIONS_FILTERING_ENABLED"] = 3; + return values; + })(); + + /** + * SearchSolutionUseCase enum. + * @name google.cloud.retail.v2beta.SearchSolutionUseCase + * @enum {number} + * @property {number} SEARCH_SOLUTION_USE_CASE_UNSPECIFIED=0 SEARCH_SOLUTION_USE_CASE_UNSPECIFIED value + * @property {number} SEARCH_SOLUTION_USE_CASE_SEARCH=1 SEARCH_SOLUTION_USE_CASE_SEARCH value + * @property {number} SEARCH_SOLUTION_USE_CASE_BROWSE=2 SEARCH_SOLUTION_USE_CASE_BROWSE value + */ + v2beta.SearchSolutionUseCase = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SEARCH_SOLUTION_USE_CASE_SEARCH"] = 1; + values[valuesById[2] = "SEARCH_SOLUTION_USE_CASE_BROWSE"] = 2; + return values; + })(); + + v2beta.Condition = (function() { + + /** + * Properties of a Condition. + * @memberof google.cloud.retail.v2beta + * @interface ICondition + * @property {Array.|null} [queryTerms] Condition queryTerms + * @property {Array.|null} [activeTimeRange] Condition activeTimeRange + */ + + /** + * Constructs a new Condition. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Condition. + * @implements ICondition + * @constructor + * @param {google.cloud.retail.v2beta.ICondition=} [properties] Properties to set + */ + function Condition(properties) { + this.queryTerms = []; + this.activeTimeRange = []; + 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]]; + } + + /** + * Condition queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2beta.Condition + * @instance + */ + Condition.prototype.queryTerms = $util.emptyArray; + + /** + * Condition activeTimeRange. + * @member {Array.} activeTimeRange + * @memberof google.cloud.retail.v2beta.Condition + * @instance + */ + Condition.prototype.activeTimeRange = $util.emptyArray; + + /** + * Creates a new Condition instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {google.cloud.retail.v2beta.ICondition=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Condition} Condition instance + */ + Condition.create = function create(properties) { + return new Condition(properties); + }; + + /** + * Encodes the specified Condition message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {google.cloud.retail.v2beta.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + $root.google.cloud.retail.v2beta.Condition.QueryTerm.encode(message.queryTerms[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.activeTimeRange != null && message.activeTimeRange.length) + for (var i = 0; i < message.activeTimeRange.length; ++i) + $root.google.cloud.retail.v2beta.Condition.TimeRange.encode(message.activeTimeRange[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Condition message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {google.cloud.retail.v2beta.ICondition} message Condition message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Condition.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Condition message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.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.cloud.retail.v2beta.Condition(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push($root.google.cloud.retail.v2beta.Condition.QueryTerm.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.activeTimeRange && message.activeTimeRange.length)) + message.activeTimeRange = []; + message.activeTimeRange.push($root.google.cloud.retail.v2beta.Condition.TimeRange.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Condition message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Condition} Condition + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Condition.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Condition message. + * @function verify + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Condition.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Condition.QueryTerm.verify(message.queryTerms[i]); + if (error) + return "queryTerms." + error; + } + } + if (message.activeTimeRange != null && message.hasOwnProperty("activeTimeRange")) { + if (!Array.isArray(message.activeTimeRange)) + return "activeTimeRange: array expected"; + for (var i = 0; i < message.activeTimeRange.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Condition.TimeRange.verify(message.activeTimeRange[i]); + if (error) + return "activeTimeRange." + error; + } + } + return null; + }; + + /** + * Creates a Condition message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Condition} Condition + */ + Condition.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Condition) + return object; + var message = new $root.google.cloud.retail.v2beta.Condition(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2beta.Condition.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) { + if (typeof object.queryTerms[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Condition.queryTerms: object expected"); + message.queryTerms[i] = $root.google.cloud.retail.v2beta.Condition.QueryTerm.fromObject(object.queryTerms[i]); + } + } + if (object.activeTimeRange) { + if (!Array.isArray(object.activeTimeRange)) + throw TypeError(".google.cloud.retail.v2beta.Condition.activeTimeRange: array expected"); + message.activeTimeRange = []; + for (var i = 0; i < object.activeTimeRange.length; ++i) { + if (typeof object.activeTimeRange[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Condition.activeTimeRange: object expected"); + message.activeTimeRange[i] = $root.google.cloud.retail.v2beta.Condition.TimeRange.fromObject(object.activeTimeRange[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Condition message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {google.cloud.retail.v2beta.Condition} message Condition + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Condition.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.queryTerms = []; + object.activeTimeRange = []; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = $root.google.cloud.retail.v2beta.Condition.QueryTerm.toObject(message.queryTerms[j], options); + } + if (message.activeTimeRange && message.activeTimeRange.length) { + object.activeTimeRange = []; + for (var j = 0; j < message.activeTimeRange.length; ++j) + object.activeTimeRange[j] = $root.google.cloud.retail.v2beta.Condition.TimeRange.toObject(message.activeTimeRange[j], options); + } + return object; + }; + + /** + * Converts this Condition to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Condition + * @instance + * @returns {Object.} JSON object + */ + Condition.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Condition + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Condition + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Condition.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Condition"; + }; + + Condition.QueryTerm = (function() { + + /** + * Properties of a QueryTerm. + * @memberof google.cloud.retail.v2beta.Condition + * @interface IQueryTerm + * @property {string|null} [value] QueryTerm value + * @property {boolean|null} [fullMatch] QueryTerm fullMatch + */ + + /** + * Constructs a new QueryTerm. + * @memberof google.cloud.retail.v2beta.Condition + * @classdesc Represents a QueryTerm. + * @implements IQueryTerm + * @constructor + * @param {google.cloud.retail.v2beta.Condition.IQueryTerm=} [properties] Properties to set + */ + function QueryTerm(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]]; + } + + /** + * QueryTerm value. + * @member {string} value + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.value = ""; + + /** + * QueryTerm fullMatch. + * @member {boolean} fullMatch + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @instance + */ + QueryTerm.prototype.fullMatch = false; + + /** + * Creates a new QueryTerm instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2beta.Condition.IQueryTerm=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Condition.QueryTerm} QueryTerm instance + */ + QueryTerm.create = function create(properties) { + return new QueryTerm(properties); + }; + + /** + * Encodes the specified QueryTerm message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.QueryTerm.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2beta.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.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); + if (message.fullMatch != null && Object.hasOwnProperty.call(message, "fullMatch")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullMatch); + return writer; + }; + + /** + * Encodes the specified QueryTerm message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.QueryTerm.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2beta.Condition.IQueryTerm} message QueryTerm message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryTerm.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.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.cloud.retail.v2beta.Condition.QueryTerm(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.fullMatch = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryTerm message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Condition.QueryTerm} QueryTerm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryTerm.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryTerm message. + * @function verify + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryTerm.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"; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + if (typeof message.fullMatch !== "boolean") + return "fullMatch: boolean expected"; + return null; + }; + + /** + * Creates a QueryTerm message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Condition.QueryTerm} QueryTerm + */ + QueryTerm.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Condition.QueryTerm) + return object; + var message = new $root.google.cloud.retail.v2beta.Condition.QueryTerm(); + if (object.value != null) + message.value = String(object.value); + if (object.fullMatch != null) + message.fullMatch = Boolean(object.fullMatch); + return message; + }; + + /** + * Creates a plain object from a QueryTerm message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {google.cloud.retail.v2beta.Condition.QueryTerm} message QueryTerm + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryTerm.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.fullMatch = false; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.fullMatch != null && message.hasOwnProperty("fullMatch")) + object.fullMatch = message.fullMatch; + return object; + }; + + /** + * Converts this QueryTerm to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @instance + * @returns {Object.} JSON object + */ + QueryTerm.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryTerm + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Condition.QueryTerm + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryTerm.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Condition.QueryTerm"; + }; + + return QueryTerm; + })(); + + Condition.TimeRange = (function() { + + /** + * Properties of a TimeRange. + * @memberof google.cloud.retail.v2beta.Condition + * @interface ITimeRange + * @property {google.protobuf.ITimestamp|null} [startTime] TimeRange startTime + * @property {google.protobuf.ITimestamp|null} [endTime] TimeRange endTime + */ + + /** + * Constructs a new TimeRange. + * @memberof google.cloud.retail.v2beta.Condition + * @classdesc Represents a TimeRange. + * @implements ITimeRange + * @constructor + * @param {google.cloud.retail.v2beta.Condition.ITimeRange=} [properties] Properties to set + */ + function TimeRange(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]]; + } + + /** + * TimeRange startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @instance + */ + TimeRange.prototype.startTime = null; + + /** + * TimeRange endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @instance + */ + TimeRange.prototype.endTime = null; + + /** + * Creates a new TimeRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2beta.Condition.ITimeRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Condition.TimeRange} TimeRange instance + */ + TimeRange.create = function create(properties) { + return new TimeRange(properties); + }; + + /** + * Encodes the specified TimeRange message. Does not implicitly {@link google.cloud.retail.v2beta.Condition.TimeRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2beta.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.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(); + return writer; + }; + + /** + * Encodes the specified TimeRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Condition.TimeRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2beta.Condition.ITimeRange} message TimeRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TimeRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.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.cloud.retail.v2beta.Condition.TimeRange(); + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TimeRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Condition.TimeRange} TimeRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TimeRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TimeRange message. + * @function verify + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TimeRange.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; + } + return null; + }; + + /** + * Creates a TimeRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Condition.TimeRange} TimeRange + */ + TimeRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Condition.TimeRange) + return object; + var message = new $root.google.cloud.retail.v2beta.Condition.TimeRange(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Condition.TimeRange.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Condition.TimeRange.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + return message; + }; + + /** + * Creates a plain object from a TimeRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {google.cloud.retail.v2beta.Condition.TimeRange} message TimeRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TimeRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + } + 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); + return object; + }; + + /** + * Converts this TimeRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @instance + * @returns {Object.} JSON object + */ + TimeRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TimeRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Condition.TimeRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TimeRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Condition.TimeRange"; + }; + + return TimeRange; + })(); + + return Condition; + })(); + + v2beta.Rule = (function() { + + /** + * Properties of a Rule. + * @memberof google.cloud.retail.v2beta + * @interface IRule + * @property {google.cloud.retail.v2beta.Rule.IBoostAction|null} [boostAction] Rule boostAction + * @property {google.cloud.retail.v2beta.Rule.IRedirectAction|null} [redirectAction] Rule redirectAction + * @property {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction|null} [onewaySynonymsAction] Rule onewaySynonymsAction + * @property {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction|null} [doNotAssociateAction] Rule doNotAssociateAction + * @property {google.cloud.retail.v2beta.Rule.IReplacementAction|null} [replacementAction] Rule replacementAction + * @property {google.cloud.retail.v2beta.Rule.IIgnoreAction|null} [ignoreAction] Rule ignoreAction + * @property {google.cloud.retail.v2beta.Rule.IFilterAction|null} [filterAction] Rule filterAction + * @property {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction|null} [twowaySynonymsAction] Rule twowaySynonymsAction + * @property {google.cloud.retail.v2beta.ICondition|null} [condition] Rule condition + */ + + /** + * Constructs a new Rule. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Rule. + * @implements IRule + * @constructor + * @param {google.cloud.retail.v2beta.IRule=} [properties] Properties to set + */ + function Rule(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]]; + } + + /** + * Rule boostAction. + * @member {google.cloud.retail.v2beta.Rule.IBoostAction|null|undefined} boostAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.boostAction = null; + + /** + * Rule redirectAction. + * @member {google.cloud.retail.v2beta.Rule.IRedirectAction|null|undefined} redirectAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.redirectAction = null; + + /** + * Rule onewaySynonymsAction. + * @member {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction|null|undefined} onewaySynonymsAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.onewaySynonymsAction = null; + + /** + * Rule doNotAssociateAction. + * @member {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction|null|undefined} doNotAssociateAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.doNotAssociateAction = null; + + /** + * Rule replacementAction. + * @member {google.cloud.retail.v2beta.Rule.IReplacementAction|null|undefined} replacementAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.replacementAction = null; + + /** + * Rule ignoreAction. + * @member {google.cloud.retail.v2beta.Rule.IIgnoreAction|null|undefined} ignoreAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.ignoreAction = null; + + /** + * Rule filterAction. + * @member {google.cloud.retail.v2beta.Rule.IFilterAction|null|undefined} filterAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.filterAction = null; + + /** + * Rule twowaySynonymsAction. + * @member {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction|null|undefined} twowaySynonymsAction + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.twowaySynonymsAction = null; + + /** + * Rule condition. + * @member {google.cloud.retail.v2beta.ICondition|null|undefined} condition + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Rule.prototype.condition = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Rule action. + * @member {"boostAction"|"redirectAction"|"onewaySynonymsAction"|"doNotAssociateAction"|"replacementAction"|"ignoreAction"|"filterAction"|"twowaySynonymsAction"|undefined} action + * @memberof google.cloud.retail.v2beta.Rule + * @instance + */ + Object.defineProperty(Rule.prototype, "action", { + get: $util.oneOfGetter($oneOfFields = ["boostAction", "redirectAction", "onewaySynonymsAction", "doNotAssociateAction", "replacementAction", "ignoreAction", "filterAction", "twowaySynonymsAction"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Rule instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {google.cloud.retail.v2beta.IRule=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule} Rule instance + */ + Rule.create = function create(properties) { + return new Rule(properties); + }; + + /** + * Encodes the specified Rule message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {google.cloud.retail.v2beta.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + $root.google.cloud.retail.v2beta.Condition.encode(message.condition, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.boostAction != null && Object.hasOwnProperty.call(message, "boostAction")) + $root.google.cloud.retail.v2beta.Rule.BoostAction.encode(message.boostAction, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.redirectAction != null && Object.hasOwnProperty.call(message, "redirectAction")) + $root.google.cloud.retail.v2beta.Rule.RedirectAction.encode(message.redirectAction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.onewaySynonymsAction != null && Object.hasOwnProperty.call(message, "onewaySynonymsAction")) + $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.encode(message.onewaySynonymsAction, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.doNotAssociateAction != null && Object.hasOwnProperty.call(message, "doNotAssociateAction")) + $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction.encode(message.doNotAssociateAction, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.replacementAction != null && Object.hasOwnProperty.call(message, "replacementAction")) + $root.google.cloud.retail.v2beta.Rule.ReplacementAction.encode(message.replacementAction, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.ignoreAction != null && Object.hasOwnProperty.call(message, "ignoreAction")) + $root.google.cloud.retail.v2beta.Rule.IgnoreAction.encode(message.ignoreAction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.filterAction != null && Object.hasOwnProperty.call(message, "filterAction")) + $root.google.cloud.retail.v2beta.Rule.FilterAction.encode(message.filterAction, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.twowaySynonymsAction != null && Object.hasOwnProperty.call(message, "twowaySynonymsAction")) + $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.encode(message.twowaySynonymsAction, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Rule message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {google.cloud.retail.v2beta.IRule} message Rule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rule message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.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.cloud.retail.v2beta.Rule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.boostAction = $root.google.cloud.retail.v2beta.Rule.BoostAction.decode(reader, reader.uint32()); + break; + } + case 3: { + message.redirectAction = $root.google.cloud.retail.v2beta.Rule.RedirectAction.decode(reader, reader.uint32()); + break; + } + case 6: { + message.onewaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 7: { + message.doNotAssociateAction = $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction.decode(reader, reader.uint32()); + break; + } + case 8: { + message.replacementAction = $root.google.cloud.retail.v2beta.Rule.ReplacementAction.decode(reader, reader.uint32()); + break; + } + case 9: { + message.ignoreAction = $root.google.cloud.retail.v2beta.Rule.IgnoreAction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.filterAction = $root.google.cloud.retail.v2beta.Rule.FilterAction.decode(reader, reader.uint32()); + break; + } + case 11: { + message.twowaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.decode(reader, reader.uint32()); + break; + } + case 1: { + message.condition = $root.google.cloud.retail.v2beta.Condition.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule} Rule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rule message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.BoostAction.verify(message.boostAction); + if (error) + return "boostAction." + error; + } + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.RedirectAction.verify(message.redirectAction); + if (error) + return "redirectAction." + error; + } + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.verify(message.onewaySynonymsAction); + if (error) + return "onewaySynonymsAction." + error; + } + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction.verify(message.doNotAssociateAction); + if (error) + return "doNotAssociateAction." + error; + } + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.ReplacementAction.verify(message.replacementAction); + if (error) + return "replacementAction." + error; + } + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.IgnoreAction.verify(message.ignoreAction); + if (error) + return "ignoreAction." + error; + } + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.FilterAction.verify(message.filterAction); + if (error) + return "filterAction." + error; + } + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + if (properties.action === 1) + return "action: multiple values"; + properties.action = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.verify(message.twowaySynonymsAction); + if (error) + return "twowaySynonymsAction." + error; + } + } + if (message.condition != null && message.hasOwnProperty("condition")) { + var error = $root.google.cloud.retail.v2beta.Condition.verify(message.condition); + if (error) + return "condition." + error; + } + return null; + }; + + /** + * Creates a Rule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule} Rule + */ + Rule.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule(); + if (object.boostAction != null) { + if (typeof object.boostAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.boostAction: object expected"); + message.boostAction = $root.google.cloud.retail.v2beta.Rule.BoostAction.fromObject(object.boostAction); + } + if (object.redirectAction != null) { + if (typeof object.redirectAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.redirectAction: object expected"); + message.redirectAction = $root.google.cloud.retail.v2beta.Rule.RedirectAction.fromObject(object.redirectAction); + } + if (object.onewaySynonymsAction != null) { + if (typeof object.onewaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.onewaySynonymsAction: object expected"); + message.onewaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.fromObject(object.onewaySynonymsAction); + } + if (object.doNotAssociateAction != null) { + if (typeof object.doNotAssociateAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.doNotAssociateAction: object expected"); + message.doNotAssociateAction = $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction.fromObject(object.doNotAssociateAction); + } + if (object.replacementAction != null) { + if (typeof object.replacementAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.replacementAction: object expected"); + message.replacementAction = $root.google.cloud.retail.v2beta.Rule.ReplacementAction.fromObject(object.replacementAction); + } + if (object.ignoreAction != null) { + if (typeof object.ignoreAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.ignoreAction: object expected"); + message.ignoreAction = $root.google.cloud.retail.v2beta.Rule.IgnoreAction.fromObject(object.ignoreAction); + } + if (object.filterAction != null) { + if (typeof object.filterAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.filterAction: object expected"); + message.filterAction = $root.google.cloud.retail.v2beta.Rule.FilterAction.fromObject(object.filterAction); + } + if (object.twowaySynonymsAction != null) { + if (typeof object.twowaySynonymsAction !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.twowaySynonymsAction: object expected"); + message.twowaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.fromObject(object.twowaySynonymsAction); + } + if (object.condition != null) { + if (typeof object.condition !== "object") + throw TypeError(".google.cloud.retail.v2beta.Rule.condition: object expected"); + message.condition = $root.google.cloud.retail.v2beta.Condition.fromObject(object.condition); + } + return message; + }; + + /** + * Creates a plain object from a Rule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {google.cloud.retail.v2beta.Rule} message Rule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.condition = null; + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = $root.google.cloud.retail.v2beta.Condition.toObject(message.condition, options); + if (message.boostAction != null && message.hasOwnProperty("boostAction")) { + object.boostAction = $root.google.cloud.retail.v2beta.Rule.BoostAction.toObject(message.boostAction, options); + if (options.oneofs) + object.action = "boostAction"; + } + if (message.redirectAction != null && message.hasOwnProperty("redirectAction")) { + object.redirectAction = $root.google.cloud.retail.v2beta.Rule.RedirectAction.toObject(message.redirectAction, options); + if (options.oneofs) + object.action = "redirectAction"; + } + if (message.onewaySynonymsAction != null && message.hasOwnProperty("onewaySynonymsAction")) { + object.onewaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.toObject(message.onewaySynonymsAction, options); + if (options.oneofs) + object.action = "onewaySynonymsAction"; + } + if (message.doNotAssociateAction != null && message.hasOwnProperty("doNotAssociateAction")) { + object.doNotAssociateAction = $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction.toObject(message.doNotAssociateAction, options); + if (options.oneofs) + object.action = "doNotAssociateAction"; + } + if (message.replacementAction != null && message.hasOwnProperty("replacementAction")) { + object.replacementAction = $root.google.cloud.retail.v2beta.Rule.ReplacementAction.toObject(message.replacementAction, options); + if (options.oneofs) + object.action = "replacementAction"; + } + if (message.ignoreAction != null && message.hasOwnProperty("ignoreAction")) { + object.ignoreAction = $root.google.cloud.retail.v2beta.Rule.IgnoreAction.toObject(message.ignoreAction, options); + if (options.oneofs) + object.action = "ignoreAction"; + } + if (message.filterAction != null && message.hasOwnProperty("filterAction")) { + object.filterAction = $root.google.cloud.retail.v2beta.Rule.FilterAction.toObject(message.filterAction, options); + if (options.oneofs) + object.action = "filterAction"; + } + if (message.twowaySynonymsAction != null && message.hasOwnProperty("twowaySynonymsAction")) { + object.twowaySynonymsAction = $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.toObject(message.twowaySynonymsAction, options); + if (options.oneofs) + object.action = "twowaySynonymsAction"; + } + return object; + }; + + /** + * Converts this Rule to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule + * @instance + * @returns {Object.} JSON object + */ + Rule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rule + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule"; + }; + + Rule.BoostAction = (function() { + + /** + * Properties of a BoostAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IBoostAction + * @property {number|null} [boost] BoostAction boost + * @property {string|null} [productsFilter] BoostAction productsFilter + */ + + /** + * Constructs a new BoostAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a BoostAction. + * @implements IBoostAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IBoostAction=} [properties] Properties to set + */ + function BoostAction(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]]; + } + + /** + * BoostAction boost. + * @member {number} boost + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @instance + */ + BoostAction.prototype.boost = 0; + + /** + * BoostAction productsFilter. + * @member {string} productsFilter + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @instance + */ + BoostAction.prototype.productsFilter = ""; + + /** + * Creates a new BoostAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IBoostAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.BoostAction} BoostAction instance + */ + BoostAction.create = function create(properties) { + return new BoostAction(properties); + }; + + /** + * Encodes the specified BoostAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.BoostAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.boost); + if (message.productsFilter != null && Object.hasOwnProperty.call(message, "productsFilter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.productsFilter); + return writer; + }; + + /** + * Encodes the specified BoostAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.BoostAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IBoostAction} message BoostAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.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.cloud.retail.v2beta.Rule.BoostAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.boost = reader.float(); + break; + } + case 2: { + message.productsFilter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.BoostAction} BoostAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + if (!$util.isString(message.productsFilter)) + return "productsFilter: string expected"; + return null; + }; + + /** + * Creates a BoostAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.BoostAction} BoostAction + */ + BoostAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.BoostAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.BoostAction(); + if (object.boost != null) + message.boost = Number(object.boost); + if (object.productsFilter != null) + message.productsFilter = String(object.productsFilter); + return message; + }; + + /** + * Creates a plain object from a BoostAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {google.cloud.retail.v2beta.Rule.BoostAction} message BoostAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.boost = 0; + object.productsFilter = ""; + } + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + if (message.productsFilter != null && message.hasOwnProperty("productsFilter")) + object.productsFilter = message.productsFilter; + return object; + }; + + /** + * Converts this BoostAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @instance + * @returns {Object.} JSON object + */ + BoostAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.BoostAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.BoostAction"; + }; + + return BoostAction; + })(); + + Rule.FilterAction = (function() { + + /** + * Properties of a FilterAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IFilterAction + * @property {string|null} [filter] FilterAction filter + */ + + /** + * Constructs a new FilterAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a FilterAction. + * @implements IFilterAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IFilterAction=} [properties] Properties to set + */ + function FilterAction(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]]; + } + + /** + * FilterAction filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @instance + */ + FilterAction.prototype.filter = ""; + + /** + * Creates a new FilterAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IFilterAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.FilterAction} FilterAction instance + */ + FilterAction.create = function create(properties) { + return new FilterAction(properties); + }; + + /** + * Encodes the specified FilterAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.FilterAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.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); + return writer; + }; + + /** + * Encodes the specified FilterAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.FilterAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IFilterAction} message FilterAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FilterAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.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.cloud.retail.v2beta.Rule.FilterAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FilterAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.FilterAction} FilterAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FilterAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FilterAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FilterAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a FilterAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.FilterAction} FilterAction + */ + FilterAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.FilterAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.FilterAction(); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a FilterAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {google.cloud.retail.v2beta.Rule.FilterAction} message FilterAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FilterAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.filter = ""; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this FilterAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @instance + * @returns {Object.} JSON object + */ + FilterAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FilterAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.FilterAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FilterAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.FilterAction"; + }; + + return FilterAction; + })(); + + Rule.RedirectAction = (function() { + + /** + * Properties of a RedirectAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IRedirectAction + * @property {string|null} [redirectUri] RedirectAction redirectUri + */ + + /** + * Constructs a new RedirectAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a RedirectAction. + * @implements IRedirectAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IRedirectAction=} [properties] Properties to set + */ + function RedirectAction(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]]; + } + + /** + * RedirectAction redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @instance + */ + RedirectAction.prototype.redirectUri = ""; + + /** + * Creates a new RedirectAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IRedirectAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.RedirectAction} RedirectAction instance + */ + RedirectAction.create = function create(properties) { + return new RedirectAction(properties); + }; + + /** + * Encodes the specified RedirectAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.RedirectAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.redirectUri); + return writer; + }; + + /** + * Encodes the specified RedirectAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.RedirectAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IRedirectAction} message RedirectAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.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.cloud.retail.v2beta.Rule.RedirectAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.redirectUri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RedirectAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.RedirectAction} RedirectAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RedirectAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RedirectAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + return null; + }; + + /** + * Creates a RedirectAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.RedirectAction} RedirectAction + */ + RedirectAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.RedirectAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.RedirectAction(); + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + return message; + }; + + /** + * Creates a plain object from a RedirectAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {google.cloud.retail.v2beta.Rule.RedirectAction} message RedirectAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RedirectAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.redirectUri = ""; + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + return object; + }; + + /** + * Converts this RedirectAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @instance + * @returns {Object.} JSON object + */ + RedirectAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RedirectAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.RedirectAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RedirectAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.RedirectAction"; + }; + + return RedirectAction; + })(); + + Rule.TwowaySynonymsAction = (function() { + + /** + * Properties of a TwowaySynonymsAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface ITwowaySynonymsAction + * @property {Array.|null} [synonyms] TwowaySynonymsAction synonyms + */ + + /** + * Constructs a new TwowaySynonymsAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a TwowaySynonymsAction. + * @implements ITwowaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction=} [properties] Properties to set + */ + function TwowaySynonymsAction(properties) { + this.synonyms = []; + 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]]; + } + + /** + * TwowaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @instance + */ + TwowaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * Creates a new TwowaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.TwowaySynonymsAction} TwowaySynonymsAction instance + */ + TwowaySynonymsAction.create = function create(properties) { + return new TwowaySynonymsAction(properties); + }; + + /** + * Encodes the specified TwowaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified TwowaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.ITwowaySynonymsAction} message TwowaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TwowaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.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.cloud.retail.v2beta.Rule.TwowaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TwowaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.TwowaySynonymsAction} TwowaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TwowaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TwowaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TwowaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + return null; + }; + + /** + * Creates a TwowaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.TwowaySynonymsAction} TwowaySynonymsAction + */ + TwowaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.TwowaySynonymsAction(); + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.TwowaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + return message; + }; + + /** + * Creates a plain object from a TwowaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.TwowaySynonymsAction} message TwowaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TwowaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.synonyms = []; + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this TwowaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + TwowaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TwowaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.TwowaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TwowaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.TwowaySynonymsAction"; + }; + + return TwowaySynonymsAction; + })(); + + Rule.OnewaySynonymsAction = (function() { + + /** + * Properties of an OnewaySynonymsAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IOnewaySynonymsAction + * @property {Array.|null} [queryTerms] OnewaySynonymsAction queryTerms + * @property {Array.|null} [synonyms] OnewaySynonymsAction synonyms + * @property {Array.|null} [onewayTerms] OnewaySynonymsAction onewayTerms + */ + + /** + * Constructs a new OnewaySynonymsAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents an OnewaySynonymsAction. + * @implements IOnewaySynonymsAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction=} [properties] Properties to set + */ + function OnewaySynonymsAction(properties) { + this.queryTerms = []; + this.synonyms = []; + this.onewayTerms = []; + 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]]; + } + + /** + * OnewaySynonymsAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.queryTerms = $util.emptyArray; + + /** + * OnewaySynonymsAction synonyms. + * @member {Array.} synonyms + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.synonyms = $util.emptyArray; + + /** + * OnewaySynonymsAction onewayTerms. + * @member {Array.} onewayTerms + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @instance + */ + OnewaySynonymsAction.prototype.onewayTerms = $util.emptyArray; + + /** + * Creates a new OnewaySynonymsAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.OnewaySynonymsAction} OnewaySynonymsAction instance + */ + OnewaySynonymsAction.create = function create(properties) { + return new OnewaySynonymsAction(properties); + }; + + /** + * Encodes the specified OnewaySynonymsAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.onewayTerms != null && message.onewayTerms.length) + for (var i = 0; i < message.onewayTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.onewayTerms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.queryTerms[i]); + if (message.synonyms != null && message.synonyms.length) + for (var i = 0; i < message.synonyms.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.synonyms[i]); + return writer; + }; + + /** + * Encodes the specified OnewaySynonymsAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IOnewaySynonymsAction} message OnewaySynonymsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OnewaySynonymsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.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.cloud.retail.v2beta.Rule.OnewaySynonymsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 4: { + if (!(message.synonyms && message.synonyms.length)) + message.synonyms = []; + message.synonyms.push(reader.string()); + break; + } + case 2: { + if (!(message.onewayTerms && message.onewayTerms.length)) + message.onewayTerms = []; + message.onewayTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OnewaySynonymsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.OnewaySynonymsAction} OnewaySynonymsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OnewaySynonymsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OnewaySynonymsAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OnewaySynonymsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.synonyms != null && message.hasOwnProperty("synonyms")) { + if (!Array.isArray(message.synonyms)) + return "synonyms: array expected"; + for (var i = 0; i < message.synonyms.length; ++i) + if (!$util.isString(message.synonyms[i])) + return "synonyms: string[] expected"; + } + if (message.onewayTerms != null && message.hasOwnProperty("onewayTerms")) { + if (!Array.isArray(message.onewayTerms)) + return "onewayTerms: array expected"; + for (var i = 0; i < message.onewayTerms.length; ++i) + if (!$util.isString(message.onewayTerms[i])) + return "onewayTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an OnewaySynonymsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.OnewaySynonymsAction} OnewaySynonymsAction + */ + OnewaySynonymsAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.OnewaySynonymsAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.synonyms) { + if (!Array.isArray(object.synonyms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.synonyms: array expected"); + message.synonyms = []; + for (var i = 0; i < object.synonyms.length; ++i) + message.synonyms[i] = String(object.synonyms[i]); + } + if (object.onewayTerms) { + if (!Array.isArray(object.onewayTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.OnewaySynonymsAction.onewayTerms: array expected"); + message.onewayTerms = []; + for (var i = 0; i < object.onewayTerms.length; ++i) + message.onewayTerms[i] = String(object.onewayTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an OnewaySynonymsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {google.cloud.retail.v2beta.Rule.OnewaySynonymsAction} message OnewaySynonymsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OnewaySynonymsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.onewayTerms = []; + object.queryTerms = []; + object.synonyms = []; + } + if (message.onewayTerms && message.onewayTerms.length) { + object.onewayTerms = []; + for (var j = 0; j < message.onewayTerms.length; ++j) + object.onewayTerms[j] = message.onewayTerms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.synonyms && message.synonyms.length) { + object.synonyms = []; + for (var j = 0; j < message.synonyms.length; ++j) + object.synonyms[j] = message.synonyms[j]; + } + return object; + }; + + /** + * Converts this OnewaySynonymsAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @instance + * @returns {Object.} JSON object + */ + OnewaySynonymsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OnewaySynonymsAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.OnewaySynonymsAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OnewaySynonymsAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.OnewaySynonymsAction"; + }; + + return OnewaySynonymsAction; + })(); + + Rule.DoNotAssociateAction = (function() { + + /** + * Properties of a DoNotAssociateAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IDoNotAssociateAction + * @property {Array.|null} [queryTerms] DoNotAssociateAction queryTerms + * @property {Array.|null} [doNotAssociateTerms] DoNotAssociateAction doNotAssociateTerms + * @property {Array.|null} [terms] DoNotAssociateAction terms + */ + + /** + * Constructs a new DoNotAssociateAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a DoNotAssociateAction. + * @implements IDoNotAssociateAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction=} [properties] Properties to set + */ + function DoNotAssociateAction(properties) { + this.queryTerms = []; + this.doNotAssociateTerms = []; + this.terms = []; + 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]]; + } + + /** + * DoNotAssociateAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.queryTerms = $util.emptyArray; + + /** + * DoNotAssociateAction doNotAssociateTerms. + * @member {Array.} doNotAssociateTerms + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.doNotAssociateTerms = $util.emptyArray; + + /** + * DoNotAssociateAction terms. + * @member {Array.} terms + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @instance + */ + DoNotAssociateAction.prototype.terms = $util.emptyArray; + + /** + * Creates a new DoNotAssociateAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.DoNotAssociateAction} DoNotAssociateAction instance + */ + DoNotAssociateAction.create = function create(properties) { + return new DoNotAssociateAction(properties); + }; + + /** + * Encodes the specified DoNotAssociateAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.terms != null && message.terms.length) + for (var i = 0; i < message.terms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.terms[i]); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.doNotAssociateTerms != null && message.doNotAssociateTerms.length) + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.doNotAssociateTerms[i]); + return writer; + }; + + /** + * Encodes the specified DoNotAssociateAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.DoNotAssociateAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IDoNotAssociateAction} message DoNotAssociateAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoNotAssociateAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.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.cloud.retail.v2beta.Rule.DoNotAssociateAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + if (!(message.doNotAssociateTerms && message.doNotAssociateTerms.length)) + message.doNotAssociateTerms = []; + message.doNotAssociateTerms.push(reader.string()); + break; + } + case 1: { + if (!(message.terms && message.terms.length)) + message.terms = []; + message.terms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DoNotAssociateAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.DoNotAssociateAction} DoNotAssociateAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoNotAssociateAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DoNotAssociateAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DoNotAssociateAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.doNotAssociateTerms != null && message.hasOwnProperty("doNotAssociateTerms")) { + if (!Array.isArray(message.doNotAssociateTerms)) + return "doNotAssociateTerms: array expected"; + for (var i = 0; i < message.doNotAssociateTerms.length; ++i) + if (!$util.isString(message.doNotAssociateTerms[i])) + return "doNotAssociateTerms: string[] expected"; + } + if (message.terms != null && message.hasOwnProperty("terms")) { + if (!Array.isArray(message.terms)) + return "terms: array expected"; + for (var i = 0; i < message.terms.length; ++i) + if (!$util.isString(message.terms[i])) + return "terms: string[] expected"; + } + return null; + }; + + /** + * Creates a DoNotAssociateAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.DoNotAssociateAction} DoNotAssociateAction + */ + DoNotAssociateAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.DoNotAssociateAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.DoNotAssociateAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.doNotAssociateTerms) { + if (!Array.isArray(object.doNotAssociateTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.DoNotAssociateAction.doNotAssociateTerms: array expected"); + message.doNotAssociateTerms = []; + for (var i = 0; i < object.doNotAssociateTerms.length; ++i) + message.doNotAssociateTerms[i] = String(object.doNotAssociateTerms[i]); + } + if (object.terms) { + if (!Array.isArray(object.terms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.DoNotAssociateAction.terms: array expected"); + message.terms = []; + for (var i = 0; i < object.terms.length; ++i) + message.terms[i] = String(object.terms[i]); + } + return message; + }; + + /** + * Creates a plain object from a DoNotAssociateAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {google.cloud.retail.v2beta.Rule.DoNotAssociateAction} message DoNotAssociateAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoNotAssociateAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.terms = []; + object.queryTerms = []; + object.doNotAssociateTerms = []; + } + if (message.terms && message.terms.length) { + object.terms = []; + for (var j = 0; j < message.terms.length; ++j) + object.terms[j] = message.terms[j]; + } + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.doNotAssociateTerms && message.doNotAssociateTerms.length) { + object.doNotAssociateTerms = []; + for (var j = 0; j < message.doNotAssociateTerms.length; ++j) + object.doNotAssociateTerms[j] = message.doNotAssociateTerms[j]; + } + return object; + }; + + /** + * Converts this DoNotAssociateAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @instance + * @returns {Object.} JSON object + */ + DoNotAssociateAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DoNotAssociateAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.DoNotAssociateAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DoNotAssociateAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.DoNotAssociateAction"; + }; + + return DoNotAssociateAction; + })(); + + Rule.ReplacementAction = (function() { + + /** + * Properties of a ReplacementAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IReplacementAction + * @property {Array.|null} [queryTerms] ReplacementAction queryTerms + * @property {string|null} [replacementTerm] ReplacementAction replacementTerm + * @property {string|null} [term] ReplacementAction term + */ + + /** + * Constructs a new ReplacementAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents a ReplacementAction. + * @implements IReplacementAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IReplacementAction=} [properties] Properties to set + */ + function ReplacementAction(properties) { + this.queryTerms = []; + 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]]; + } + + /** + * ReplacementAction queryTerms. + * @member {Array.} queryTerms + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.queryTerms = $util.emptyArray; + + /** + * ReplacementAction replacementTerm. + * @member {string} replacementTerm + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.replacementTerm = ""; + + /** + * ReplacementAction term. + * @member {string} term + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @instance + */ + ReplacementAction.prototype.term = ""; + + /** + * Creates a new ReplacementAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IReplacementAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.ReplacementAction} ReplacementAction instance + */ + ReplacementAction.create = function create(properties) { + return new ReplacementAction(properties); + }; + + /** + * Encodes the specified ReplacementAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.ReplacementAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.term != null && Object.hasOwnProperty.call(message, "term")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.term); + if (message.queryTerms != null && message.queryTerms.length) + for (var i = 0; i < message.queryTerms.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.queryTerms[i]); + if (message.replacementTerm != null && Object.hasOwnProperty.call(message, "replacementTerm")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.replacementTerm); + return writer; + }; + + /** + * Encodes the specified ReplacementAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.ReplacementAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IReplacementAction} message ReplacementAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplacementAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.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.cloud.retail.v2beta.Rule.ReplacementAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.queryTerms && message.queryTerms.length)) + message.queryTerms = []; + message.queryTerms.push(reader.string()); + break; + } + case 3: { + message.replacementTerm = reader.string(); + break; + } + case 1: { + message.term = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplacementAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.ReplacementAction} ReplacementAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplacementAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplacementAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplacementAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryTerms != null && message.hasOwnProperty("queryTerms")) { + if (!Array.isArray(message.queryTerms)) + return "queryTerms: array expected"; + for (var i = 0; i < message.queryTerms.length; ++i) + if (!$util.isString(message.queryTerms[i])) + return "queryTerms: string[] expected"; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + if (!$util.isString(message.replacementTerm)) + return "replacementTerm: string expected"; + if (message.term != null && message.hasOwnProperty("term")) + if (!$util.isString(message.term)) + return "term: string expected"; + return null; + }; + + /** + * Creates a ReplacementAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.ReplacementAction} ReplacementAction + */ + ReplacementAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.ReplacementAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.ReplacementAction(); + if (object.queryTerms) { + if (!Array.isArray(object.queryTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.ReplacementAction.queryTerms: array expected"); + message.queryTerms = []; + for (var i = 0; i < object.queryTerms.length; ++i) + message.queryTerms[i] = String(object.queryTerms[i]); + } + if (object.replacementTerm != null) + message.replacementTerm = String(object.replacementTerm); + if (object.term != null) + message.term = String(object.term); + return message; + }; + + /** + * Creates a plain object from a ReplacementAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {google.cloud.retail.v2beta.Rule.ReplacementAction} message ReplacementAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplacementAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.queryTerms = []; + if (options.defaults) { + object.term = ""; + object.replacementTerm = ""; + } + if (message.term != null && message.hasOwnProperty("term")) + object.term = message.term; + if (message.queryTerms && message.queryTerms.length) { + object.queryTerms = []; + for (var j = 0; j < message.queryTerms.length; ++j) + object.queryTerms[j] = message.queryTerms[j]; + } + if (message.replacementTerm != null && message.hasOwnProperty("replacementTerm")) + object.replacementTerm = message.replacementTerm; + return object; + }; + + /** + * Converts this ReplacementAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @instance + * @returns {Object.} JSON object + */ + ReplacementAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplacementAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.ReplacementAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplacementAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.ReplacementAction"; + }; + + return ReplacementAction; + })(); + + Rule.IgnoreAction = (function() { + + /** + * Properties of an IgnoreAction. + * @memberof google.cloud.retail.v2beta.Rule + * @interface IIgnoreAction + * @property {Array.|null} [ignoreTerms] IgnoreAction ignoreTerms + */ + + /** + * Constructs a new IgnoreAction. + * @memberof google.cloud.retail.v2beta.Rule + * @classdesc Represents an IgnoreAction. + * @implements IIgnoreAction + * @constructor + * @param {google.cloud.retail.v2beta.Rule.IIgnoreAction=} [properties] Properties to set + */ + function IgnoreAction(properties) { + this.ignoreTerms = []; + 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]]; + } + + /** + * IgnoreAction ignoreTerms. + * @member {Array.} ignoreTerms + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @instance + */ + IgnoreAction.prototype.ignoreTerms = $util.emptyArray; + + /** + * Creates a new IgnoreAction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IIgnoreAction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rule.IgnoreAction} IgnoreAction instance + */ + IgnoreAction.create = function create(properties) { + return new IgnoreAction(properties); + }; + + /** + * Encodes the specified IgnoreAction message. Does not implicitly {@link google.cloud.retail.v2beta.Rule.IgnoreAction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ignoreTerms != null && message.ignoreTerms.length) + for (var i = 0; i < message.ignoreTerms.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.ignoreTerms[i]); + return writer; + }; + + /** + * Encodes the specified IgnoreAction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rule.IgnoreAction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IIgnoreAction} message IgnoreAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IgnoreAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.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.cloud.retail.v2beta.Rule.IgnoreAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.ignoreTerms && message.ignoreTerms.length)) + message.ignoreTerms = []; + message.ignoreTerms.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IgnoreAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rule.IgnoreAction} IgnoreAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IgnoreAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IgnoreAction message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IgnoreAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ignoreTerms != null && message.hasOwnProperty("ignoreTerms")) { + if (!Array.isArray(message.ignoreTerms)) + return "ignoreTerms: array expected"; + for (var i = 0; i < message.ignoreTerms.length; ++i) + if (!$util.isString(message.ignoreTerms[i])) + return "ignoreTerms: string[] expected"; + } + return null; + }; + + /** + * Creates an IgnoreAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rule.IgnoreAction} IgnoreAction + */ + IgnoreAction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rule.IgnoreAction) + return object; + var message = new $root.google.cloud.retail.v2beta.Rule.IgnoreAction(); + if (object.ignoreTerms) { + if (!Array.isArray(object.ignoreTerms)) + throw TypeError(".google.cloud.retail.v2beta.Rule.IgnoreAction.ignoreTerms: array expected"); + message.ignoreTerms = []; + for (var i = 0; i < object.ignoreTerms.length; ++i) + message.ignoreTerms[i] = String(object.ignoreTerms[i]); + } + return message; + }; + + /** + * Creates a plain object from an IgnoreAction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {google.cloud.retail.v2beta.Rule.IgnoreAction} message IgnoreAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IgnoreAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ignoreTerms = []; + if (message.ignoreTerms && message.ignoreTerms.length) { + object.ignoreTerms = []; + for (var j = 0; j < message.ignoreTerms.length; ++j) + object.ignoreTerms[j] = message.ignoreTerms[j]; + } + return object; + }; + + /** + * Converts this IgnoreAction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @instance + * @returns {Object.} JSON object + */ + IgnoreAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IgnoreAction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rule.IgnoreAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IgnoreAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rule.IgnoreAction"; + }; + + return IgnoreAction; + })(); + + return Rule; + })(); + + v2beta.Audience = (function() { + + /** + * Properties of an Audience. + * @memberof google.cloud.retail.v2beta + * @interface IAudience + * @property {Array.|null} [genders] Audience genders + * @property {Array.|null} [ageGroups] Audience ageGroups + */ + + /** + * Constructs a new Audience. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an Audience. + * @implements IAudience + * @constructor + * @param {google.cloud.retail.v2beta.IAudience=} [properties] Properties to set + */ + function Audience(properties) { + this.genders = []; + this.ageGroups = []; + 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]]; + } + + /** + * Audience genders. + * @member {Array.} genders + * @memberof google.cloud.retail.v2beta.Audience + * @instance + */ + Audience.prototype.genders = $util.emptyArray; + + /** + * Audience ageGroups. + * @member {Array.} ageGroups + * @memberof google.cloud.retail.v2beta.Audience + * @instance + */ + Audience.prototype.ageGroups = $util.emptyArray; + + /** + * Creates a new Audience instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {google.cloud.retail.v2beta.IAudience=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Audience} Audience instance + */ + Audience.create = function create(properties) { + return new Audience(properties); + }; + + /** + * Encodes the specified Audience message. Does not implicitly {@link google.cloud.retail.v2beta.Audience.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {google.cloud.retail.v2beta.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.genders != null && message.genders.length) + for (var i = 0; i < message.genders.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.genders[i]); + if (message.ageGroups != null && message.ageGroups.length) + for (var i = 0; i < message.ageGroups.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ageGroups[i]); + return writer; + }; + + /** + * Encodes the specified Audience message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Audience.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {google.cloud.retail.v2beta.IAudience} message Audience message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Audience.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Audience message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.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.cloud.retail.v2beta.Audience(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.genders && message.genders.length)) + message.genders = []; + message.genders.push(reader.string()); + break; + } + case 2: { + if (!(message.ageGroups && message.ageGroups.length)) + message.ageGroups = []; + message.ageGroups.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Audience message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Audience} Audience + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Audience.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Audience message. + * @function verify + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Audience.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.genders != null && message.hasOwnProperty("genders")) { + if (!Array.isArray(message.genders)) + return "genders: array expected"; + for (var i = 0; i < message.genders.length; ++i) + if (!$util.isString(message.genders[i])) + return "genders: string[] expected"; + } + if (message.ageGroups != null && message.hasOwnProperty("ageGroups")) { + if (!Array.isArray(message.ageGroups)) + return "ageGroups: array expected"; + for (var i = 0; i < message.ageGroups.length; ++i) + if (!$util.isString(message.ageGroups[i])) + return "ageGroups: string[] expected"; + } + return null; + }; + + /** + * Creates an Audience message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Audience} Audience + */ + Audience.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Audience) + return object; + var message = new $root.google.cloud.retail.v2beta.Audience(); + if (object.genders) { + if (!Array.isArray(object.genders)) + throw TypeError(".google.cloud.retail.v2beta.Audience.genders: array expected"); + message.genders = []; + for (var i = 0; i < object.genders.length; ++i) + message.genders[i] = String(object.genders[i]); + } + if (object.ageGroups) { + if (!Array.isArray(object.ageGroups)) + throw TypeError(".google.cloud.retail.v2beta.Audience.ageGroups: array expected"); + message.ageGroups = []; + for (var i = 0; i < object.ageGroups.length; ++i) + message.ageGroups[i] = String(object.ageGroups[i]); + } + return message; + }; + + /** + * Creates a plain object from an Audience message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {google.cloud.retail.v2beta.Audience} message Audience + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Audience.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.genders = []; + object.ageGroups = []; + } + if (message.genders && message.genders.length) { + object.genders = []; + for (var j = 0; j < message.genders.length; ++j) + object.genders[j] = message.genders[j]; + } + if (message.ageGroups && message.ageGroups.length) { + object.ageGroups = []; + for (var j = 0; j < message.ageGroups.length; ++j) + object.ageGroups[j] = message.ageGroups[j]; + } + return object; + }; + + /** + * Converts this Audience to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Audience + * @instance + * @returns {Object.} JSON object + */ + Audience.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Audience + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Audience + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Audience.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Audience"; + }; + + return Audience; + })(); + + v2beta.ColorInfo = (function() { + + /** + * Properties of a ColorInfo. + * @memberof google.cloud.retail.v2beta + * @interface IColorInfo + * @property {Array.|null} [colorFamilies] ColorInfo colorFamilies + * @property {Array.|null} [colors] ColorInfo colors + */ + + /** + * Constructs a new ColorInfo. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ColorInfo. + * @implements IColorInfo + * @constructor + * @param {google.cloud.retail.v2beta.IColorInfo=} [properties] Properties to set + */ + function ColorInfo(properties) { + this.colorFamilies = []; + this.colors = []; + 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]]; + } + + /** + * ColorInfo colorFamilies. + * @member {Array.} colorFamilies + * @memberof google.cloud.retail.v2beta.ColorInfo + * @instance + */ + ColorInfo.prototype.colorFamilies = $util.emptyArray; + + /** + * ColorInfo colors. + * @member {Array.} colors + * @memberof google.cloud.retail.v2beta.ColorInfo + * @instance + */ + ColorInfo.prototype.colors = $util.emptyArray; + + /** + * Creates a new ColorInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {google.cloud.retail.v2beta.IColorInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ColorInfo} ColorInfo instance + */ + ColorInfo.create = function create(properties) { + return new ColorInfo(properties); + }; + + /** + * Encodes the specified ColorInfo message. Does not implicitly {@link google.cloud.retail.v2beta.ColorInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {google.cloud.retail.v2beta.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.colorFamilies != null && message.colorFamilies.length) + for (var i = 0; i < message.colorFamilies.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.colorFamilies[i]); + if (message.colors != null && message.colors.length) + for (var i = 0; i < message.colors.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.colors[i]); + return writer; + }; + + /** + * Encodes the specified ColorInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ColorInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {google.cloud.retail.v2beta.IColorInfo} message ColorInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ColorInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.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.cloud.retail.v2beta.ColorInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.colorFamilies && message.colorFamilies.length)) + message.colorFamilies = []; + message.colorFamilies.push(reader.string()); + break; + } + case 2: { + if (!(message.colors && message.colors.length)) + message.colors = []; + message.colors.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ColorInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ColorInfo} ColorInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ColorInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ColorInfo message. + * @function verify + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ColorInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.colorFamilies != null && message.hasOwnProperty("colorFamilies")) { + if (!Array.isArray(message.colorFamilies)) + return "colorFamilies: array expected"; + for (var i = 0; i < message.colorFamilies.length; ++i) + if (!$util.isString(message.colorFamilies[i])) + return "colorFamilies: string[] expected"; + } + if (message.colors != null && message.hasOwnProperty("colors")) { + if (!Array.isArray(message.colors)) + return "colors: array expected"; + for (var i = 0; i < message.colors.length; ++i) + if (!$util.isString(message.colors[i])) + return "colors: string[] expected"; + } + return null; + }; + + /** + * Creates a ColorInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ColorInfo} ColorInfo + */ + ColorInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ColorInfo) + return object; + var message = new $root.google.cloud.retail.v2beta.ColorInfo(); + if (object.colorFamilies) { + if (!Array.isArray(object.colorFamilies)) + throw TypeError(".google.cloud.retail.v2beta.ColorInfo.colorFamilies: array expected"); + message.colorFamilies = []; + for (var i = 0; i < object.colorFamilies.length; ++i) + message.colorFamilies[i] = String(object.colorFamilies[i]); + } + if (object.colors) { + if (!Array.isArray(object.colors)) + throw TypeError(".google.cloud.retail.v2beta.ColorInfo.colors: array expected"); + message.colors = []; + for (var i = 0; i < object.colors.length; ++i) + message.colors[i] = String(object.colors[i]); + } + return message; + }; + + /** + * Creates a plain object from a ColorInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {google.cloud.retail.v2beta.ColorInfo} message ColorInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ColorInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.colorFamilies = []; + object.colors = []; + } + if (message.colorFamilies && message.colorFamilies.length) { + object.colorFamilies = []; + for (var j = 0; j < message.colorFamilies.length; ++j) + object.colorFamilies[j] = message.colorFamilies[j]; + } + if (message.colors && message.colors.length) { + object.colors = []; + for (var j = 0; j < message.colors.length; ++j) + object.colors[j] = message.colors[j]; + } + return object; + }; + + /** + * Converts this ColorInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ColorInfo + * @instance + * @returns {Object.} JSON object + */ + ColorInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ColorInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ColorInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ColorInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ColorInfo"; + }; + + return ColorInfo; + })(); + + v2beta.CustomAttribute = (function() { + + /** + * Properties of a CustomAttribute. + * @memberof google.cloud.retail.v2beta + * @interface ICustomAttribute + * @property {Array.|null} [text] CustomAttribute text + * @property {Array.|null} [numbers] CustomAttribute numbers + * @property {boolean|null} [searchable] CustomAttribute searchable + * @property {boolean|null} [indexable] CustomAttribute indexable + */ + + /** + * Constructs a new CustomAttribute. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CustomAttribute. + * @implements ICustomAttribute + * @constructor + * @param {google.cloud.retail.v2beta.ICustomAttribute=} [properties] Properties to set + */ + function CustomAttribute(properties) { + this.text = []; + this.numbers = []; + 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]]; + } + + /** + * CustomAttribute text. + * @member {Array.} text + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + CustomAttribute.prototype.text = $util.emptyArray; + + /** + * CustomAttribute numbers. + * @member {Array.} numbers + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + CustomAttribute.prototype.numbers = $util.emptyArray; + + /** + * CustomAttribute searchable. + * @member {boolean|null|undefined} searchable + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + CustomAttribute.prototype.searchable = null; + + /** + * CustomAttribute indexable. + * @member {boolean|null|undefined} indexable + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + CustomAttribute.prototype.indexable = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CustomAttribute _searchable. + * @member {"searchable"|undefined} _searchable + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_searchable", { + get: $util.oneOfGetter($oneOfFields = ["searchable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * CustomAttribute _indexable. + * @member {"indexable"|undefined} _indexable + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + */ + Object.defineProperty(CustomAttribute.prototype, "_indexable", { + get: $util.oneOfGetter($oneOfFields = ["indexable"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CustomAttribute instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {google.cloud.retail.v2beta.ICustomAttribute=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CustomAttribute} CustomAttribute instance + */ + CustomAttribute.create = function create(properties) { + return new CustomAttribute(properties); + }; + + /** + * Encodes the specified CustomAttribute message. Does not implicitly {@link google.cloud.retail.v2beta.CustomAttribute.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {google.cloud.retail.v2beta.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.text != null && message.text.length) + for (var i = 0; i < message.text.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.text[i]); + if (message.numbers != null && message.numbers.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.numbers.length; ++i) + writer.double(message.numbers[i]); + writer.ldelim(); + } + if (message.searchable != null && Object.hasOwnProperty.call(message, "searchable")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.searchable); + if (message.indexable != null && Object.hasOwnProperty.call(message, "indexable")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.indexable); + return writer; + }; + + /** + * Encodes the specified CustomAttribute message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CustomAttribute.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {google.cloud.retail.v2beta.ICustomAttribute} message CustomAttribute message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomAttribute.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.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.cloud.retail.v2beta.CustomAttribute(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.text && message.text.length)) + message.text = []; + message.text.push(reader.string()); + break; + } + case 2: { + if (!(message.numbers && message.numbers.length)) + message.numbers = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.numbers.push(reader.double()); + } else + message.numbers.push(reader.double()); + break; + } + case 3: { + message.searchable = reader.bool(); + break; + } + case 4: { + message.indexable = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomAttribute message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CustomAttribute} CustomAttribute + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomAttribute.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomAttribute message. + * @function verify + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomAttribute.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.text != null && message.hasOwnProperty("text")) { + if (!Array.isArray(message.text)) + return "text: array expected"; + for (var i = 0; i < message.text.length; ++i) + if (!$util.isString(message.text[i])) + return "text: string[] expected"; + } + if (message.numbers != null && message.hasOwnProperty("numbers")) { + if (!Array.isArray(message.numbers)) + return "numbers: array expected"; + for (var i = 0; i < message.numbers.length; ++i) + if (typeof message.numbers[i] !== "number") + return "numbers: number[] expected"; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + properties._searchable = 1; + if (typeof message.searchable !== "boolean") + return "searchable: boolean expected"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + properties._indexable = 1; + if (typeof message.indexable !== "boolean") + return "indexable: boolean expected"; + } + return null; + }; + + /** + * Creates a CustomAttribute message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CustomAttribute} CustomAttribute + */ + CustomAttribute.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CustomAttribute) + return object; + var message = new $root.google.cloud.retail.v2beta.CustomAttribute(); + if (object.text) { + if (!Array.isArray(object.text)) + throw TypeError(".google.cloud.retail.v2beta.CustomAttribute.text: array expected"); + message.text = []; + for (var i = 0; i < object.text.length; ++i) + message.text[i] = String(object.text[i]); + } + if (object.numbers) { + if (!Array.isArray(object.numbers)) + throw TypeError(".google.cloud.retail.v2beta.CustomAttribute.numbers: array expected"); + message.numbers = []; + for (var i = 0; i < object.numbers.length; ++i) + message.numbers[i] = Number(object.numbers[i]); + } + if (object.searchable != null) + message.searchable = Boolean(object.searchable); + if (object.indexable != null) + message.indexable = Boolean(object.indexable); + return message; + }; + + /** + * Creates a plain object from a CustomAttribute message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {google.cloud.retail.v2beta.CustomAttribute} message CustomAttribute + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomAttribute.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.text = []; + object.numbers = []; + } + if (message.text && message.text.length) { + object.text = []; + for (var j = 0; j < message.text.length; ++j) + object.text[j] = message.text[j]; + } + if (message.numbers && message.numbers.length) { + object.numbers = []; + for (var j = 0; j < message.numbers.length; ++j) + object.numbers[j] = options.json && !isFinite(message.numbers[j]) ? String(message.numbers[j]) : message.numbers[j]; + } + if (message.searchable != null && message.hasOwnProperty("searchable")) { + object.searchable = message.searchable; + if (options.oneofs) + object._searchable = "searchable"; + } + if (message.indexable != null && message.hasOwnProperty("indexable")) { + object.indexable = message.indexable; + if (options.oneofs) + object._indexable = "indexable"; + } + return object; + }; + + /** + * Converts this CustomAttribute to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @instance + * @returns {Object.} JSON object + */ + CustomAttribute.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CustomAttribute + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CustomAttribute + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomAttribute.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CustomAttribute"; + }; + + return CustomAttribute; + })(); + + v2beta.FulfillmentInfo = (function() { + + /** + * Properties of a FulfillmentInfo. + * @memberof google.cloud.retail.v2beta + * @interface IFulfillmentInfo + * @property {string|null} [type] FulfillmentInfo type + * @property {Array.|null} [placeIds] FulfillmentInfo placeIds + */ + + /** + * Constructs a new FulfillmentInfo. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a FulfillmentInfo. + * @implements IFulfillmentInfo + * @constructor + * @param {google.cloud.retail.v2beta.IFulfillmentInfo=} [properties] Properties to set + */ + function FulfillmentInfo(properties) { + this.placeIds = []; + 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]]; + } + + /** + * FulfillmentInfo type. + * @member {string} type + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.type = ""; + + /** + * FulfillmentInfo placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @instance + */ + FulfillmentInfo.prototype.placeIds = $util.emptyArray; + + /** + * Creates a new FulfillmentInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2beta.IFulfillmentInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.FulfillmentInfo} FulfillmentInfo instance + */ + FulfillmentInfo.create = function create(properties) { + return new FulfillmentInfo(properties); + }; + + /** + * Encodes the specified FulfillmentInfo message. Does not implicitly {@link google.cloud.retail.v2beta.FulfillmentInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2beta.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + return writer; + }; + + /** + * Encodes the specified FulfillmentInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.FulfillmentInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2beta.IFulfillmentInfo} message FulfillmentInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FulfillmentInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.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.cloud.retail.v2beta.FulfillmentInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FulfillmentInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.FulfillmentInfo} FulfillmentInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FulfillmentInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FulfillmentInfo message. + * @function verify + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FulfillmentInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + return null; + }; + + /** + * Creates a FulfillmentInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.FulfillmentInfo} FulfillmentInfo + */ + FulfillmentInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.FulfillmentInfo) + return object; + var message = new $root.google.cloud.retail.v2beta.FulfillmentInfo(); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2beta.FulfillmentInfo.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a FulfillmentInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {google.cloud.retail.v2beta.FulfillmentInfo} message FulfillmentInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FulfillmentInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) + object.type = ""; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + return object; + }; + + /** + * Converts this FulfillmentInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @instance + * @returns {Object.} JSON object + */ + FulfillmentInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FulfillmentInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.FulfillmentInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FulfillmentInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.FulfillmentInfo"; + }; + + return FulfillmentInfo; + })(); + + v2beta.Image = (function() { + + /** + * Properties of an Image. + * @memberof google.cloud.retail.v2beta + * @interface IImage + * @property {string|null} [uri] Image uri + * @property {number|null} [height] Image height + * @property {number|null} [width] Image width + */ + + /** + * Constructs a new Image. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an Image. + * @implements IImage + * @constructor + * @param {google.cloud.retail.v2beta.IImage=} [properties] Properties to set + */ + function Image(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]]; + } + + /** + * Image uri. + * @member {string} uri + * @memberof google.cloud.retail.v2beta.Image + * @instance + */ + Image.prototype.uri = ""; + + /** + * Image height. + * @member {number} height + * @memberof google.cloud.retail.v2beta.Image + * @instance + */ + Image.prototype.height = 0; + + /** + * Image width. + * @member {number} width + * @memberof google.cloud.retail.v2beta.Image + * @instance + */ + Image.prototype.width = 0; + + /** + * Creates a new Image instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {google.cloud.retail.v2beta.IImage=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Image} Image instance + */ + Image.create = function create(properties) { + return new Image(properties); + }; + + /** + * Encodes the specified Image message. Does not implicitly {@link google.cloud.retail.v2beta.Image.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {google.cloud.retail.v2beta.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.uri); + if (message.height != null && Object.hasOwnProperty.call(message, "height")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.height); + if (message.width != null && Object.hasOwnProperty.call(message, "width")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.width); + return writer; + }; + + /** + * Encodes the specified Image message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Image.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {google.cloud.retail.v2beta.IImage} message Image message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Image.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Image message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.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.cloud.retail.v2beta.Image(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.uri = reader.string(); + break; + } + case 2: { + message.height = reader.int32(); + break; + } + case 3: { + message.width = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Image message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Image} Image + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Image.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Image message. + * @function verify + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Image.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.height != null && message.hasOwnProperty("height")) + if (!$util.isInteger(message.height)) + return "height: integer expected"; + if (message.width != null && message.hasOwnProperty("width")) + if (!$util.isInteger(message.width)) + return "width: integer expected"; + return null; + }; + + /** + * Creates an Image message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Image} Image + */ + Image.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Image) + return object; + var message = new $root.google.cloud.retail.v2beta.Image(); + if (object.uri != null) + message.uri = String(object.uri); + if (object.height != null) + message.height = object.height | 0; + if (object.width != null) + message.width = object.width | 0; + return message; + }; + + /** + * Creates a plain object from an Image message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {google.cloud.retail.v2beta.Image} message Image + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Image.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.uri = ""; + object.height = 0; + object.width = 0; + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.height != null && message.hasOwnProperty("height")) + object.height = message.height; + if (message.width != null && message.hasOwnProperty("width")) + object.width = message.width; + return object; + }; + + /** + * Converts this Image to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Image + * @instance + * @returns {Object.} JSON object + */ + Image.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Image + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Image + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Image.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Image"; + }; + + return Image; + })(); + + v2beta.Interval = (function() { + + /** + * Properties of an Interval. + * @memberof google.cloud.retail.v2beta + * @interface IInterval + * @property {number|null} [minimum] Interval minimum + * @property {number|null} [exclusiveMinimum] Interval exclusiveMinimum + * @property {number|null} [maximum] Interval maximum + * @property {number|null} [exclusiveMaximum] Interval exclusiveMaximum + */ + + /** + * Constructs a new Interval. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an Interval. + * @implements IInterval + * @constructor + * @param {google.cloud.retail.v2beta.IInterval=} [properties] Properties to set + */ + function Interval(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]]; + } + + /** + * Interval minimum. + * @member {number|null|undefined} minimum + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Interval.prototype.minimum = null; + + /** + * Interval exclusiveMinimum. + * @member {number|null|undefined} exclusiveMinimum + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Interval.prototype.exclusiveMinimum = null; + + /** + * Interval maximum. + * @member {number|null|undefined} maximum + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Interval.prototype.maximum = null; + + /** + * Interval exclusiveMaximum. + * @member {number|null|undefined} exclusiveMaximum + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Interval.prototype.exclusiveMaximum = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Interval min. + * @member {"minimum"|"exclusiveMinimum"|undefined} min + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "min", { + get: $util.oneOfGetter($oneOfFields = ["minimum", "exclusiveMinimum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Interval max. + * @member {"maximum"|"exclusiveMaximum"|undefined} max + * @memberof google.cloud.retail.v2beta.Interval + * @instance + */ + Object.defineProperty(Interval.prototype, "max", { + get: $util.oneOfGetter($oneOfFields = ["maximum", "exclusiveMaximum"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Interval instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {google.cloud.retail.v2beta.IInterval=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Interval} Interval instance + */ + Interval.create = function create(properties) { + return new Interval(properties); + }; + + /** + * Encodes the specified Interval message. Does not implicitly {@link google.cloud.retail.v2beta.Interval.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {google.cloud.retail.v2beta.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.minimum != null && Object.hasOwnProperty.call(message, "minimum")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.minimum); + if (message.exclusiveMinimum != null && Object.hasOwnProperty.call(message, "exclusiveMinimum")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.exclusiveMinimum); + if (message.maximum != null && Object.hasOwnProperty.call(message, "maximum")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.maximum); + if (message.exclusiveMaximum != null && Object.hasOwnProperty.call(message, "exclusiveMaximum")) + writer.uint32(/* id 4, wireType 1 =*/33).double(message.exclusiveMaximum); + return writer; + }; + + /** + * Encodes the specified Interval message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Interval.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {google.cloud.retail.v2beta.IInterval} message Interval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Interval.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Interval message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.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.cloud.retail.v2beta.Interval(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.minimum = reader.double(); + break; + } + case 2: { + message.exclusiveMinimum = reader.double(); + break; + } + case 3: { + message.maximum = reader.double(); + break; + } + case 4: { + message.exclusiveMaximum = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Interval message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Interval} Interval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Interval.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Interval message. + * @function verify + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Interval.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + properties.min = 1; + if (typeof message.minimum !== "number") + return "minimum: number expected"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + if (properties.min === 1) + return "min: multiple values"; + properties.min = 1; + if (typeof message.exclusiveMinimum !== "number") + return "exclusiveMinimum: number expected"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + properties.max = 1; + if (typeof message.maximum !== "number") + return "maximum: number expected"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + if (properties.max === 1) + return "max: multiple values"; + properties.max = 1; + if (typeof message.exclusiveMaximum !== "number") + return "exclusiveMaximum: number expected"; + } + return null; + }; + + /** + * Creates an Interval message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Interval} Interval + */ + Interval.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Interval) + return object; + var message = new $root.google.cloud.retail.v2beta.Interval(); + if (object.minimum != null) + message.minimum = Number(object.minimum); + if (object.exclusiveMinimum != null) + message.exclusiveMinimum = Number(object.exclusiveMinimum); + if (object.maximum != null) + message.maximum = Number(object.maximum); + if (object.exclusiveMaximum != null) + message.exclusiveMaximum = Number(object.exclusiveMaximum); + return message; + }; + + /** + * Creates a plain object from an Interval message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {google.cloud.retail.v2beta.Interval} message Interval + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Interval.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = options.json && !isFinite(message.minimum) ? String(message.minimum) : message.minimum; + if (options.oneofs) + object.min = "minimum"; + } + if (message.exclusiveMinimum != null && message.hasOwnProperty("exclusiveMinimum")) { + object.exclusiveMinimum = options.json && !isFinite(message.exclusiveMinimum) ? String(message.exclusiveMinimum) : message.exclusiveMinimum; + if (options.oneofs) + object.min = "exclusiveMinimum"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = options.json && !isFinite(message.maximum) ? String(message.maximum) : message.maximum; + if (options.oneofs) + object.max = "maximum"; + } + if (message.exclusiveMaximum != null && message.hasOwnProperty("exclusiveMaximum")) { + object.exclusiveMaximum = options.json && !isFinite(message.exclusiveMaximum) ? String(message.exclusiveMaximum) : message.exclusiveMaximum; + if (options.oneofs) + object.max = "exclusiveMaximum"; + } + return object; + }; + + /** + * Converts this Interval to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Interval + * @instance + * @returns {Object.} JSON object + */ + Interval.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Interval + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Interval + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Interval.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Interval"; + }; + + return Interval; + })(); + + v2beta.PriceInfo = (function() { + + /** + * Properties of a PriceInfo. + * @memberof google.cloud.retail.v2beta + * @interface IPriceInfo + * @property {string|null} [currencyCode] PriceInfo currencyCode + * @property {number|null} [price] PriceInfo price + * @property {number|null} [originalPrice] PriceInfo originalPrice + * @property {number|null} [cost] PriceInfo cost + * @property {google.protobuf.ITimestamp|null} [priceEffectiveTime] PriceInfo priceEffectiveTime + * @property {google.protobuf.ITimestamp|null} [priceExpireTime] PriceInfo priceExpireTime + * @property {google.cloud.retail.v2beta.PriceInfo.IPriceRange|null} [priceRange] PriceInfo priceRange + */ + + /** + * Constructs a new PriceInfo. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PriceInfo. + * @implements IPriceInfo + * @constructor + * @param {google.cloud.retail.v2beta.IPriceInfo=} [properties] Properties to set + */ + function PriceInfo(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]]; + } + + /** + * PriceInfo currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.currencyCode = ""; + + /** + * PriceInfo price. + * @member {number} price + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.price = 0; + + /** + * PriceInfo originalPrice. + * @member {number} originalPrice + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.originalPrice = 0; + + /** + * PriceInfo cost. + * @member {number} cost + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.cost = 0; + + /** + * PriceInfo priceEffectiveTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceEffectiveTime + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.priceEffectiveTime = null; + + /** + * PriceInfo priceExpireTime. + * @member {google.protobuf.ITimestamp|null|undefined} priceExpireTime + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.priceExpireTime = null; + + /** + * PriceInfo priceRange. + * @member {google.cloud.retail.v2beta.PriceInfo.IPriceRange|null|undefined} priceRange + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + */ + PriceInfo.prototype.priceRange = null; + + /** + * Creates a new PriceInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {google.cloud.retail.v2beta.IPriceInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PriceInfo} PriceInfo instance + */ + PriceInfo.create = function create(properties) { + return new PriceInfo(properties); + }; + + /** + * Encodes the specified PriceInfo message. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {google.cloud.retail.v2beta.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.currencyCode); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.price); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.originalPrice); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.priceEffectiveTime != null && Object.hasOwnProperty.call(message, "priceEffectiveTime")) + $root.google.protobuf.Timestamp.encode(message.priceEffectiveTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.priceExpireTime != null && Object.hasOwnProperty.call(message, "priceExpireTime")) + $root.google.protobuf.Timestamp.encode(message.priceExpireTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.priceRange != null && Object.hasOwnProperty.call(message, "priceRange")) + $root.google.cloud.retail.v2beta.PriceInfo.PriceRange.encode(message.priceRange, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {google.cloud.retail.v2beta.IPriceInfo} message PriceInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.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.cloud.retail.v2beta.PriceInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.currencyCode = reader.string(); + break; + } + case 2: { + message.price = reader.float(); + break; + } + case 3: { + message.originalPrice = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.priceEffectiveTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.priceExpireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 7: { + message.priceRange = $root.google.cloud.retail.v2beta.PriceInfo.PriceRange.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PriceInfo} PriceInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceInfo message. + * @function verify + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + if (message.price != null && message.hasOwnProperty("price")) + if (typeof message.price !== "number") + return "price: number expected"; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + if (typeof message.originalPrice !== "number") + return "originalPrice: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceEffectiveTime); + if (error) + return "priceEffectiveTime." + error; + } + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.priceExpireTime); + if (error) + return "priceExpireTime." + error; + } + if (message.priceRange != null && message.hasOwnProperty("priceRange")) { + var error = $root.google.cloud.retail.v2beta.PriceInfo.PriceRange.verify(message.priceRange); + if (error) + return "priceRange." + error; + } + return null; + }; + + /** + * Creates a PriceInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PriceInfo} PriceInfo + */ + PriceInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PriceInfo) + return object; + var message = new $root.google.cloud.retail.v2beta.PriceInfo(); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + if (object.price != null) + message.price = Number(object.price); + if (object.originalPrice != null) + message.originalPrice = Number(object.originalPrice); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.priceEffectiveTime != null) { + if (typeof object.priceEffectiveTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.PriceInfo.priceEffectiveTime: object expected"); + message.priceEffectiveTime = $root.google.protobuf.Timestamp.fromObject(object.priceEffectiveTime); + } + if (object.priceExpireTime != null) { + if (typeof object.priceExpireTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.PriceInfo.priceExpireTime: object expected"); + message.priceExpireTime = $root.google.protobuf.Timestamp.fromObject(object.priceExpireTime); + } + if (object.priceRange != null) { + if (typeof object.priceRange !== "object") + throw TypeError(".google.cloud.retail.v2beta.PriceInfo.priceRange: object expected"); + message.priceRange = $root.google.cloud.retail.v2beta.PriceInfo.PriceRange.fromObject(object.priceRange); + } + return message; + }; + + /** + * Creates a plain object from a PriceInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {google.cloud.retail.v2beta.PriceInfo} message PriceInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.currencyCode = ""; + object.price = 0; + object.originalPrice = 0; + object.cost = 0; + object.priceEffectiveTime = null; + object.priceExpireTime = null; + object.priceRange = null; + } + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + if (message.price != null && message.hasOwnProperty("price")) + object.price = options.json && !isFinite(message.price) ? String(message.price) : message.price; + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = options.json && !isFinite(message.originalPrice) ? String(message.originalPrice) : message.originalPrice; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.priceEffectiveTime != null && message.hasOwnProperty("priceEffectiveTime")) + object.priceEffectiveTime = $root.google.protobuf.Timestamp.toObject(message.priceEffectiveTime, options); + if (message.priceExpireTime != null && message.hasOwnProperty("priceExpireTime")) + object.priceExpireTime = $root.google.protobuf.Timestamp.toObject(message.priceExpireTime, options); + if (message.priceRange != null && message.hasOwnProperty("priceRange")) + object.priceRange = $root.google.cloud.retail.v2beta.PriceInfo.PriceRange.toObject(message.priceRange, options); + return object; + }; + + /** + * Converts this PriceInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PriceInfo + * @instance + * @returns {Object.} JSON object + */ + PriceInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PriceInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PriceInfo"; + }; + + PriceInfo.PriceRange = (function() { + + /** + * Properties of a PriceRange. + * @memberof google.cloud.retail.v2beta.PriceInfo + * @interface IPriceRange + * @property {google.cloud.retail.v2beta.IInterval|null} [price] PriceRange price + * @property {google.cloud.retail.v2beta.IInterval|null} [originalPrice] PriceRange originalPrice + */ + + /** + * Constructs a new PriceRange. + * @memberof google.cloud.retail.v2beta.PriceInfo + * @classdesc Represents a PriceRange. + * @implements IPriceRange + * @constructor + * @param {google.cloud.retail.v2beta.PriceInfo.IPriceRange=} [properties] Properties to set + */ + function PriceRange(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]]; + } + + /** + * PriceRange price. + * @member {google.cloud.retail.v2beta.IInterval|null|undefined} price + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.price = null; + + /** + * PriceRange originalPrice. + * @member {google.cloud.retail.v2beta.IInterval|null|undefined} originalPrice + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @instance + */ + PriceRange.prototype.originalPrice = null; + + /** + * Creates a new PriceRange instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2beta.PriceInfo.IPriceRange=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PriceInfo.PriceRange} PriceRange instance + */ + PriceRange.create = function create(properties) { + return new PriceRange(properties); + }; + + /** + * Encodes the specified PriceRange message. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.PriceRange.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2beta.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.price != null && Object.hasOwnProperty.call(message, "price")) + $root.google.cloud.retail.v2beta.Interval.encode(message.price, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.originalPrice != null && Object.hasOwnProperty.call(message, "originalPrice")) + $root.google.cloud.retail.v2beta.Interval.encode(message.originalPrice, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PriceRange message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PriceInfo.PriceRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2beta.PriceInfo.IPriceRange} message PriceRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PriceRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.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.cloud.retail.v2beta.PriceInfo.PriceRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.price = $root.google.cloud.retail.v2beta.Interval.decode(reader, reader.uint32()); + break; + } + case 2: { + message.originalPrice = $root.google.cloud.retail.v2beta.Interval.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PriceRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PriceInfo.PriceRange} PriceRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PriceRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PriceRange message. + * @function verify + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PriceRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.price != null && message.hasOwnProperty("price")) { + var error = $root.google.cloud.retail.v2beta.Interval.verify(message.price); + if (error) + return "price." + error; + } + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) { + var error = $root.google.cloud.retail.v2beta.Interval.verify(message.originalPrice); + if (error) + return "originalPrice." + error; + } + return null; + }; + + /** + * Creates a PriceRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PriceInfo.PriceRange} PriceRange + */ + PriceRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PriceInfo.PriceRange) + return object; + var message = new $root.google.cloud.retail.v2beta.PriceInfo.PriceRange(); + if (object.price != null) { + if (typeof object.price !== "object") + throw TypeError(".google.cloud.retail.v2beta.PriceInfo.PriceRange.price: object expected"); + message.price = $root.google.cloud.retail.v2beta.Interval.fromObject(object.price); + } + if (object.originalPrice != null) { + if (typeof object.originalPrice !== "object") + throw TypeError(".google.cloud.retail.v2beta.PriceInfo.PriceRange.originalPrice: object expected"); + message.originalPrice = $root.google.cloud.retail.v2beta.Interval.fromObject(object.originalPrice); + } + return message; + }; + + /** + * Creates a plain object from a PriceRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {google.cloud.retail.v2beta.PriceInfo.PriceRange} message PriceRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PriceRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.price = null; + object.originalPrice = null; + } + if (message.price != null && message.hasOwnProperty("price")) + object.price = $root.google.cloud.retail.v2beta.Interval.toObject(message.price, options); + if (message.originalPrice != null && message.hasOwnProperty("originalPrice")) + object.originalPrice = $root.google.cloud.retail.v2beta.Interval.toObject(message.originalPrice, options); + return object; + }; + + /** + * Converts this PriceRange to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @instance + * @returns {Object.} JSON object + */ + PriceRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PriceRange + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PriceInfo.PriceRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PriceRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PriceInfo.PriceRange"; + }; + + return PriceRange; + })(); + + return PriceInfo; + })(); + + v2beta.Rating = (function() { + + /** + * Properties of a Rating. + * @memberof google.cloud.retail.v2beta + * @interface IRating + * @property {number|null} [ratingCount] Rating ratingCount + * @property {number|null} [averageRating] Rating averageRating + * @property {Array.|null} [ratingHistogram] Rating ratingHistogram + */ + + /** + * Constructs a new Rating. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Rating. + * @implements IRating + * @constructor + * @param {google.cloud.retail.v2beta.IRating=} [properties] Properties to set + */ + function Rating(properties) { + this.ratingHistogram = []; + 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]]; + } + + /** + * Rating ratingCount. + * @member {number} ratingCount + * @memberof google.cloud.retail.v2beta.Rating + * @instance + */ + Rating.prototype.ratingCount = 0; + + /** + * Rating averageRating. + * @member {number} averageRating + * @memberof google.cloud.retail.v2beta.Rating + * @instance + */ + Rating.prototype.averageRating = 0; + + /** + * Rating ratingHistogram. + * @member {Array.} ratingHistogram + * @memberof google.cloud.retail.v2beta.Rating + * @instance + */ + Rating.prototype.ratingHistogram = $util.emptyArray; + + /** + * Creates a new Rating instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {google.cloud.retail.v2beta.IRating=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Rating} Rating instance + */ + Rating.create = function create(properties) { + return new Rating(properties); + }; + + /** + * Encodes the specified Rating message. Does not implicitly {@link google.cloud.retail.v2beta.Rating.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {google.cloud.retail.v2beta.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ratingCount != null && Object.hasOwnProperty.call(message, "ratingCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ratingCount); + if (message.averageRating != null && Object.hasOwnProperty.call(message, "averageRating")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.averageRating); + if (message.ratingHistogram != null && message.ratingHistogram.length) { + writer.uint32(/* id 3, wireType 2 =*/26).fork(); + for (var i = 0; i < message.ratingHistogram.length; ++i) + writer.int32(message.ratingHistogram[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Rating message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Rating.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {google.cloud.retail.v2beta.IRating} message Rating message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Rating.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Rating message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.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.cloud.retail.v2beta.Rating(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ratingCount = reader.int32(); + break; + } + case 2: { + message.averageRating = reader.float(); + break; + } + case 3: { + if (!(message.ratingHistogram && message.ratingHistogram.length)) + message.ratingHistogram = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.ratingHistogram.push(reader.int32()); + } else + message.ratingHistogram.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Rating message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Rating} Rating + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Rating.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Rating message. + * @function verify + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Rating.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + if (!$util.isInteger(message.ratingCount)) + return "ratingCount: integer expected"; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + if (typeof message.averageRating !== "number") + return "averageRating: number expected"; + if (message.ratingHistogram != null && message.hasOwnProperty("ratingHistogram")) { + if (!Array.isArray(message.ratingHistogram)) + return "ratingHistogram: array expected"; + for (var i = 0; i < message.ratingHistogram.length; ++i) + if (!$util.isInteger(message.ratingHistogram[i])) + return "ratingHistogram: integer[] expected"; + } + return null; + }; + + /** + * Creates a Rating message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Rating} Rating + */ + Rating.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Rating) + return object; + var message = new $root.google.cloud.retail.v2beta.Rating(); + if (object.ratingCount != null) + message.ratingCount = object.ratingCount | 0; + if (object.averageRating != null) + message.averageRating = Number(object.averageRating); + if (object.ratingHistogram) { + if (!Array.isArray(object.ratingHistogram)) + throw TypeError(".google.cloud.retail.v2beta.Rating.ratingHistogram: array expected"); + message.ratingHistogram = []; + for (var i = 0; i < object.ratingHistogram.length; ++i) + message.ratingHistogram[i] = object.ratingHistogram[i] | 0; + } + return message; + }; + + /** + * Creates a plain object from a Rating message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {google.cloud.retail.v2beta.Rating} message Rating + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Rating.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.ratingHistogram = []; + if (options.defaults) { + object.ratingCount = 0; + object.averageRating = 0; + } + if (message.ratingCount != null && message.hasOwnProperty("ratingCount")) + object.ratingCount = message.ratingCount; + if (message.averageRating != null && message.hasOwnProperty("averageRating")) + object.averageRating = options.json && !isFinite(message.averageRating) ? String(message.averageRating) : message.averageRating; + if (message.ratingHistogram && message.ratingHistogram.length) { + object.ratingHistogram = []; + for (var j = 0; j < message.ratingHistogram.length; ++j) + object.ratingHistogram[j] = message.ratingHistogram[j]; + } + return object; + }; + + /** + * Converts this Rating to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Rating + * @instance + * @returns {Object.} JSON object + */ + Rating.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Rating + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Rating + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Rating.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Rating"; + }; + + return Rating; + })(); + + v2beta.UserInfo = (function() { + + /** + * Properties of a UserInfo. + * @memberof google.cloud.retail.v2beta + * @interface IUserInfo + * @property {string|null} [userId] UserInfo userId + * @property {string|null} [ipAddress] UserInfo ipAddress + * @property {string|null} [userAgent] UserInfo userAgent + * @property {boolean|null} [directUserRequest] UserInfo directUserRequest + */ + + /** + * Constructs a new UserInfo. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserInfo. + * @implements IUserInfo + * @constructor + * @param {google.cloud.retail.v2beta.IUserInfo=} [properties] Properties to set + */ + function UserInfo(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]]; + } + + /** + * UserInfo userId. + * @member {string} userId + * @memberof google.cloud.retail.v2beta.UserInfo + * @instance + */ + UserInfo.prototype.userId = ""; + + /** + * UserInfo ipAddress. + * @member {string} ipAddress + * @memberof google.cloud.retail.v2beta.UserInfo + * @instance + */ + UserInfo.prototype.ipAddress = ""; + + /** + * UserInfo userAgent. + * @member {string} userAgent + * @memberof google.cloud.retail.v2beta.UserInfo + * @instance + */ + UserInfo.prototype.userAgent = ""; + + /** + * UserInfo directUserRequest. + * @member {boolean} directUserRequest + * @memberof google.cloud.retail.v2beta.UserInfo + * @instance + */ + UserInfo.prototype.directUserRequest = false; + + /** + * Creates a new UserInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {google.cloud.retail.v2beta.IUserInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UserInfo} UserInfo instance + */ + UserInfo.create = function create(properties) { + return new UserInfo(properties); + }; + + /** + * Encodes the specified UserInfo message. Does not implicitly {@link google.cloud.retail.v2beta.UserInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {google.cloud.retail.v2beta.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userId != null && Object.hasOwnProperty.call(message, "userId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.userId); + if (message.ipAddress != null && Object.hasOwnProperty.call(message, "ipAddress")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.ipAddress); + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.userAgent); + if (message.directUserRequest != null && Object.hasOwnProperty.call(message, "directUserRequest")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.directUserRequest); + return writer; + }; + + /** + * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {google.cloud.retail.v2beta.IUserInfo} message UserInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.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.cloud.retail.v2beta.UserInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userId = reader.string(); + break; + } + case 2: { + message.ipAddress = reader.string(); + break; + } + case 3: { + message.userAgent = reader.string(); + break; + } + case 4: { + message.directUserRequest = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UserInfo} UserInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserInfo message. + * @function verify + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userId != null && message.hasOwnProperty("userId")) + if (!$util.isString(message.userId)) + return "userId: string expected"; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + if (!$util.isString(message.ipAddress)) + return "ipAddress: string expected"; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + if (!$util.isString(message.userAgent)) + return "userAgent: string expected"; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + if (typeof message.directUserRequest !== "boolean") + return "directUserRequest: boolean expected"; + return null; + }; + + /** + * Creates a UserInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UserInfo} UserInfo + */ + UserInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UserInfo) + return object; + var message = new $root.google.cloud.retail.v2beta.UserInfo(); + if (object.userId != null) + message.userId = String(object.userId); + if (object.ipAddress != null) + message.ipAddress = String(object.ipAddress); + if (object.userAgent != null) + message.userAgent = String(object.userAgent); + if (object.directUserRequest != null) + message.directUserRequest = Boolean(object.directUserRequest); + return message; + }; + + /** + * Creates a plain object from a UserInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {google.cloud.retail.v2beta.UserInfo} message UserInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.userId = ""; + object.ipAddress = ""; + object.userAgent = ""; + object.directUserRequest = false; + } + if (message.userId != null && message.hasOwnProperty("userId")) + object.userId = message.userId; + if (message.ipAddress != null && message.hasOwnProperty("ipAddress")) + object.ipAddress = message.ipAddress; + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + object.userAgent = message.userAgent; + if (message.directUserRequest != null && message.hasOwnProperty("directUserRequest")) + object.directUserRequest = message.directUserRequest; + return object; + }; + + /** + * Converts this UserInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UserInfo + * @instance + * @returns {Object.} JSON object + */ + UserInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UserInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UserInfo"; + }; + + return UserInfo; + })(); + + v2beta.LocalInventory = (function() { + + /** + * Properties of a LocalInventory. + * @memberof google.cloud.retail.v2beta + * @interface ILocalInventory + * @property {string|null} [placeId] LocalInventory placeId + * @property {google.cloud.retail.v2beta.IPriceInfo|null} [priceInfo] LocalInventory priceInfo + * @property {Object.|null} [attributes] LocalInventory attributes + * @property {Array.|null} [fulfillmentTypes] LocalInventory fulfillmentTypes + */ + + /** + * Constructs a new LocalInventory. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a LocalInventory. + * @implements ILocalInventory + * @constructor + * @param {google.cloud.retail.v2beta.ILocalInventory=} [properties] Properties to set + */ + function LocalInventory(properties) { + this.attributes = {}; + this.fulfillmentTypes = []; + 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]]; + } + + /** + * LocalInventory placeId. + * @member {string} placeId + * @memberof google.cloud.retail.v2beta.LocalInventory + * @instance + */ + LocalInventory.prototype.placeId = ""; + + /** + * LocalInventory priceInfo. + * @member {google.cloud.retail.v2beta.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2beta.LocalInventory + * @instance + */ + LocalInventory.prototype.priceInfo = null; + + /** + * LocalInventory attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2beta.LocalInventory + * @instance + */ + LocalInventory.prototype.attributes = $util.emptyObject; + + /** + * LocalInventory fulfillmentTypes. + * @member {Array.} fulfillmentTypes + * @memberof google.cloud.retail.v2beta.LocalInventory + * @instance + */ + LocalInventory.prototype.fulfillmentTypes = $util.emptyArray; + + /** + * Creates a new LocalInventory instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {google.cloud.retail.v2beta.ILocalInventory=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.LocalInventory} LocalInventory instance + */ + LocalInventory.create = function create(properties) { + return new LocalInventory(properties); + }; + + /** + * Encodes the specified LocalInventory message. Does not implicitly {@link google.cloud.retail.v2beta.LocalInventory.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {google.cloud.retail.v2beta.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placeId != null && Object.hasOwnProperty.call(message, "placeId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placeId); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2beta.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2beta.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.fulfillmentTypes != null && message.fulfillmentTypes.length) + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.fulfillmentTypes[i]); + return writer; + }; + + /** + * Encodes the specified LocalInventory message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.LocalInventory.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {google.cloud.retail.v2beta.ILocalInventory} message LocalInventory message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalInventory.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.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.cloud.retail.v2beta.LocalInventory(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placeId = reader.string(); + break; + } + case 2: { + message.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 3: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2beta.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 4: { + if (!(message.fulfillmentTypes && message.fulfillmentTypes.length)) + message.fulfillmentTypes = []; + message.fulfillmentTypes.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LocalInventory message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.LocalInventory} LocalInventory + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalInventory.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LocalInventory message. + * @function verify + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LocalInventory.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placeId != null && message.hasOwnProperty("placeId")) + if (!$util.isString(message.placeId)) + return "placeId: string expected"; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2beta.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.fulfillmentTypes != null && message.hasOwnProperty("fulfillmentTypes")) { + if (!Array.isArray(message.fulfillmentTypes)) + return "fulfillmentTypes: array expected"; + for (var i = 0; i < message.fulfillmentTypes.length; ++i) + if (!$util.isString(message.fulfillmentTypes[i])) + return "fulfillmentTypes: string[] expected"; + } + return null; + }; + + /** + * Creates a LocalInventory message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.LocalInventory} LocalInventory + */ + LocalInventory.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.LocalInventory) + return object; + var message = new $root.google.cloud.retail.v2beta.LocalInventory(); + if (object.placeId != null) + message.placeId = String(object.placeId); + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.LocalInventory.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.fromObject(object.priceInfo); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2beta.LocalInventory.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.LocalInventory.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2beta.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.fulfillmentTypes) { + if (!Array.isArray(object.fulfillmentTypes)) + throw TypeError(".google.cloud.retail.v2beta.LocalInventory.fulfillmentTypes: array expected"); + message.fulfillmentTypes = []; + for (var i = 0; i < object.fulfillmentTypes.length; ++i) + message.fulfillmentTypes[i] = String(object.fulfillmentTypes[i]); + } + return message; + }; + + /** + * Creates a plain object from a LocalInventory message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {google.cloud.retail.v2beta.LocalInventory} message LocalInventory + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocalInventory.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.fulfillmentTypes = []; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.placeId = ""; + object.priceInfo = null; + } + if (message.placeId != null && message.hasOwnProperty("placeId")) + object.placeId = message.placeId; + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.toObject(message.priceInfo, options); + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2beta.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.fulfillmentTypes && message.fulfillmentTypes.length) { + object.fulfillmentTypes = []; + for (var j = 0; j < message.fulfillmentTypes.length; ++j) + object.fulfillmentTypes[j] = message.fulfillmentTypes[j]; + } + return object; + }; + + /** + * Converts this LocalInventory to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.LocalInventory + * @instance + * @returns {Object.} JSON object + */ + LocalInventory.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LocalInventory + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.LocalInventory + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LocalInventory.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.LocalInventory"; + }; + + return LocalInventory; + })(); + + v2beta.GcsSource = (function() { + + /** + * Properties of a GcsSource. + * @memberof google.cloud.retail.v2beta + * @interface IGcsSource + * @property {Array.|null} [inputUris] GcsSource inputUris + * @property {string|null} [dataSchema] GcsSource dataSchema + */ + + /** + * Constructs a new GcsSource. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GcsSource. + * @implements IGcsSource + * @constructor + * @param {google.cloud.retail.v2beta.IGcsSource=} [properties] Properties to set + */ + function GcsSource(properties) { + this.inputUris = []; + 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]]; + } + + /** + * GcsSource inputUris. + * @member {Array.} inputUris + * @memberof google.cloud.retail.v2beta.GcsSource + * @instance + */ + GcsSource.prototype.inputUris = $util.emptyArray; + + /** + * GcsSource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2beta.GcsSource + * @instance + */ + GcsSource.prototype.dataSchema = ""; + + /** + * Creates a new GcsSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {google.cloud.retail.v2beta.IGcsSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GcsSource} GcsSource instance + */ + GcsSource.create = function create(properties) { + return new GcsSource(properties); + }; + + /** + * Encodes the specified GcsSource message. Does not implicitly {@link google.cloud.retail.v2beta.GcsSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {google.cloud.retail.v2beta.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inputUris != null && message.inputUris.length) + for (var i = 0; i < message.inputUris.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.inputUris[i]); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.dataSchema); + return writer; + }; + + /** + * Encodes the specified GcsSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GcsSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {google.cloud.retail.v2beta.IGcsSource} message GcsSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GcsSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.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.cloud.retail.v2beta.GcsSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.inputUris && message.inputUris.length)) + message.inputUris = []; + message.inputUris.push(reader.string()); + break; + } + case 2: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GcsSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GcsSource} GcsSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GcsSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GcsSource message. + * @function verify + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GcsSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inputUris != null && message.hasOwnProperty("inputUris")) { + if (!Array.isArray(message.inputUris)) + return "inputUris: array expected"; + for (var i = 0; i < message.inputUris.length; ++i) + if (!$util.isString(message.inputUris[i])) + return "inputUris: string[] expected"; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a GcsSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GcsSource} GcsSource + */ + GcsSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GcsSource) + return object; + var message = new $root.google.cloud.retail.v2beta.GcsSource(); + if (object.inputUris) { + if (!Array.isArray(object.inputUris)) + throw TypeError(".google.cloud.retail.v2beta.GcsSource.inputUris: array expected"); + message.inputUris = []; + for (var i = 0; i < object.inputUris.length; ++i) + message.inputUris[i] = String(object.inputUris[i]); + } + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a GcsSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {google.cloud.retail.v2beta.GcsSource} message GcsSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GcsSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.inputUris = []; + if (options.defaults) + object.dataSchema = ""; + if (message.inputUris && message.inputUris.length) { + object.inputUris = []; + for (var j = 0; j < message.inputUris.length; ++j) + object.inputUris[j] = message.inputUris[j]; + } + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + return object; + }; + + /** + * Converts this GcsSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GcsSource + * @instance + * @returns {Object.} JSON object + */ + GcsSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GcsSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GcsSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GcsSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GcsSource"; + }; + + return GcsSource; + })(); + + v2beta.BigQuerySource = (function() { + + /** + * Properties of a BigQuerySource. + * @memberof google.cloud.retail.v2beta + * @interface IBigQuerySource + * @property {google.type.IDate|null} [partitionDate] BigQuerySource partitionDate + * @property {string|null} [projectId] BigQuerySource projectId + * @property {string|null} [datasetId] BigQuerySource datasetId + * @property {string|null} [tableId] BigQuerySource tableId + * @property {string|null} [gcsStagingDir] BigQuerySource gcsStagingDir + * @property {string|null} [dataSchema] BigQuerySource dataSchema + */ + + /** + * Constructs a new BigQuerySource. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a BigQuerySource. + * @implements IBigQuerySource + * @constructor + * @param {google.cloud.retail.v2beta.IBigQuerySource=} [properties] Properties to set + */ + function BigQuerySource(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]]; + } + + /** + * BigQuerySource partitionDate. + * @member {google.type.IDate|null|undefined} partitionDate + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.partitionDate = null; + + /** + * BigQuerySource projectId. + * @member {string} projectId + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.projectId = ""; + + /** + * BigQuerySource datasetId. + * @member {string} datasetId + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.datasetId = ""; + + /** + * BigQuerySource tableId. + * @member {string} tableId + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.tableId = ""; + + /** + * BigQuerySource gcsStagingDir. + * @member {string} gcsStagingDir + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.gcsStagingDir = ""; + + /** + * BigQuerySource dataSchema. + * @member {string} dataSchema + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + BigQuerySource.prototype.dataSchema = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BigQuerySource partition. + * @member {"partitionDate"|undefined} partition + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + */ + Object.defineProperty(BigQuerySource.prototype, "partition", { + get: $util.oneOfGetter($oneOfFields = ["partitionDate"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BigQuerySource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {google.cloud.retail.v2beta.IBigQuerySource=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.BigQuerySource} BigQuerySource instance + */ + BigQuerySource.create = function create(properties) { + return new BigQuerySource(properties); + }; + + /** + * Encodes the specified BigQuerySource message. Does not implicitly {@link google.cloud.retail.v2beta.BigQuerySource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {google.cloud.retail.v2beta.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.datasetId != null && Object.hasOwnProperty.call(message, "datasetId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.datasetId); + if (message.tableId != null && Object.hasOwnProperty.call(message, "tableId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.tableId); + if (message.gcsStagingDir != null && Object.hasOwnProperty.call(message, "gcsStagingDir")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.gcsStagingDir); + if (message.dataSchema != null && Object.hasOwnProperty.call(message, "dataSchema")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.dataSchema); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.projectId); + if (message.partitionDate != null && Object.hasOwnProperty.call(message, "partitionDate")) + $root.google.type.Date.encode(message.partitionDate, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BigQuerySource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BigQuerySource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {google.cloud.retail.v2beta.IBigQuerySource} message BigQuerySource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQuerySource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.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.cloud.retail.v2beta.BigQuerySource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + message.partitionDate = $root.google.type.Date.decode(reader, reader.uint32()); + break; + } + case 5: { + message.projectId = reader.string(); + break; + } + case 1: { + message.datasetId = reader.string(); + break; + } + case 2: { + message.tableId = reader.string(); + break; + } + case 3: { + message.gcsStagingDir = reader.string(); + break; + } + case 4: { + message.dataSchema = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQuerySource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.BigQuerySource} BigQuerySource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQuerySource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQuerySource message. + * @function verify + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQuerySource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + properties.partition = 1; + { + var error = $root.google.type.Date.verify(message.partitionDate); + if (error) + return "partitionDate." + error; + } + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + if (!$util.isString(message.datasetId)) + return "datasetId: string expected"; + if (message.tableId != null && message.hasOwnProperty("tableId")) + if (!$util.isString(message.tableId)) + return "tableId: string expected"; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + if (!$util.isString(message.gcsStagingDir)) + return "gcsStagingDir: string expected"; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + if (!$util.isString(message.dataSchema)) + return "dataSchema: string expected"; + return null; + }; + + /** + * Creates a BigQuerySource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.BigQuerySource} BigQuerySource + */ + BigQuerySource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.BigQuerySource) + return object; + var message = new $root.google.cloud.retail.v2beta.BigQuerySource(); + if (object.partitionDate != null) { + if (typeof object.partitionDate !== "object") + throw TypeError(".google.cloud.retail.v2beta.BigQuerySource.partitionDate: object expected"); + message.partitionDate = $root.google.type.Date.fromObject(object.partitionDate); + } + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.datasetId != null) + message.datasetId = String(object.datasetId); + if (object.tableId != null) + message.tableId = String(object.tableId); + if (object.gcsStagingDir != null) + message.gcsStagingDir = String(object.gcsStagingDir); + if (object.dataSchema != null) + message.dataSchema = String(object.dataSchema); + return message; + }; + + /** + * Creates a plain object from a BigQuerySource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {google.cloud.retail.v2beta.BigQuerySource} message BigQuerySource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQuerySource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.datasetId = ""; + object.tableId = ""; + object.gcsStagingDir = ""; + object.dataSchema = ""; + object.projectId = ""; + } + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + object.datasetId = message.datasetId; + if (message.tableId != null && message.hasOwnProperty("tableId")) + object.tableId = message.tableId; + if (message.gcsStagingDir != null && message.hasOwnProperty("gcsStagingDir")) + object.gcsStagingDir = message.gcsStagingDir; + if (message.dataSchema != null && message.hasOwnProperty("dataSchema")) + object.dataSchema = message.dataSchema; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.partitionDate != null && message.hasOwnProperty("partitionDate")) { + object.partitionDate = $root.google.type.Date.toObject(message.partitionDate, options); + if (options.oneofs) + object.partition = "partitionDate"; + } + return object; + }; + + /** + * Converts this BigQuerySource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @instance + * @returns {Object.} JSON object + */ + BigQuerySource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BigQuerySource + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.BigQuerySource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BigQuerySource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.BigQuerySource"; + }; + + return BigQuerySource; + })(); + + v2beta.ProductInlineSource = (function() { + + /** + * Properties of a ProductInlineSource. + * @memberof google.cloud.retail.v2beta + * @interface IProductInlineSource + * @property {Array.|null} [products] ProductInlineSource products + */ + + /** + * Constructs a new ProductInlineSource. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ProductInlineSource. + * @implements IProductInlineSource + * @constructor + * @param {google.cloud.retail.v2beta.IProductInlineSource=} [properties] Properties to set + */ + function ProductInlineSource(properties) { + this.products = []; + 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]]; + } + + /** + * ProductInlineSource products. + * @member {Array.} products + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @instance + */ + ProductInlineSource.prototype.products = $util.emptyArray; + + /** + * Creates a new ProductInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {google.cloud.retail.v2beta.IProductInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ProductInlineSource} ProductInlineSource instance + */ + ProductInlineSource.create = function create(properties) { + return new ProductInlineSource(properties); + }; + + /** + * Encodes the specified ProductInlineSource message. Does not implicitly {@link google.cloud.retail.v2beta.ProductInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {google.cloud.retail.v2beta.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2beta.Product.encode(message.products[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {google.cloud.retail.v2beta.IProductInlineSource} message ProductInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.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.cloud.retail.v2beta.ProductInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ProductInlineSource} ProductInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + return null; + }; + + /** + * Creates a ProductInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ProductInlineSource} ProductInlineSource + */ + ProductInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ProductInlineSource) + return object; + var message = new $root.google.cloud.retail.v2beta.ProductInlineSource(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2beta.ProductInlineSource.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductInlineSource.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2beta.Product.fromObject(object.products[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ProductInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {google.cloud.retail.v2beta.ProductInlineSource} message ProductInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2beta.Product.toObject(message.products[j], options); + } + return object; + }; + + /** + * Converts this ProductInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @instance + * @returns {Object.} JSON object + */ + ProductInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ProductInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ProductInlineSource"; + }; + + return ProductInlineSource; + })(); + + v2beta.UserEventInlineSource = (function() { + + /** + * Properties of a UserEventInlineSource. + * @memberof google.cloud.retail.v2beta + * @interface IUserEventInlineSource + * @property {Array.|null} [userEvents] UserEventInlineSource userEvents + */ + + /** + * Constructs a new UserEventInlineSource. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserEventInlineSource. + * @implements IUserEventInlineSource + * @constructor + * @param {google.cloud.retail.v2beta.IUserEventInlineSource=} [properties] Properties to set + */ + function UserEventInlineSource(properties) { + this.userEvents = []; + 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]]; + } + + /** + * UserEventInlineSource userEvents. + * @member {Array.} userEvents + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @instance + */ + UserEventInlineSource.prototype.userEvents = $util.emptyArray; + + /** + * Creates a new UserEventInlineSource instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2beta.IUserEventInlineSource=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UserEventInlineSource} UserEventInlineSource instance + */ + UserEventInlineSource.create = function create(properties) { + return new UserEventInlineSource(properties); + }; + + /** + * Encodes the specified UserEventInlineSource message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInlineSource.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2beta.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEvents != null && message.userEvents.length) + for (var i = 0; i < message.userEvents.length; ++i) + $root.google.cloud.retail.v2beta.UserEvent.encode(message.userEvents[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInlineSource message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInlineSource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2beta.IUserEventInlineSource} message UserEventInlineSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInlineSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.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.cloud.retail.v2beta.UserEventInlineSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.userEvents && message.userEvents.length)) + message.userEvents = []; + message.userEvents.push($root.google.cloud.retail.v2beta.UserEvent.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInlineSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UserEventInlineSource} UserEventInlineSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInlineSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInlineSource message. + * @function verify + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInlineSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userEvents != null && message.hasOwnProperty("userEvents")) { + if (!Array.isArray(message.userEvents)) + return "userEvents: array expected"; + for (var i = 0; i < message.userEvents.length; ++i) { + var error = $root.google.cloud.retail.v2beta.UserEvent.verify(message.userEvents[i]); + if (error) + return "userEvents." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInlineSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UserEventInlineSource} UserEventInlineSource + */ + UserEventInlineSource.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UserEventInlineSource) + return object; + var message = new $root.google.cloud.retail.v2beta.UserEventInlineSource(); + if (object.userEvents) { + if (!Array.isArray(object.userEvents)) + throw TypeError(".google.cloud.retail.v2beta.UserEventInlineSource.userEvents: array expected"); + message.userEvents = []; + for (var i = 0; i < object.userEvents.length; ++i) { + if (typeof object.userEvents[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEventInlineSource.userEvents: object expected"); + message.userEvents[i] = $root.google.cloud.retail.v2beta.UserEvent.fromObject(object.userEvents[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a UserEventInlineSource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {google.cloud.retail.v2beta.UserEventInlineSource} message UserEventInlineSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInlineSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.userEvents = []; + if (message.userEvents && message.userEvents.length) { + object.userEvents = []; + for (var j = 0; j < message.userEvents.length; ++j) + object.userEvents[j] = $root.google.cloud.retail.v2beta.UserEvent.toObject(message.userEvents[j], options); + } + return object; + }; + + /** + * Converts this UserEventInlineSource to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @instance + * @returns {Object.} JSON object + */ + UserEventInlineSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInlineSource + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UserEventInlineSource + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInlineSource.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UserEventInlineSource"; + }; + + return UserEventInlineSource; + })(); + + v2beta.ImportErrorsConfig = (function() { + + /** + * Properties of an ImportErrorsConfig. + * @memberof google.cloud.retail.v2beta + * @interface IImportErrorsConfig + * @property {string|null} [gcsPrefix] ImportErrorsConfig gcsPrefix + */ + + /** + * Constructs a new ImportErrorsConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportErrorsConfig. + * @implements IImportErrorsConfig + * @constructor + * @param {google.cloud.retail.v2beta.IImportErrorsConfig=} [properties] Properties to set + */ + function ImportErrorsConfig(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]]; + } + + /** + * ImportErrorsConfig gcsPrefix. + * @member {string|null|undefined} gcsPrefix + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @instance + */ + ImportErrorsConfig.prototype.gcsPrefix = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ImportErrorsConfig destination. + * @member {"gcsPrefix"|undefined} destination + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @instance + */ + Object.defineProperty(ImportErrorsConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsPrefix"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ImportErrorsConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IImportErrorsConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportErrorsConfig} ImportErrorsConfig instance + */ + ImportErrorsConfig.create = function create(properties) { + return new ImportErrorsConfig(properties); + }; + + /** + * Encodes the specified ImportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ImportErrorsConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsPrefix != null && Object.hasOwnProperty.call(message, "gcsPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsPrefix); + return writer; + }; + + /** + * Encodes the specified ImportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportErrorsConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IImportErrorsConfig} message ImportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportErrorsConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.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.cloud.retail.v2beta.ImportErrorsConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportErrorsConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportErrorsConfig} ImportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportErrorsConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportErrorsConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportErrorsConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + properties.destination = 1; + if (!$util.isString(message.gcsPrefix)) + return "gcsPrefix: string expected"; + } + return null; + }; + + /** + * Creates an ImportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportErrorsConfig} ImportErrorsConfig + */ + ImportErrorsConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportErrorsConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportErrorsConfig(); + if (object.gcsPrefix != null) + message.gcsPrefix = String(object.gcsPrefix); + return message; + }; + + /** + * Creates a plain object from an ImportErrorsConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} message ImportErrorsConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportErrorsConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + object.gcsPrefix = message.gcsPrefix; + if (options.oneofs) + object.destination = "gcsPrefix"; + } + return object; + }; + + /** + * Converts this ImportErrorsConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @instance + * @returns {Object.} JSON object + */ + ImportErrorsConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportErrorsConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportErrorsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportErrorsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportErrorsConfig"; + }; + + return ImportErrorsConfig; + })(); + + v2beta.ImportProductsRequest = (function() { + + /** + * Properties of an ImportProductsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IImportProductsRequest + * @property {string|null} [parent] ImportProductsRequest parent + * @property {string|null} [requestId] ImportProductsRequest requestId + * @property {google.cloud.retail.v2beta.IProductInputConfig|null} [inputConfig] ImportProductsRequest inputConfig + * @property {google.cloud.retail.v2beta.IImportErrorsConfig|null} [errorsConfig] ImportProductsRequest errorsConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] ImportProductsRequest updateMask + * @property {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode|null} [reconciliationMode] ImportProductsRequest reconciliationMode + * @property {string|null} [notificationPubsubTopic] ImportProductsRequest notificationPubsubTopic + */ + + /** + * Constructs a new ImportProductsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportProductsRequest. + * @implements IImportProductsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IImportProductsRequest=} [properties] Properties to set + */ + function ImportProductsRequest(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]]; + } + + /** + * ImportProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.parent = ""; + + /** + * ImportProductsRequest requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.requestId = ""; + + /** + * ImportProductsRequest inputConfig. + * @member {google.cloud.retail.v2beta.IProductInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.inputConfig = null; + + /** + * ImportProductsRequest errorsConfig. + * @member {google.cloud.retail.v2beta.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.errorsConfig = null; + + /** + * ImportProductsRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.updateMask = null; + + /** + * ImportProductsRequest reconciliationMode. + * @member {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} reconciliationMode + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.reconciliationMode = 0; + + /** + * ImportProductsRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + */ + ImportProductsRequest.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportProductsRequest} ImportProductsRequest instance + */ + ImportProductsRequest.create = function create(properties) { + return new ImportProductsRequest(properties); + }; + + /** + * Encodes the specified ImportProductsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2beta.ProductInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.reconciliationMode != null && Object.hasOwnProperty.call(message, "reconciliationMode")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.reconciliationMode); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportProductsRequest} message ImportProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.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.cloud.retail.v2beta.ImportProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 6: { + message.requestId = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2beta.ProductInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.reconciliationMode = reader.int32(); + break; + } + case 7: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportProductsRequest} ImportProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2beta.ProductInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + switch (message.reconciliationMode) { + default: + return "reconciliationMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportProductsRequest} ImportProductsRequest + */ + ImportProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportProductsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2beta.ProductInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportProductsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportProductsRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + switch (object.reconciliationMode) { + default: + if (typeof object.reconciliationMode === "number") { + message.reconciliationMode = object.reconciliationMode; + break; + } + break; + case "RECONCILIATION_MODE_UNSPECIFIED": + case 0: + message.reconciliationMode = 0; + break; + case "INCREMENTAL": + case 1: + message.reconciliationMode = 1; + break; + case "FULL": + case 2: + message.reconciliationMode = 2; + break; + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {google.cloud.retail.v2beta.ImportProductsRequest} message ImportProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + object.updateMask = null; + object.reconciliationMode = options.enums === String ? "RECONCILIATION_MODE_UNSPECIFIED" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2beta.ProductInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.reconciliationMode != null && message.hasOwnProperty("reconciliationMode")) + object.reconciliationMode = options.enums === String ? $root.google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] === undefined ? message.reconciliationMode : $root.google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode[message.reconciliationMode] : message.reconciliationMode; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportProductsRequest"; + }; + + /** + * ReconciliationMode enum. + * @name google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode + * @enum {number} + * @property {number} RECONCILIATION_MODE_UNSPECIFIED=0 RECONCILIATION_MODE_UNSPECIFIED value + * @property {number} INCREMENTAL=1 INCREMENTAL value + * @property {number} FULL=2 FULL value + */ + ImportProductsRequest.ReconciliationMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RECONCILIATION_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INCREMENTAL"] = 1; + values[valuesById[2] = "FULL"] = 2; + return values; + })(); + + return ImportProductsRequest; + })(); + + v2beta.ImportUserEventsRequest = (function() { + + /** + * Properties of an ImportUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IImportUserEventsRequest + * @property {string|null} [parent] ImportUserEventsRequest parent + * @property {google.cloud.retail.v2beta.IUserEventInputConfig|null} [inputConfig] ImportUserEventsRequest inputConfig + * @property {google.cloud.retail.v2beta.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsRequest errorsConfig + */ + + /** + * Constructs a new ImportUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportUserEventsRequest. + * @implements IImportUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest=} [properties] Properties to set + */ + function ImportUserEventsRequest(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]]; + } + + /** + * ImportUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.parent = ""; + + /** + * ImportUserEventsRequest inputConfig. + * @member {google.cloud.retail.v2beta.IUserEventInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.inputConfig = null; + + /** + * ImportUserEventsRequest errorsConfig. + * @member {google.cloud.retail.v2beta.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @instance + */ + ImportUserEventsRequest.prototype.errorsConfig = null; + + /** + * Creates a new ImportUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportUserEventsRequest} ImportUserEventsRequest instance + */ + ImportUserEventsRequest.create = function create(properties) { + return new ImportUserEventsRequest(properties); + }; + + /** + * Encodes the specified ImportUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2beta.UserEventInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest} message ImportUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.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.cloud.retail.v2beta.ImportUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2beta.UserEventInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportUserEventsRequest} ImportUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2beta.UserEventInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportUserEventsRequest} ImportUserEventsRequest + */ + ImportUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2beta.UserEventInputConfig.fromObject(object.inputConfig); + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsRequest.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.ImportUserEventsRequest} message ImportUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.errorsConfig = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2beta.UserEventInputConfig.toObject(message.inputConfig, options); + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportUserEventsRequest"; + }; + + return ImportUserEventsRequest; + })(); + + v2beta.ImportCompletionDataRequest = (function() { + + /** + * Properties of an ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2beta + * @interface IImportCompletionDataRequest + * @property {string|null} [parent] ImportCompletionDataRequest parent + * @property {google.cloud.retail.v2beta.ICompletionDataInputConfig|null} [inputConfig] ImportCompletionDataRequest inputConfig + * @property {string|null} [notificationPubsubTopic] ImportCompletionDataRequest notificationPubsubTopic + */ + + /** + * Constructs a new ImportCompletionDataRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportCompletionDataRequest. + * @implements IImportCompletionDataRequest + * @constructor + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest=} [properties] Properties to set + */ + function ImportCompletionDataRequest(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]]; + } + + /** + * ImportCompletionDataRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.parent = ""; + + /** + * ImportCompletionDataRequest inputConfig. + * @member {google.cloud.retail.v2beta.ICompletionDataInputConfig|null|undefined} inputConfig + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.inputConfig = null; + + /** + * ImportCompletionDataRequest notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @instance + */ + ImportCompletionDataRequest.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportCompletionDataRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportCompletionDataRequest} ImportCompletionDataRequest instance + */ + ImportCompletionDataRequest.create = function create(properties) { + return new ImportCompletionDataRequest(properties); + }; + + /** + * Encodes the specified ImportCompletionDataRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.inputConfig != null && Object.hasOwnProperty.call(message, "inputConfig")) + $root.google.cloud.retail.v2beta.CompletionDataInputConfig.encode(message.inputConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest} message ImportCompletionDataRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.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.cloud.retail.v2beta.ImportCompletionDataRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.inputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportCompletionDataRequest} ImportCompletionDataRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) { + var error = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.verify(message.inputConfig); + if (error) + return "inputConfig." + error; + } + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportCompletionDataRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportCompletionDataRequest} ImportCompletionDataRequest + */ + ImportCompletionDataRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportCompletionDataRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportCompletionDataRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.inputConfig != null) { + if (typeof object.inputConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportCompletionDataRequest.inputConfig: object expected"); + message.inputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.fromObject(object.inputConfig); + } + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {google.cloud.retail.v2beta.ImportCompletionDataRequest} message ImportCompletionDataRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.inputConfig = null; + object.notificationPubsubTopic = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.inputConfig != null && message.hasOwnProperty("inputConfig")) + object.inputConfig = $root.google.cloud.retail.v2beta.CompletionDataInputConfig.toObject(message.inputConfig, options); + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportCompletionDataRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportCompletionDataRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportCompletionDataRequest"; + }; + + return ImportCompletionDataRequest; + })(); + + v2beta.ProductInputConfig = (function() { + + /** + * Properties of a ProductInputConfig. + * @memberof google.cloud.retail.v2beta + * @interface IProductInputConfig + * @property {google.cloud.retail.v2beta.IProductInlineSource|null} [productInlineSource] ProductInputConfig productInlineSource + * @property {google.cloud.retail.v2beta.IGcsSource|null} [gcsSource] ProductInputConfig gcsSource + * @property {google.cloud.retail.v2beta.IBigQuerySource|null} [bigQuerySource] ProductInputConfig bigQuerySource + */ + + /** + * Constructs a new ProductInputConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ProductInputConfig. + * @implements IProductInputConfig + * @constructor + * @param {google.cloud.retail.v2beta.IProductInputConfig=} [properties] Properties to set + */ + function ProductInputConfig(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]]; + } + + /** + * ProductInputConfig productInlineSource. + * @member {google.cloud.retail.v2beta.IProductInlineSource|null|undefined} productInlineSource + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.productInlineSource = null; + + /** + * ProductInputConfig gcsSource. + * @member {google.cloud.retail.v2beta.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.gcsSource = null; + + /** + * ProductInputConfig bigQuerySource. + * @member {google.cloud.retail.v2beta.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @instance + */ + ProductInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ProductInputConfig source. + * @member {"productInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @instance + */ + Object.defineProperty(ProductInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["productInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ProductInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {google.cloud.retail.v2beta.IProductInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ProductInputConfig} ProductInputConfig instance + */ + ProductInputConfig.create = function create(properties) { + return new ProductInputConfig(properties); + }; + + /** + * Encodes the specified ProductInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ProductInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {google.cloud.retail.v2beta.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.productInlineSource != null && Object.hasOwnProperty.call(message, "productInlineSource")) + $root.google.cloud.retail.v2beta.ProductInlineSource.encode(message.productInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2beta.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2beta.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {google.cloud.retail.v2beta.IProductInputConfig} message ProductInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.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.cloud.retail.v2beta.ProductInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.productInlineSource = $root.google.cloud.retail.v2beta.ProductInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ProductInputConfig} ProductInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.ProductInlineSource.verify(message.productInlineSource); + if (error) + return "productInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a ProductInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ProductInputConfig} ProductInputConfig + */ + ProductInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ProductInputConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.ProductInputConfig(); + if (object.productInlineSource != null) { + if (typeof object.productInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductInputConfig.productInlineSource: object expected"); + message.productInlineSource = $root.google.cloud.retail.v2beta.ProductInlineSource.fromObject(object.productInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a ProductInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {google.cloud.retail.v2beta.ProductInputConfig} message ProductInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.productInlineSource != null && message.hasOwnProperty("productInlineSource")) { + object.productInlineSource = $root.google.cloud.retail.v2beta.ProductInlineSource.toObject(message.productInlineSource, options); + if (options.oneofs) + object.source = "productInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this ProductInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @instance + * @returns {Object.} JSON object + */ + ProductInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ProductInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ProductInputConfig"; + }; + + return ProductInputConfig; + })(); + + v2beta.UserEventInputConfig = (function() { + + /** + * Properties of a UserEventInputConfig. + * @memberof google.cloud.retail.v2beta + * @interface IUserEventInputConfig + * @property {google.cloud.retail.v2beta.IUserEventInlineSource|null} [userEventInlineSource] UserEventInputConfig userEventInlineSource + * @property {google.cloud.retail.v2beta.IGcsSource|null} [gcsSource] UserEventInputConfig gcsSource + * @property {google.cloud.retail.v2beta.IBigQuerySource|null} [bigQuerySource] UserEventInputConfig bigQuerySource + */ + + /** + * Constructs a new UserEventInputConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserEventInputConfig. + * @implements IUserEventInputConfig + * @constructor + * @param {google.cloud.retail.v2beta.IUserEventInputConfig=} [properties] Properties to set + */ + function UserEventInputConfig(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]]; + } + + /** + * UserEventInputConfig userEventInlineSource. + * @member {google.cloud.retail.v2beta.IUserEventInlineSource|null|undefined} userEventInlineSource + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.userEventInlineSource = null; + + /** + * UserEventInputConfig gcsSource. + * @member {google.cloud.retail.v2beta.IGcsSource|null|undefined} gcsSource + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.gcsSource = null; + + /** + * UserEventInputConfig bigQuerySource. + * @member {google.cloud.retail.v2beta.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @instance + */ + UserEventInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * UserEventInputConfig source. + * @member {"userEventInlineSource"|"gcsSource"|"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @instance + */ + Object.defineProperty(UserEventInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["userEventInlineSource", "gcsSource", "bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new UserEventInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2beta.IUserEventInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UserEventInputConfig} UserEventInputConfig instance + */ + UserEventInputConfig.create = function create(properties) { + return new UserEventInputConfig(properties); + }; + + /** + * Encodes the specified UserEventInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2beta.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userEventInlineSource != null && Object.hasOwnProperty.call(message, "userEventInlineSource")) + $root.google.cloud.retail.v2beta.UserEventInlineSource.encode(message.userEventInlineSource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.gcsSource != null && Object.hasOwnProperty.call(message, "gcsSource")) + $root.google.cloud.retail.v2beta.GcsSource.encode(message.gcsSource, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2beta.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEventInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2beta.IUserEventInputConfig} message UserEventInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.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.cloud.retail.v2beta.UserEventInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.userEventInlineSource = $root.google.cloud.retail.v2beta.UserEventInlineSource.decode(reader, reader.uint32()); + break; + } + case 2: { + message.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.decode(reader, reader.uint32()); + break; + } + case 3: { + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UserEventInputConfig} UserEventInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.UserEventInlineSource.verify(message.userEventInlineSource); + if (error) + return "userEventInlineSource." + error; + } + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.GcsSource.verify(message.gcsSource); + if (error) + return "gcsSource." + error; + } + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + if (properties.source === 1) + return "source: multiple values"; + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a UserEventInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UserEventInputConfig} UserEventInputConfig + */ + UserEventInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UserEventInputConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.UserEventInputConfig(); + if (object.userEventInlineSource != null) { + if (typeof object.userEventInlineSource !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEventInputConfig.userEventInlineSource: object expected"); + message.userEventInlineSource = $root.google.cloud.retail.v2beta.UserEventInlineSource.fromObject(object.userEventInlineSource); + } + if (object.gcsSource != null) { + if (typeof object.gcsSource !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEventInputConfig.gcsSource: object expected"); + message.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.fromObject(object.gcsSource); + } + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEventInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a UserEventInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {google.cloud.retail.v2beta.UserEventInputConfig} message UserEventInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.userEventInlineSource != null && message.hasOwnProperty("userEventInlineSource")) { + object.userEventInlineSource = $root.google.cloud.retail.v2beta.UserEventInlineSource.toObject(message.userEventInlineSource, options); + if (options.oneofs) + object.source = "userEventInlineSource"; + } + if (message.gcsSource != null && message.hasOwnProperty("gcsSource")) { + object.gcsSource = $root.google.cloud.retail.v2beta.GcsSource.toObject(message.gcsSource, options); + if (options.oneofs) + object.source = "gcsSource"; + } + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this UserEventInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @instance + * @returns {Object.} JSON object + */ + UserEventInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UserEventInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UserEventInputConfig"; + }; + + return UserEventInputConfig; + })(); + + v2beta.CompletionDataInputConfig = (function() { + + /** + * Properties of a CompletionDataInputConfig. + * @memberof google.cloud.retail.v2beta + * @interface ICompletionDataInputConfig + * @property {google.cloud.retail.v2beta.IBigQuerySource|null} [bigQuerySource] CompletionDataInputConfig bigQuerySource + */ + + /** + * Constructs a new CompletionDataInputConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompletionDataInputConfig. + * @implements ICompletionDataInputConfig + * @constructor + * @param {google.cloud.retail.v2beta.ICompletionDataInputConfig=} [properties] Properties to set + */ + function CompletionDataInputConfig(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]]; + } + + /** + * CompletionDataInputConfig bigQuerySource. + * @member {google.cloud.retail.v2beta.IBigQuerySource|null|undefined} bigQuerySource + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @instance + */ + CompletionDataInputConfig.prototype.bigQuerySource = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CompletionDataInputConfig source. + * @member {"bigQuerySource"|undefined} source + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @instance + */ + Object.defineProperty(CompletionDataInputConfig.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["bigQuerySource"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CompletionDataInputConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionDataInputConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompletionDataInputConfig} CompletionDataInputConfig instance + */ + CompletionDataInputConfig.create = function create(properties) { + return new CompletionDataInputConfig(properties); + }; + + /** + * Encodes the specified CompletionDataInputConfig message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDataInputConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.bigQuerySource != null && Object.hasOwnProperty.call(message, "bigQuerySource")) + $root.google.cloud.retail.v2beta.BigQuerySource.encode(message.bigQuerySource, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompletionDataInputConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDataInputConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2beta.ICompletionDataInputConfig} message CompletionDataInputConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDataInputConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.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.cloud.retail.v2beta.CompletionDataInputConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDataInputConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompletionDataInputConfig} CompletionDataInputConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDataInputConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDataInputConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDataInputConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + properties.source = 1; + { + var error = $root.google.cloud.retail.v2beta.BigQuerySource.verify(message.bigQuerySource); + if (error) + return "bigQuerySource." + error; + } + } + return null; + }; + + /** + * Creates a CompletionDataInputConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompletionDataInputConfig} CompletionDataInputConfig + */ + CompletionDataInputConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompletionDataInputConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.CompletionDataInputConfig(); + if (object.bigQuerySource != null) { + if (typeof object.bigQuerySource !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompletionDataInputConfig.bigQuerySource: object expected"); + message.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.fromObject(object.bigQuerySource); + } + return message; + }; + + /** + * Creates a plain object from a CompletionDataInputConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} message CompletionDataInputConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDataInputConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.bigQuerySource != null && message.hasOwnProperty("bigQuerySource")) { + object.bigQuerySource = $root.google.cloud.retail.v2beta.BigQuerySource.toObject(message.bigQuerySource, options); + if (options.oneofs) + object.source = "bigQuerySource"; + } + return object; + }; + + /** + * Converts this CompletionDataInputConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @instance + * @returns {Object.} JSON object + */ + CompletionDataInputConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDataInputConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompletionDataInputConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDataInputConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompletionDataInputConfig"; + }; + + return CompletionDataInputConfig; + })(); + + v2beta.ImportMetadata = (function() { + + /** + * Properties of an ImportMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IImportMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] ImportMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ImportMetadata updateTime + * @property {number|Long|null} [successCount] ImportMetadata successCount + * @property {number|Long|null} [failureCount] ImportMetadata failureCount + * @property {string|null} [requestId] ImportMetadata requestId + * @property {string|null} [notificationPubsubTopic] ImportMetadata notificationPubsubTopic + */ + + /** + * Constructs a new ImportMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportMetadata. + * @implements IImportMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IImportMetadata=} [properties] Properties to set + */ + function ImportMetadata(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]]; + } + + /** + * ImportMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.createTime = null; + + /** + * ImportMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.updateTime = null; + + /** + * ImportMetadata successCount. + * @member {number|Long} successCount + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.successCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata failureCount. + * @member {number|Long} failureCount + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.failureCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ImportMetadata requestId. + * @member {string} requestId + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.requestId = ""; + + /** + * ImportMetadata notificationPubsubTopic. + * @member {string} notificationPubsubTopic + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + */ + ImportMetadata.prototype.notificationPubsubTopic = ""; + + /** + * Creates a new ImportMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {google.cloud.retail.v2beta.IImportMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportMetadata} ImportMetadata instance + */ + ImportMetadata.create = function create(properties) { + return new ImportMetadata(properties); + }; + + /** + * Encodes the specified ImportMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.ImportMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {google.cloud.retail.v2beta.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.successCount != null && Object.hasOwnProperty.call(message, "successCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.successCount); + if (message.failureCount != null && Object.hasOwnProperty.call(message, "failureCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.failureCount); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.requestId); + if (message.notificationPubsubTopic != null && Object.hasOwnProperty.call(message, "notificationPubsubTopic")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.notificationPubsubTopic); + return writer; + }; + + /** + * Encodes the specified ImportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {google.cloud.retail.v2beta.IImportMetadata} message ImportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.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.cloud.retail.v2beta.ImportMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.successCount = reader.int64(); + break; + } + case 4: { + message.failureCount = reader.int64(); + break; + } + case 5: { + message.requestId = reader.string(); + break; + } + case 6: { + message.notificationPubsubTopic = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportMetadata} ImportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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.successCount != null && message.hasOwnProperty("successCount")) + if (!$util.isInteger(message.successCount) && !(message.successCount && $util.isInteger(message.successCount.low) && $util.isInteger(message.successCount.high))) + return "successCount: integer|Long expected"; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (!$util.isInteger(message.failureCount) && !(message.failureCount && $util.isInteger(message.failureCount.low) && $util.isInteger(message.failureCount.high))) + return "failureCount: integer|Long expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isString(message.requestId)) + return "requestId: string expected"; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + if (!$util.isString(message.notificationPubsubTopic)) + return "notificationPubsubTopic: string expected"; + return null; + }; + + /** + * Creates an ImportMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportMetadata} ImportMetadata + */ + ImportMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportMetadata) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.successCount != null) + if ($util.Long) + (message.successCount = $util.Long.fromValue(object.successCount)).unsigned = false; + else if (typeof object.successCount === "string") + message.successCount = parseInt(object.successCount, 10); + else if (typeof object.successCount === "number") + message.successCount = object.successCount; + else if (typeof object.successCount === "object") + message.successCount = new $util.LongBits(object.successCount.low >>> 0, object.successCount.high >>> 0).toNumber(); + if (object.failureCount != null) + if ($util.Long) + (message.failureCount = $util.Long.fromValue(object.failureCount)).unsigned = false; + else if (typeof object.failureCount === "string") + message.failureCount = parseInt(object.failureCount, 10); + else if (typeof object.failureCount === "number") + message.failureCount = object.failureCount; + else if (typeof object.failureCount === "object") + message.failureCount = new $util.LongBits(object.failureCount.low >>> 0, object.failureCount.high >>> 0).toNumber(); + if (object.requestId != null) + message.requestId = String(object.requestId); + if (object.notificationPubsubTopic != null) + message.notificationPubsubTopic = String(object.notificationPubsubTopic); + return message; + }; + + /** + * Creates a plain object from an ImportMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {google.cloud.retail.v2beta.ImportMetadata} message ImportMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.successCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.successCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.failureCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.failureCount = options.longs === String ? "0" : 0; + object.requestId = ""; + object.notificationPubsubTopic = ""; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.successCount != null && message.hasOwnProperty("successCount")) + if (typeof message.successCount === "number") + object.successCount = options.longs === String ? String(message.successCount) : message.successCount; + else + object.successCount = options.longs === String ? $util.Long.prototype.toString.call(message.successCount) : options.longs === Number ? new $util.LongBits(message.successCount.low >>> 0, message.successCount.high >>> 0).toNumber() : message.successCount; + if (message.failureCount != null && message.hasOwnProperty("failureCount")) + if (typeof message.failureCount === "number") + object.failureCount = options.longs === String ? String(message.failureCount) : message.failureCount; + else + object.failureCount = options.longs === String ? $util.Long.prototype.toString.call(message.failureCount) : options.longs === Number ? new $util.LongBits(message.failureCount.low >>> 0, message.failureCount.high >>> 0).toNumber() : message.failureCount; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = message.requestId; + if (message.notificationPubsubTopic != null && message.hasOwnProperty("notificationPubsubTopic")) + object.notificationPubsubTopic = message.notificationPubsubTopic; + return object; + }; + + /** + * Converts this ImportMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportMetadata"; + }; + + return ImportMetadata; + })(); + + v2beta.ImportProductsResponse = (function() { + + /** + * Properties of an ImportProductsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IImportProductsResponse + * @property {Array.|null} [errorSamples] ImportProductsResponse errorSamples + * @property {google.cloud.retail.v2beta.IImportErrorsConfig|null} [errorsConfig] ImportProductsResponse errorsConfig + */ + + /** + * Constructs a new ImportProductsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportProductsResponse. + * @implements IImportProductsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IImportProductsResponse=} [properties] Properties to set + */ + function ImportProductsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportProductsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportProductsResponse errorsConfig. + * @member {google.cloud.retail.v2beta.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @instance + */ + ImportProductsResponse.prototype.errorsConfig = null; + + /** + * Creates a new ImportProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportProductsResponse} ImportProductsResponse instance + */ + ImportProductsResponse.create = function create(properties) { + return new ImportProductsResponse(properties); + }; + + /** + * Encodes the specified ImportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportProductsResponse} message ImportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.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.cloud.retail.v2beta.ImportProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportProductsResponse} ImportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + return null; + }; + + /** + * Creates an ImportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportProductsResponse} ImportProductsResponse + */ + ImportProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportProductsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2beta.ImportProductsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportProductsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportProductsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.fromObject(object.errorsConfig); + } + return message; + }; + + /** + * Creates a plain object from an ImportProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.ImportProductsResponse} message ImportProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) + object.errorsConfig = null; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.toObject(message.errorsConfig, options); + return object; + }; + + /** + * Converts this ImportProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportProductsResponse"; + }; + + return ImportProductsResponse; + })(); + + v2beta.ImportUserEventsResponse = (function() { + + /** + * Properties of an ImportUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IImportUserEventsResponse + * @property {Array.|null} [errorSamples] ImportUserEventsResponse errorSamples + * @property {google.cloud.retail.v2beta.IImportErrorsConfig|null} [errorsConfig] ImportUserEventsResponse errorsConfig + * @property {google.cloud.retail.v2beta.IUserEventImportSummary|null} [importSummary] ImportUserEventsResponse importSummary + */ + + /** + * Constructs a new ImportUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportUserEventsResponse. + * @implements IImportUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IImportUserEventsResponse=} [properties] Properties to set + */ + function ImportUserEventsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportUserEventsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ImportUserEventsResponse errorsConfig. + * @member {google.cloud.retail.v2beta.IImportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.errorsConfig = null; + + /** + * ImportUserEventsResponse importSummary. + * @member {google.cloud.retail.v2beta.IUserEventImportSummary|null|undefined} importSummary + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @instance + */ + ImportUserEventsResponse.prototype.importSummary = null; + + /** + * Creates a new ImportUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportUserEventsResponse} ImportUserEventsResponse instance + */ + ImportUserEventsResponse.create = function create(properties) { + return new ImportUserEventsResponse(properties); + }; + + /** + * Encodes the specified ImportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ImportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.importSummary != null && Object.hasOwnProperty.call(message, "importSummary")) + $root.google.cloud.retail.v2beta.UserEventImportSummary.encode(message.importSummary, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IImportUserEventsResponse} message ImportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.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.cloud.retail.v2beta.ImportUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.importSummary = $root.google.cloud.retail.v2beta.UserEventImportSummary.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportUserEventsResponse} ImportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ImportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.importSummary != null && message.hasOwnProperty("importSummary")) { + var error = $root.google.cloud.retail.v2beta.UserEventImportSummary.verify(message.importSummary); + if (error) + return "importSummary." + error; + } + return null; + }; + + /** + * Creates an ImportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportUserEventsResponse} ImportUserEventsResponse + */ + ImportUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportUserEventsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.importSummary != null) { + if (typeof object.importSummary !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportUserEventsResponse.importSummary: object expected"); + message.importSummary = $root.google.cloud.retail.v2beta.UserEventImportSummary.fromObject(object.importSummary); + } + return message; + }; + + /** + * Creates a plain object from an ImportUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.ImportUserEventsResponse} message ImportUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportUserEventsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.importSummary = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ImportErrorsConfig.toObject(message.errorsConfig, options); + if (message.importSummary != null && message.hasOwnProperty("importSummary")) + object.importSummary = $root.google.cloud.retail.v2beta.UserEventImportSummary.toObject(message.importSummary, options); + return object; + }; + + /** + * Converts this ImportUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + ImportUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportUserEventsResponse"; + }; + + return ImportUserEventsResponse; + })(); + + v2beta.UserEventImportSummary = (function() { + + /** + * Properties of a UserEventImportSummary. + * @memberof google.cloud.retail.v2beta + * @interface IUserEventImportSummary + * @property {number|Long|null} [joinedEventsCount] UserEventImportSummary joinedEventsCount + * @property {number|Long|null} [unjoinedEventsCount] UserEventImportSummary unjoinedEventsCount + */ + + /** + * Constructs a new UserEventImportSummary. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserEventImportSummary. + * @implements IUserEventImportSummary + * @constructor + * @param {google.cloud.retail.v2beta.IUserEventImportSummary=} [properties] Properties to set + */ + function UserEventImportSummary(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]]; + } + + /** + * UserEventImportSummary joinedEventsCount. + * @member {number|Long} joinedEventsCount + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.joinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UserEventImportSummary unjoinedEventsCount. + * @member {number|Long} unjoinedEventsCount + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @instance + */ + UserEventImportSummary.prototype.unjoinedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new UserEventImportSummary instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2beta.IUserEventImportSummary=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UserEventImportSummary} UserEventImportSummary instance + */ + UserEventImportSummary.create = function create(properties) { + return new UserEventImportSummary(properties); + }; + + /** + * Encodes the specified UserEventImportSummary message. Does not implicitly {@link google.cloud.retail.v2beta.UserEventImportSummary.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2beta.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.joinedEventsCount != null && Object.hasOwnProperty.call(message, "joinedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.joinedEventsCount); + if (message.unjoinedEventsCount != null && Object.hasOwnProperty.call(message, "unjoinedEventsCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.unjoinedEventsCount); + return writer; + }; + + /** + * Encodes the specified UserEventImportSummary message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEventImportSummary.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2beta.IUserEventImportSummary} message UserEventImportSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEventImportSummary.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.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.cloud.retail.v2beta.UserEventImportSummary(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.joinedEventsCount = reader.int64(); + break; + } + case 2: { + message.unjoinedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEventImportSummary message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UserEventImportSummary} UserEventImportSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEventImportSummary.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEventImportSummary message. + * @function verify + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEventImportSummary.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (!$util.isInteger(message.joinedEventsCount) && !(message.joinedEventsCount && $util.isInteger(message.joinedEventsCount.low) && $util.isInteger(message.joinedEventsCount.high))) + return "joinedEventsCount: integer|Long expected"; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (!$util.isInteger(message.unjoinedEventsCount) && !(message.unjoinedEventsCount && $util.isInteger(message.unjoinedEventsCount.low) && $util.isInteger(message.unjoinedEventsCount.high))) + return "unjoinedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a UserEventImportSummary message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UserEventImportSummary} UserEventImportSummary + */ + UserEventImportSummary.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UserEventImportSummary) + return object; + var message = new $root.google.cloud.retail.v2beta.UserEventImportSummary(); + if (object.joinedEventsCount != null) + if ($util.Long) + (message.joinedEventsCount = $util.Long.fromValue(object.joinedEventsCount)).unsigned = false; + else if (typeof object.joinedEventsCount === "string") + message.joinedEventsCount = parseInt(object.joinedEventsCount, 10); + else if (typeof object.joinedEventsCount === "number") + message.joinedEventsCount = object.joinedEventsCount; + else if (typeof object.joinedEventsCount === "object") + message.joinedEventsCount = new $util.LongBits(object.joinedEventsCount.low >>> 0, object.joinedEventsCount.high >>> 0).toNumber(); + if (object.unjoinedEventsCount != null) + if ($util.Long) + (message.unjoinedEventsCount = $util.Long.fromValue(object.unjoinedEventsCount)).unsigned = false; + else if (typeof object.unjoinedEventsCount === "string") + message.unjoinedEventsCount = parseInt(object.unjoinedEventsCount, 10); + else if (typeof object.unjoinedEventsCount === "number") + message.unjoinedEventsCount = object.unjoinedEventsCount; + else if (typeof object.unjoinedEventsCount === "object") + message.unjoinedEventsCount = new $util.LongBits(object.unjoinedEventsCount.low >>> 0, object.unjoinedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a UserEventImportSummary message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {google.cloud.retail.v2beta.UserEventImportSummary} message UserEventImportSummary + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEventImportSummary.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.joinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.joinedEventsCount = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.unjoinedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.unjoinedEventsCount = options.longs === String ? "0" : 0; + } + if (message.joinedEventsCount != null && message.hasOwnProperty("joinedEventsCount")) + if (typeof message.joinedEventsCount === "number") + object.joinedEventsCount = options.longs === String ? String(message.joinedEventsCount) : message.joinedEventsCount; + else + object.joinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.joinedEventsCount) : options.longs === Number ? new $util.LongBits(message.joinedEventsCount.low >>> 0, message.joinedEventsCount.high >>> 0).toNumber() : message.joinedEventsCount; + if (message.unjoinedEventsCount != null && message.hasOwnProperty("unjoinedEventsCount")) + if (typeof message.unjoinedEventsCount === "number") + object.unjoinedEventsCount = options.longs === String ? String(message.unjoinedEventsCount) : message.unjoinedEventsCount; + else + object.unjoinedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.unjoinedEventsCount) : options.longs === Number ? new $util.LongBits(message.unjoinedEventsCount.low >>> 0, message.unjoinedEventsCount.high >>> 0).toNumber() : message.unjoinedEventsCount; + return object; + }; + + /** + * Converts this UserEventImportSummary to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @instance + * @returns {Object.} JSON object + */ + UserEventImportSummary.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEventImportSummary + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UserEventImportSummary + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEventImportSummary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UserEventImportSummary"; + }; + + return UserEventImportSummary; + })(); + + v2beta.ImportCompletionDataResponse = (function() { + + /** + * Properties of an ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2beta + * @interface IImportCompletionDataResponse + * @property {Array.|null} [errorSamples] ImportCompletionDataResponse errorSamples + */ + + /** + * Constructs a new ImportCompletionDataResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ImportCompletionDataResponse. + * @implements IImportCompletionDataResponse + * @constructor + * @param {google.cloud.retail.v2beta.IImportCompletionDataResponse=} [properties] Properties to set + */ + function ImportCompletionDataResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ImportCompletionDataResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @instance + */ + ImportCompletionDataResponse.prototype.errorSamples = $util.emptyArray; + + /** + * Creates a new ImportCompletionDataResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ImportCompletionDataResponse} ImportCompletionDataResponse instance + */ + ImportCompletionDataResponse.create = function create(properties) { + return new ImportCompletionDataResponse(properties); + }; + + /** + * Encodes the specified ImportCompletionDataResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportCompletionDataResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ImportCompletionDataResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2beta.IImportCompletionDataResponse} message ImportCompletionDataResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportCompletionDataResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.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.cloud.retail.v2beta.ImportCompletionDataResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportCompletionDataResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ImportCompletionDataResponse} ImportCompletionDataResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportCompletionDataResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportCompletionDataResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportCompletionDataResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + return null; + }; + + /** + * Creates an ImportCompletionDataResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ImportCompletionDataResponse} ImportCompletionDataResponse + */ + ImportCompletionDataResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ImportCompletionDataResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ImportCompletionDataResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2beta.ImportCompletionDataResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ImportCompletionDataResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ImportCompletionDataResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {google.cloud.retail.v2beta.ImportCompletionDataResponse} message ImportCompletionDataResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportCompletionDataResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + return object; + }; + + /** + * Converts this ImportCompletionDataResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @instance + * @returns {Object.} JSON object + */ + ImportCompletionDataResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportCompletionDataResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ImportCompletionDataResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportCompletionDataResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ImportCompletionDataResponse"; + }; + + return ImportCompletionDataResponse; + })(); + + v2beta.Product = (function() { + + /** + * Properties of a Product. + * @memberof google.cloud.retail.v2beta + * @interface IProduct + * @property {google.protobuf.ITimestamp|null} [expireTime] Product expireTime + * @property {google.protobuf.IDuration|null} [ttl] Product ttl + * @property {string|null} [name] Product name + * @property {string|null} [id] Product id + * @property {google.cloud.retail.v2beta.Product.Type|null} [type] Product type + * @property {string|null} [primaryProductId] Product primaryProductId + * @property {Array.|null} [collectionMemberIds] Product collectionMemberIds + * @property {string|null} [gtin] Product gtin + * @property {Array.|null} [categories] Product categories + * @property {string|null} [title] Product title + * @property {Array.|null} [brands] Product brands + * @property {string|null} [description] Product description + * @property {string|null} [languageCode] Product languageCode + * @property {Object.|null} [attributes] Product attributes + * @property {Array.|null} [tags] Product tags + * @property {google.cloud.retail.v2beta.IPriceInfo|null} [priceInfo] Product priceInfo + * @property {google.cloud.retail.v2beta.IRating|null} [rating] Product rating + * @property {google.protobuf.ITimestamp|null} [availableTime] Product availableTime + * @property {google.cloud.retail.v2beta.Product.Availability|null} [availability] Product availability + * @property {google.protobuf.IInt32Value|null} [availableQuantity] Product availableQuantity + * @property {Array.|null} [fulfillmentInfo] Product fulfillmentInfo + * @property {string|null} [uri] Product uri + * @property {Array.|null} [images] Product images + * @property {google.cloud.retail.v2beta.IAudience|null} [audience] Product audience + * @property {google.cloud.retail.v2beta.IColorInfo|null} [colorInfo] Product colorInfo + * @property {Array.|null} [sizes] Product sizes + * @property {Array.|null} [materials] Product materials + * @property {Array.|null} [patterns] Product patterns + * @property {Array.|null} [conditions] Product conditions + * @property {Array.|null} [promotions] Product promotions + * @property {google.protobuf.ITimestamp|null} [publishTime] Product publishTime + * @property {google.protobuf.IFieldMask|null} [retrievableFields] Product retrievableFields + * @property {Array.|null} [variants] Product variants + * @property {Array.|null} [localInventories] Product localInventories + */ + + /** + * Constructs a new Product. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Product. + * @implements IProduct + * @constructor + * @param {google.cloud.retail.v2beta.IProduct=} [properties] Properties to set + */ + function Product(properties) { + this.collectionMemberIds = []; + this.categories = []; + this.brands = []; + this.attributes = {}; + this.tags = []; + this.fulfillmentInfo = []; + this.images = []; + this.sizes = []; + this.materials = []; + this.patterns = []; + this.conditions = []; + this.promotions = []; + this.variants = []; + this.localInventories = []; + 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]]; + } + + /** + * Product expireTime. + * @member {google.protobuf.ITimestamp|null|undefined} expireTime + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.expireTime = null; + + /** + * Product ttl. + * @member {google.protobuf.IDuration|null|undefined} ttl + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.ttl = null; + + /** + * Product name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.name = ""; + + /** + * Product id. + * @member {string} id + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.id = ""; + + /** + * Product type. + * @member {google.cloud.retail.v2beta.Product.Type} type + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.type = 0; + + /** + * Product primaryProductId. + * @member {string} primaryProductId + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.primaryProductId = ""; + + /** + * Product collectionMemberIds. + * @member {Array.} collectionMemberIds + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.collectionMemberIds = $util.emptyArray; + + /** + * Product gtin. + * @member {string} gtin + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.gtin = ""; + + /** + * Product categories. + * @member {Array.} categories + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.categories = $util.emptyArray; + + /** + * Product title. + * @member {string} title + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.title = ""; + + /** + * Product brands. + * @member {Array.} brands + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.brands = $util.emptyArray; + + /** + * Product description. + * @member {string} description + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.description = ""; + + /** + * Product languageCode. + * @member {string} languageCode + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.languageCode = ""; + + /** + * Product attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.attributes = $util.emptyObject; + + /** + * Product tags. + * @member {Array.} tags + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.tags = $util.emptyArray; + + /** + * Product priceInfo. + * @member {google.cloud.retail.v2beta.IPriceInfo|null|undefined} priceInfo + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.priceInfo = null; + + /** + * Product rating. + * @member {google.cloud.retail.v2beta.IRating|null|undefined} rating + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.rating = null; + + /** + * Product availableTime. + * @member {google.protobuf.ITimestamp|null|undefined} availableTime + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.availableTime = null; + + /** + * Product availability. + * @member {google.cloud.retail.v2beta.Product.Availability} availability + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.availability = 0; + + /** + * Product availableQuantity. + * @member {google.protobuf.IInt32Value|null|undefined} availableQuantity + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.availableQuantity = null; + + /** + * Product fulfillmentInfo. + * @member {Array.} fulfillmentInfo + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.fulfillmentInfo = $util.emptyArray; + + /** + * Product uri. + * @member {string} uri + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.uri = ""; + + /** + * Product images. + * @member {Array.} images + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.images = $util.emptyArray; + + /** + * Product audience. + * @member {google.cloud.retail.v2beta.IAudience|null|undefined} audience + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.audience = null; + + /** + * Product colorInfo. + * @member {google.cloud.retail.v2beta.IColorInfo|null|undefined} colorInfo + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.colorInfo = null; + + /** + * Product sizes. + * @member {Array.} sizes + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.sizes = $util.emptyArray; + + /** + * Product materials. + * @member {Array.} materials + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.materials = $util.emptyArray; + + /** + * Product patterns. + * @member {Array.} patterns + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.patterns = $util.emptyArray; + + /** + * Product conditions. + * @member {Array.} conditions + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.conditions = $util.emptyArray; + + /** + * Product promotions. + * @member {Array.} promotions + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.promotions = $util.emptyArray; + + /** + * Product publishTime. + * @member {google.protobuf.ITimestamp|null|undefined} publishTime + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.publishTime = null; + + /** + * Product retrievableFields. + * @member {google.protobuf.IFieldMask|null|undefined} retrievableFields + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.retrievableFields = null; + + /** + * Product variants. + * @member {Array.} variants + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.variants = $util.emptyArray; + + /** + * Product localInventories. + * @member {Array.} localInventories + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Product.prototype.localInventories = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Product expiration. + * @member {"expireTime"|"ttl"|undefined} expiration + * @memberof google.cloud.retail.v2beta.Product + * @instance + */ + Object.defineProperty(Product.prototype, "expiration", { + get: $util.oneOfGetter($oneOfFields = ["expireTime", "ttl"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Product instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {google.cloud.retail.v2beta.IProduct=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Product} Product instance + */ + Product.create = function create(properties) { + return new Product(properties); + }; + + /** + * Encodes the specified Product message. Does not implicitly {@link google.cloud.retail.v2beta.Product.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {google.cloud.retail.v2beta.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.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.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.primaryProductId != null && Object.hasOwnProperty.call(message, "primaryProductId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.primaryProductId); + if (message.collectionMemberIds != null && message.collectionMemberIds.length) + for (var i = 0; i < message.collectionMemberIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.collectionMemberIds[i]); + if (message.gtin != null && Object.hasOwnProperty.call(message, "gtin")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.gtin); + if (message.categories != null && message.categories.length) + for (var i = 0; i < message.categories.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.categories[i]); + if (message.title != null && Object.hasOwnProperty.call(message, "title")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.title); + if (message.brands != null && message.brands.length) + for (var i = 0; i < message.brands.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.brands[i]); + if (message.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.description); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.languageCode); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 12, wireType 2 =*/98).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2beta.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.tags != null && message.tags.length) + for (var i = 0; i < message.tags.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.tags[i]); + if (message.priceInfo != null && Object.hasOwnProperty.call(message, "priceInfo")) + $root.google.cloud.retail.v2beta.PriceInfo.encode(message.priceInfo, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.rating != null && Object.hasOwnProperty.call(message, "rating")) + $root.google.cloud.retail.v2beta.Rating.encode(message.rating, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.expireTime != null && Object.hasOwnProperty.call(message, "expireTime")) + $root.google.protobuf.Timestamp.encode(message.expireTime, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.ttl != null && Object.hasOwnProperty.call(message, "ttl")) + $root.google.protobuf.Duration.encode(message.ttl, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.availableTime != null && Object.hasOwnProperty.call(message, "availableTime")) + $root.google.protobuf.Timestamp.encode(message.availableTime, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.availability != null && Object.hasOwnProperty.call(message, "availability")) + writer.uint32(/* id 19, wireType 0 =*/152).int32(message.availability); + if (message.availableQuantity != null && Object.hasOwnProperty.call(message, "availableQuantity")) + $root.google.protobuf.Int32Value.encode(message.availableQuantity, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.fulfillmentInfo != null && message.fulfillmentInfo.length) + for (var i = 0; i < message.fulfillmentInfo.length; ++i) + $root.google.cloud.retail.v2beta.FulfillmentInfo.encode(message.fulfillmentInfo[i], writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 22, wireType 2 =*/178).string(message.uri); + if (message.images != null && message.images.length) + for (var i = 0; i < message.images.length; ++i) + $root.google.cloud.retail.v2beta.Image.encode(message.images[i], writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + if (message.audience != null && Object.hasOwnProperty.call(message, "audience")) + $root.google.cloud.retail.v2beta.Audience.encode(message.audience, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); + if (message.colorInfo != null && Object.hasOwnProperty.call(message, "colorInfo")) + $root.google.cloud.retail.v2beta.ColorInfo.encode(message.colorInfo, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim(); + if (message.sizes != null && message.sizes.length) + for (var i = 0; i < message.sizes.length; ++i) + writer.uint32(/* id 26, wireType 2 =*/210).string(message.sizes[i]); + if (message.materials != null && message.materials.length) + for (var i = 0; i < message.materials.length; ++i) + writer.uint32(/* id 27, wireType 2 =*/218).string(message.materials[i]); + if (message.patterns != null && message.patterns.length) + for (var i = 0; i < message.patterns.length; ++i) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.patterns[i]); + if (message.conditions != null && message.conditions.length) + for (var i = 0; i < message.conditions.length; ++i) + writer.uint32(/* id 29, wireType 2 =*/234).string(message.conditions[i]); + if (message.retrievableFields != null && Object.hasOwnProperty.call(message, "retrievableFields")) + $root.google.protobuf.FieldMask.encode(message.retrievableFields, writer.uint32(/* id 30, wireType 2 =*/242).fork()).ldelim(); + if (message.variants != null && message.variants.length) + for (var i = 0; i < message.variants.length; ++i) + $root.google.cloud.retail.v2beta.Product.encode(message.variants[i], writer.uint32(/* id 31, wireType 2 =*/250).fork()).ldelim(); + if (message.publishTime != null && Object.hasOwnProperty.call(message, "publishTime")) + $root.google.protobuf.Timestamp.encode(message.publishTime, writer.uint32(/* id 33, wireType 2 =*/266).fork()).ldelim(); + if (message.promotions != null && message.promotions.length) + for (var i = 0; i < message.promotions.length; ++i) + $root.google.cloud.retail.v2beta.Promotion.encode(message.promotions[i], writer.uint32(/* id 34, wireType 2 =*/274).fork()).ldelim(); + if (message.localInventories != null && message.localInventories.length) + for (var i = 0; i < message.localInventories.length; ++i) + $root.google.cloud.retail.v2beta.LocalInventory.encode(message.localInventories[i], writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Product message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Product.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {google.cloud.retail.v2beta.IProduct} message Product message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Product.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Product message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.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.cloud.retail.v2beta.Product(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 16: { + message.expireTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 17: { + message.ttl = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.id = reader.string(); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.primaryProductId = reader.string(); + break; + } + case 5: { + if (!(message.collectionMemberIds && message.collectionMemberIds.length)) + message.collectionMemberIds = []; + message.collectionMemberIds.push(reader.string()); + break; + } + case 6: { + message.gtin = reader.string(); + break; + } + case 7: { + if (!(message.categories && message.categories.length)) + message.categories = []; + message.categories.push(reader.string()); + break; + } + case 8: { + message.title = reader.string(); + break; + } + case 9: { + if (!(message.brands && message.brands.length)) + message.brands = []; + message.brands.push(reader.string()); + break; + } + case 10: { + message.description = reader.string(); + break; + } + case 11: { + message.languageCode = reader.string(); + break; + } + case 12: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2beta.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 13: { + if (!(message.tags && message.tags.length)) + message.tags = []; + message.tags.push(reader.string()); + break; + } + case 14: { + message.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.decode(reader, reader.uint32()); + break; + } + case 15: { + message.rating = $root.google.cloud.retail.v2beta.Rating.decode(reader, reader.uint32()); + break; + } + case 18: { + message.availableTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 19: { + message.availability = reader.int32(); + break; + } + case 20: { + message.availableQuantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + case 21: { + if (!(message.fulfillmentInfo && message.fulfillmentInfo.length)) + message.fulfillmentInfo = []; + message.fulfillmentInfo.push($root.google.cloud.retail.v2beta.FulfillmentInfo.decode(reader, reader.uint32())); + break; + } + case 22: { + message.uri = reader.string(); + break; + } + case 23: { + if (!(message.images && message.images.length)) + message.images = []; + message.images.push($root.google.cloud.retail.v2beta.Image.decode(reader, reader.uint32())); + break; + } + case 24: { + message.audience = $root.google.cloud.retail.v2beta.Audience.decode(reader, reader.uint32()); + break; + } + case 25: { + message.colorInfo = $root.google.cloud.retail.v2beta.ColorInfo.decode(reader, reader.uint32()); + break; + } + case 26: { + if (!(message.sizes && message.sizes.length)) + message.sizes = []; + message.sizes.push(reader.string()); + break; + } + case 27: { + if (!(message.materials && message.materials.length)) + message.materials = []; + message.materials.push(reader.string()); + break; + } + case 28: { + if (!(message.patterns && message.patterns.length)) + message.patterns = []; + message.patterns.push(reader.string()); + break; + } + case 29: { + if (!(message.conditions && message.conditions.length)) + message.conditions = []; + message.conditions.push(reader.string()); + break; + } + case 34: { + if (!(message.promotions && message.promotions.length)) + message.promotions = []; + message.promotions.push($root.google.cloud.retail.v2beta.Promotion.decode(reader, reader.uint32())); + break; + } + case 33: { + message.publishTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 30: { + message.retrievableFields = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 31: { + if (!(message.variants && message.variants.length)) + message.variants = []; + message.variants.push($root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32())); + break; + } + case 35: { + if (!(message.localInventories && message.localInventories.length)) + message.localInventories = []; + message.localInventories.push($root.google.cloud.retail.v2beta.LocalInventory.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Product message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Product} Product + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Product.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Product message. + * @function verify + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Product.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + properties.expiration = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.expireTime); + if (error) + return "expireTime." + error; + } + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + if (properties.expiration === 1) + return "expiration: multiple values"; + properties.expiration = 1; + { + var error = $root.google.protobuf.Duration.verify(message.ttl); + if (error) + return "ttl." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + if (!$util.isString(message.primaryProductId)) + return "primaryProductId: string expected"; + if (message.collectionMemberIds != null && message.hasOwnProperty("collectionMemberIds")) { + if (!Array.isArray(message.collectionMemberIds)) + return "collectionMemberIds: array expected"; + for (var i = 0; i < message.collectionMemberIds.length; ++i) + if (!$util.isString(message.collectionMemberIds[i])) + return "collectionMemberIds: string[] expected"; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + if (!$util.isString(message.gtin)) + return "gtin: string expected"; + if (message.categories != null && message.hasOwnProperty("categories")) { + if (!Array.isArray(message.categories)) + return "categories: array expected"; + for (var i = 0; i < message.categories.length; ++i) + if (!$util.isString(message.categories[i])) + return "categories: string[] expected"; + } + if (message.title != null && message.hasOwnProperty("title")) + if (!$util.isString(message.title)) + return "title: string expected"; + if (message.brands != null && message.hasOwnProperty("brands")) { + if (!Array.isArray(message.brands)) + return "brands: array expected"; + for (var i = 0; i < message.brands.length; ++i) + if (!$util.isString(message.brands[i])) + return "brands: string[] expected"; + } + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.tags != null && message.hasOwnProperty("tags")) { + if (!Array.isArray(message.tags)) + return "tags: array expected"; + for (var i = 0; i < message.tags.length; ++i) + if (!$util.isString(message.tags[i])) + return "tags: string[] expected"; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) { + var error = $root.google.cloud.retail.v2beta.PriceInfo.verify(message.priceInfo); + if (error) + return "priceInfo." + error; + } + if (message.rating != null && message.hasOwnProperty("rating")) { + var error = $root.google.cloud.retail.v2beta.Rating.verify(message.rating); + if (error) + return "rating." + error; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.availableTime); + if (error) + return "availableTime." + error; + } + if (message.availability != null && message.hasOwnProperty("availability")) + switch (message.availability) { + default: + return "availability: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.availableQuantity); + if (error) + return "availableQuantity." + error; + } + if (message.fulfillmentInfo != null && message.hasOwnProperty("fulfillmentInfo")) { + if (!Array.isArray(message.fulfillmentInfo)) + return "fulfillmentInfo: array expected"; + for (var i = 0; i < message.fulfillmentInfo.length; ++i) { + var error = $root.google.cloud.retail.v2beta.FulfillmentInfo.verify(message.fulfillmentInfo[i]); + if (error) + return "fulfillmentInfo." + error; + } + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.images != null && message.hasOwnProperty("images")) { + if (!Array.isArray(message.images)) + return "images: array expected"; + for (var i = 0; i < message.images.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Image.verify(message.images[i]); + if (error) + return "images." + error; + } + } + if (message.audience != null && message.hasOwnProperty("audience")) { + var error = $root.google.cloud.retail.v2beta.Audience.verify(message.audience); + if (error) + return "audience." + error; + } + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) { + var error = $root.google.cloud.retail.v2beta.ColorInfo.verify(message.colorInfo); + if (error) + return "colorInfo." + error; + } + if (message.sizes != null && message.hasOwnProperty("sizes")) { + if (!Array.isArray(message.sizes)) + return "sizes: array expected"; + for (var i = 0; i < message.sizes.length; ++i) + if (!$util.isString(message.sizes[i])) + return "sizes: string[] expected"; + } + if (message.materials != null && message.hasOwnProperty("materials")) { + if (!Array.isArray(message.materials)) + return "materials: array expected"; + for (var i = 0; i < message.materials.length; ++i) + if (!$util.isString(message.materials[i])) + return "materials: string[] expected"; + } + if (message.patterns != null && message.hasOwnProperty("patterns")) { + if (!Array.isArray(message.patterns)) + return "patterns: array expected"; + for (var i = 0; i < message.patterns.length; ++i) + if (!$util.isString(message.patterns[i])) + return "patterns: string[] expected"; + } + if (message.conditions != null && message.hasOwnProperty("conditions")) { + if (!Array.isArray(message.conditions)) + return "conditions: array expected"; + for (var i = 0; i < message.conditions.length; ++i) + if (!$util.isString(message.conditions[i])) + return "conditions: string[] expected"; + } + if (message.promotions != null && message.hasOwnProperty("promotions")) { + if (!Array.isArray(message.promotions)) + return "promotions: array expected"; + for (var i = 0; i < message.promotions.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Promotion.verify(message.promotions[i]); + if (error) + return "promotions." + error; + } + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.publishTime); + if (error) + return "publishTime." + error; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) { + var error = $root.google.protobuf.FieldMask.verify(message.retrievableFields); + if (error) + return "retrievableFields." + error; + } + if (message.variants != null && message.hasOwnProperty("variants")) { + if (!Array.isArray(message.variants)) + return "variants: array expected"; + for (var i = 0; i < message.variants.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.variants[i]); + if (error) + return "variants." + error; + } + } + if (message.localInventories != null && message.hasOwnProperty("localInventories")) { + if (!Array.isArray(message.localInventories)) + return "localInventories: array expected"; + for (var i = 0; i < message.localInventories.length; ++i) { + var error = $root.google.cloud.retail.v2beta.LocalInventory.verify(message.localInventories[i]); + if (error) + return "localInventories." + error; + } + } + return null; + }; + + /** + * Creates a Product message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Product} Product + */ + Product.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Product) + return object; + var message = new $root.google.cloud.retail.v2beta.Product(); + if (object.expireTime != null) { + if (typeof object.expireTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.expireTime: object expected"); + message.expireTime = $root.google.protobuf.Timestamp.fromObject(object.expireTime); + } + if (object.ttl != null) { + if (typeof object.ttl !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.ttl: object expected"); + message.ttl = $root.google.protobuf.Duration.fromObject(object.ttl); + } + if (object.name != null) + message.name = String(object.name); + if (object.id != null) + message.id = String(object.id); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_UNSPECIFIED": + case 0: + message.type = 0; + break; + case "PRIMARY": + case 1: + message.type = 1; + break; + case "VARIANT": + case 2: + message.type = 2; + break; + case "COLLECTION": + case 3: + message.type = 3; + break; + } + if (object.primaryProductId != null) + message.primaryProductId = String(object.primaryProductId); + if (object.collectionMemberIds) { + if (!Array.isArray(object.collectionMemberIds)) + throw TypeError(".google.cloud.retail.v2beta.Product.collectionMemberIds: array expected"); + message.collectionMemberIds = []; + for (var i = 0; i < object.collectionMemberIds.length; ++i) + message.collectionMemberIds[i] = String(object.collectionMemberIds[i]); + } + if (object.gtin != null) + message.gtin = String(object.gtin); + if (object.categories) { + if (!Array.isArray(object.categories)) + throw TypeError(".google.cloud.retail.v2beta.Product.categories: array expected"); + message.categories = []; + for (var i = 0; i < object.categories.length; ++i) + message.categories[i] = String(object.categories[i]); + } + if (object.title != null) + message.title = String(object.title); + if (object.brands) { + if (!Array.isArray(object.brands)) + throw TypeError(".google.cloud.retail.v2beta.Product.brands: array expected"); + message.brands = []; + for (var i = 0; i < object.brands.length; ++i) + message.brands[i] = String(object.brands[i]); + } + if (object.description != null) + message.description = String(object.description); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2beta.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.tags) { + if (!Array.isArray(object.tags)) + throw TypeError(".google.cloud.retail.v2beta.Product.tags: array expected"); + message.tags = []; + for (var i = 0; i < object.tags.length; ++i) + message.tags[i] = String(object.tags[i]); + } + if (object.priceInfo != null) { + if (typeof object.priceInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.priceInfo: object expected"); + message.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.fromObject(object.priceInfo); + } + if (object.rating != null) { + if (typeof object.rating !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.rating: object expected"); + message.rating = $root.google.cloud.retail.v2beta.Rating.fromObject(object.rating); + } + if (object.availableTime != null) { + if (typeof object.availableTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.availableTime: object expected"); + message.availableTime = $root.google.protobuf.Timestamp.fromObject(object.availableTime); + } + switch (object.availability) { + default: + if (typeof object.availability === "number") { + message.availability = object.availability; + break; + } + break; + case "AVAILABILITY_UNSPECIFIED": + case 0: + message.availability = 0; + break; + case "IN_STOCK": + case 1: + message.availability = 1; + break; + case "OUT_OF_STOCK": + case 2: + message.availability = 2; + break; + case "PREORDER": + case 3: + message.availability = 3; + break; + case "BACKORDER": + case 4: + message.availability = 4; + break; + } + if (object.availableQuantity != null) { + if (typeof object.availableQuantity !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.availableQuantity: object expected"); + message.availableQuantity = $root.google.protobuf.Int32Value.fromObject(object.availableQuantity); + } + if (object.fulfillmentInfo) { + if (!Array.isArray(object.fulfillmentInfo)) + throw TypeError(".google.cloud.retail.v2beta.Product.fulfillmentInfo: array expected"); + message.fulfillmentInfo = []; + for (var i = 0; i < object.fulfillmentInfo.length; ++i) { + if (typeof object.fulfillmentInfo[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.fulfillmentInfo: object expected"); + message.fulfillmentInfo[i] = $root.google.cloud.retail.v2beta.FulfillmentInfo.fromObject(object.fulfillmentInfo[i]); + } + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.images) { + if (!Array.isArray(object.images)) + throw TypeError(".google.cloud.retail.v2beta.Product.images: array expected"); + message.images = []; + for (var i = 0; i < object.images.length; ++i) { + if (typeof object.images[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.images: object expected"); + message.images[i] = $root.google.cloud.retail.v2beta.Image.fromObject(object.images[i]); + } + } + if (object.audience != null) { + if (typeof object.audience !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.audience: object expected"); + message.audience = $root.google.cloud.retail.v2beta.Audience.fromObject(object.audience); + } + if (object.colorInfo != null) { + if (typeof object.colorInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.colorInfo: object expected"); + message.colorInfo = $root.google.cloud.retail.v2beta.ColorInfo.fromObject(object.colorInfo); + } + if (object.sizes) { + if (!Array.isArray(object.sizes)) + throw TypeError(".google.cloud.retail.v2beta.Product.sizes: array expected"); + message.sizes = []; + for (var i = 0; i < object.sizes.length; ++i) + message.sizes[i] = String(object.sizes[i]); + } + if (object.materials) { + if (!Array.isArray(object.materials)) + throw TypeError(".google.cloud.retail.v2beta.Product.materials: array expected"); + message.materials = []; + for (var i = 0; i < object.materials.length; ++i) + message.materials[i] = String(object.materials[i]); + } + if (object.patterns) { + if (!Array.isArray(object.patterns)) + throw TypeError(".google.cloud.retail.v2beta.Product.patterns: array expected"); + message.patterns = []; + for (var i = 0; i < object.patterns.length; ++i) + message.patterns[i] = String(object.patterns[i]); + } + if (object.conditions) { + if (!Array.isArray(object.conditions)) + throw TypeError(".google.cloud.retail.v2beta.Product.conditions: array expected"); + message.conditions = []; + for (var i = 0; i < object.conditions.length; ++i) + message.conditions[i] = String(object.conditions[i]); + } + if (object.promotions) { + if (!Array.isArray(object.promotions)) + throw TypeError(".google.cloud.retail.v2beta.Product.promotions: array expected"); + message.promotions = []; + for (var i = 0; i < object.promotions.length; ++i) { + if (typeof object.promotions[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.promotions: object expected"); + message.promotions[i] = $root.google.cloud.retail.v2beta.Promotion.fromObject(object.promotions[i]); + } + } + if (object.publishTime != null) { + if (typeof object.publishTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.publishTime: object expected"); + message.publishTime = $root.google.protobuf.Timestamp.fromObject(object.publishTime); + } + if (object.retrievableFields != null) { + if (typeof object.retrievableFields !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.retrievableFields: object expected"); + message.retrievableFields = $root.google.protobuf.FieldMask.fromObject(object.retrievableFields); + } + if (object.variants) { + if (!Array.isArray(object.variants)) + throw TypeError(".google.cloud.retail.v2beta.Product.variants: array expected"); + message.variants = []; + for (var i = 0; i < object.variants.length; ++i) { + if (typeof object.variants[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.variants: object expected"); + message.variants[i] = $root.google.cloud.retail.v2beta.Product.fromObject(object.variants[i]); + } + } + if (object.localInventories) { + if (!Array.isArray(object.localInventories)) + throw TypeError(".google.cloud.retail.v2beta.Product.localInventories: array expected"); + message.localInventories = []; + for (var i = 0; i < object.localInventories.length; ++i) { + if (typeof object.localInventories[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Product.localInventories: object expected"); + message.localInventories[i] = $root.google.cloud.retail.v2beta.LocalInventory.fromObject(object.localInventories[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Product message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {google.cloud.retail.v2beta.Product} message Product + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Product.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.collectionMemberIds = []; + object.categories = []; + object.brands = []; + object.tags = []; + object.fulfillmentInfo = []; + object.images = []; + object.sizes = []; + object.materials = []; + object.patterns = []; + object.conditions = []; + object.variants = []; + object.promotions = []; + object.localInventories = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.name = ""; + object.id = ""; + object.type = options.enums === String ? "TYPE_UNSPECIFIED" : 0; + object.primaryProductId = ""; + object.gtin = ""; + object.title = ""; + object.description = ""; + object.languageCode = ""; + object.priceInfo = null; + object.rating = null; + object.availableTime = null; + object.availability = options.enums === String ? "AVAILABILITY_UNSPECIFIED" : 0; + object.availableQuantity = null; + object.uri = ""; + object.audience = null; + object.colorInfo = null; + object.retrievableFields = null; + object.publishTime = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.cloud.retail.v2beta.Product.Type[message.type] === undefined ? message.type : $root.google.cloud.retail.v2beta.Product.Type[message.type] : message.type; + if (message.primaryProductId != null && message.hasOwnProperty("primaryProductId")) + object.primaryProductId = message.primaryProductId; + if (message.collectionMemberIds && message.collectionMemberIds.length) { + object.collectionMemberIds = []; + for (var j = 0; j < message.collectionMemberIds.length; ++j) + object.collectionMemberIds[j] = message.collectionMemberIds[j]; + } + if (message.gtin != null && message.hasOwnProperty("gtin")) + object.gtin = message.gtin; + if (message.categories && message.categories.length) { + object.categories = []; + for (var j = 0; j < message.categories.length; ++j) + object.categories[j] = message.categories[j]; + } + if (message.title != null && message.hasOwnProperty("title")) + object.title = message.title; + if (message.brands && message.brands.length) { + object.brands = []; + for (var j = 0; j < message.brands.length; ++j) + object.brands[j] = message.brands[j]; + } + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2beta.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.tags && message.tags.length) { + object.tags = []; + for (var j = 0; j < message.tags.length; ++j) + object.tags[j] = message.tags[j]; + } + if (message.priceInfo != null && message.hasOwnProperty("priceInfo")) + object.priceInfo = $root.google.cloud.retail.v2beta.PriceInfo.toObject(message.priceInfo, options); + if (message.rating != null && message.hasOwnProperty("rating")) + object.rating = $root.google.cloud.retail.v2beta.Rating.toObject(message.rating, options); + if (message.expireTime != null && message.hasOwnProperty("expireTime")) { + object.expireTime = $root.google.protobuf.Timestamp.toObject(message.expireTime, options); + if (options.oneofs) + object.expiration = "expireTime"; + } + if (message.ttl != null && message.hasOwnProperty("ttl")) { + object.ttl = $root.google.protobuf.Duration.toObject(message.ttl, options); + if (options.oneofs) + object.expiration = "ttl"; + } + if (message.availableTime != null && message.hasOwnProperty("availableTime")) + object.availableTime = $root.google.protobuf.Timestamp.toObject(message.availableTime, options); + if (message.availability != null && message.hasOwnProperty("availability")) + object.availability = options.enums === String ? $root.google.cloud.retail.v2beta.Product.Availability[message.availability] === undefined ? message.availability : $root.google.cloud.retail.v2beta.Product.Availability[message.availability] : message.availability; + if (message.availableQuantity != null && message.hasOwnProperty("availableQuantity")) + object.availableQuantity = $root.google.protobuf.Int32Value.toObject(message.availableQuantity, options); + if (message.fulfillmentInfo && message.fulfillmentInfo.length) { + object.fulfillmentInfo = []; + for (var j = 0; j < message.fulfillmentInfo.length; ++j) + object.fulfillmentInfo[j] = $root.google.cloud.retail.v2beta.FulfillmentInfo.toObject(message.fulfillmentInfo[j], options); + } + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.images && message.images.length) { + object.images = []; + for (var j = 0; j < message.images.length; ++j) + object.images[j] = $root.google.cloud.retail.v2beta.Image.toObject(message.images[j], options); + } + if (message.audience != null && message.hasOwnProperty("audience")) + object.audience = $root.google.cloud.retail.v2beta.Audience.toObject(message.audience, options); + if (message.colorInfo != null && message.hasOwnProperty("colorInfo")) + object.colorInfo = $root.google.cloud.retail.v2beta.ColorInfo.toObject(message.colorInfo, options); + if (message.sizes && message.sizes.length) { + object.sizes = []; + for (var j = 0; j < message.sizes.length; ++j) + object.sizes[j] = message.sizes[j]; + } + if (message.materials && message.materials.length) { + object.materials = []; + for (var j = 0; j < message.materials.length; ++j) + object.materials[j] = message.materials[j]; + } + if (message.patterns && message.patterns.length) { + object.patterns = []; + for (var j = 0; j < message.patterns.length; ++j) + object.patterns[j] = message.patterns[j]; + } + if (message.conditions && message.conditions.length) { + object.conditions = []; + for (var j = 0; j < message.conditions.length; ++j) + object.conditions[j] = message.conditions[j]; + } + if (message.retrievableFields != null && message.hasOwnProperty("retrievableFields")) + object.retrievableFields = $root.google.protobuf.FieldMask.toObject(message.retrievableFields, options); + if (message.variants && message.variants.length) { + object.variants = []; + for (var j = 0; j < message.variants.length; ++j) + object.variants[j] = $root.google.cloud.retail.v2beta.Product.toObject(message.variants[j], options); + } + if (message.publishTime != null && message.hasOwnProperty("publishTime")) + object.publishTime = $root.google.protobuf.Timestamp.toObject(message.publishTime, options); + if (message.promotions && message.promotions.length) { + object.promotions = []; + for (var j = 0; j < message.promotions.length; ++j) + object.promotions[j] = $root.google.cloud.retail.v2beta.Promotion.toObject(message.promotions[j], options); + } + if (message.localInventories && message.localInventories.length) { + object.localInventories = []; + for (var j = 0; j < message.localInventories.length; ++j) + object.localInventories[j] = $root.google.cloud.retail.v2beta.LocalInventory.toObject(message.localInventories[j], options); + } + return object; + }; + + /** + * Converts this Product to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Product + * @instance + * @returns {Object.} JSON object + */ + Product.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Product + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Product + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Product.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Product"; + }; + + /** + * Type enum. + * @name google.cloud.retail.v2beta.Product.Type + * @enum {number} + * @property {number} TYPE_UNSPECIFIED=0 TYPE_UNSPECIFIED value + * @property {number} PRIMARY=1 PRIMARY value + * @property {number} VARIANT=2 VARIANT value + * @property {number} COLLECTION=3 COLLECTION value + */ + Product.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRIMARY"] = 1; + values[valuesById[2] = "VARIANT"] = 2; + values[valuesById[3] = "COLLECTION"] = 3; + return values; + })(); + + /** + * Availability enum. + * @name google.cloud.retail.v2beta.Product.Availability + * @enum {number} + * @property {number} AVAILABILITY_UNSPECIFIED=0 AVAILABILITY_UNSPECIFIED value + * @property {number} IN_STOCK=1 IN_STOCK value + * @property {number} OUT_OF_STOCK=2 OUT_OF_STOCK value + * @property {number} PREORDER=3 PREORDER value + * @property {number} BACKORDER=4 BACKORDER value + */ + Product.Availability = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "AVAILABILITY_UNSPECIFIED"] = 0; + values[valuesById[1] = "IN_STOCK"] = 1; + values[valuesById[2] = "OUT_OF_STOCK"] = 2; + values[valuesById[3] = "PREORDER"] = 3; + values[valuesById[4] = "BACKORDER"] = 4; + return values; + })(); + + return Product; + })(); + + v2beta.Promotion = (function() { + + /** + * Properties of a Promotion. + * @memberof google.cloud.retail.v2beta + * @interface IPromotion + * @property {string|null} [promotionId] Promotion promotionId + */ + + /** + * Constructs a new Promotion. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Promotion. + * @implements IPromotion + * @constructor + * @param {google.cloud.retail.v2beta.IPromotion=} [properties] Properties to set + */ + function Promotion(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]]; + } + + /** + * Promotion promotionId. + * @member {string} promotionId + * @memberof google.cloud.retail.v2beta.Promotion + * @instance + */ + Promotion.prototype.promotionId = ""; + + /** + * Creates a new Promotion instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {google.cloud.retail.v2beta.IPromotion=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Promotion} Promotion instance + */ + Promotion.create = function create(properties) { + return new Promotion(properties); + }; + + /** + * Encodes the specified Promotion message. Does not implicitly {@link google.cloud.retail.v2beta.Promotion.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {google.cloud.retail.v2beta.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.promotionId != null && Object.hasOwnProperty.call(message, "promotionId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.promotionId); + return writer; + }; + + /** + * Encodes the specified Promotion message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Promotion.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {google.cloud.retail.v2beta.IPromotion} message Promotion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Promotion.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Promotion message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.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.cloud.retail.v2beta.Promotion(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.promotionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Promotion message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Promotion} Promotion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Promotion.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Promotion message. + * @function verify + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Promotion.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + if (!$util.isString(message.promotionId)) + return "promotionId: string expected"; + return null; + }; + + /** + * Creates a Promotion message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Promotion} Promotion + */ + Promotion.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Promotion) + return object; + var message = new $root.google.cloud.retail.v2beta.Promotion(); + if (object.promotionId != null) + message.promotionId = String(object.promotionId); + return message; + }; + + /** + * Creates a plain object from a Promotion message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {google.cloud.retail.v2beta.Promotion} message Promotion + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Promotion.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.promotionId = ""; + if (message.promotionId != null && message.hasOwnProperty("promotionId")) + object.promotionId = message.promotionId; + return object; + }; + + /** + * Converts this Promotion to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Promotion + * @instance + * @returns {Object.} JSON object + */ + Promotion.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Promotion + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Promotion + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Promotion.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Promotion"; + }; + + return Promotion; + })(); + + v2beta.UserEvent = (function() { + + /** + * Properties of a UserEvent. + * @memberof google.cloud.retail.v2beta + * @interface IUserEvent + * @property {string|null} [eventType] UserEvent eventType + * @property {string|null} [visitorId] UserEvent visitorId + * @property {string|null} [sessionId] UserEvent sessionId + * @property {google.protobuf.ITimestamp|null} [eventTime] UserEvent eventTime + * @property {Array.|null} [experimentIds] UserEvent experimentIds + * @property {string|null} [attributionToken] UserEvent attributionToken + * @property {Array.|null} [productDetails] UserEvent productDetails + * @property {google.cloud.retail.v2beta.ICompletionDetail|null} [completionDetail] UserEvent completionDetail + * @property {Object.|null} [attributes] UserEvent attributes + * @property {string|null} [cartId] UserEvent cartId + * @property {google.cloud.retail.v2beta.IPurchaseTransaction|null} [purchaseTransaction] UserEvent purchaseTransaction + * @property {string|null} [searchQuery] UserEvent searchQuery + * @property {string|null} [filter] UserEvent filter + * @property {string|null} [orderBy] UserEvent orderBy + * @property {number|null} [offset] UserEvent offset + * @property {Array.|null} [pageCategories] UserEvent pageCategories + * @property {google.cloud.retail.v2beta.IUserInfo|null} [userInfo] UserEvent userInfo + * @property {string|null} [uri] UserEvent uri + * @property {string|null} [referrerUri] UserEvent referrerUri + * @property {string|null} [pageViewId] UserEvent pageViewId + */ + + /** + * Constructs a new UserEvent. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserEvent. + * @implements IUserEvent + * @constructor + * @param {google.cloud.retail.v2beta.IUserEvent=} [properties] Properties to set + */ + function UserEvent(properties) { + this.experimentIds = []; + this.productDetails = []; + this.attributes = {}; + this.pageCategories = []; + 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]]; + } + + /** + * UserEvent eventType. + * @member {string} eventType + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.eventType = ""; + + /** + * UserEvent visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.visitorId = ""; + + /** + * UserEvent sessionId. + * @member {string} sessionId + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.sessionId = ""; + + /** + * UserEvent eventTime. + * @member {google.protobuf.ITimestamp|null|undefined} eventTime + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.eventTime = null; + + /** + * UserEvent experimentIds. + * @member {Array.} experimentIds + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.experimentIds = $util.emptyArray; + + /** + * UserEvent attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.attributionToken = ""; + + /** + * UserEvent productDetails. + * @member {Array.} productDetails + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.productDetails = $util.emptyArray; + + /** + * UserEvent completionDetail. + * @member {google.cloud.retail.v2beta.ICompletionDetail|null|undefined} completionDetail + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.completionDetail = null; + + /** + * UserEvent attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.attributes = $util.emptyObject; + + /** + * UserEvent cartId. + * @member {string} cartId + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.cartId = ""; + + /** + * UserEvent purchaseTransaction. + * @member {google.cloud.retail.v2beta.IPurchaseTransaction|null|undefined} purchaseTransaction + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.purchaseTransaction = null; + + /** + * UserEvent searchQuery. + * @member {string} searchQuery + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.searchQuery = ""; + + /** + * UserEvent filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.filter = ""; + + /** + * UserEvent orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.orderBy = ""; + + /** + * UserEvent offset. + * @member {number} offset + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.offset = 0; + + /** + * UserEvent pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.pageCategories = $util.emptyArray; + + /** + * UserEvent userInfo. + * @member {google.cloud.retail.v2beta.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.userInfo = null; + + /** + * UserEvent uri. + * @member {string} uri + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.uri = ""; + + /** + * UserEvent referrerUri. + * @member {string} referrerUri + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.referrerUri = ""; + + /** + * UserEvent pageViewId. + * @member {string} pageViewId + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + */ + UserEvent.prototype.pageViewId = ""; + + /** + * Creates a new UserEvent instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {google.cloud.retail.v2beta.IUserEvent=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UserEvent} UserEvent instance + */ + UserEvent.create = function create(properties) { + return new UserEvent(properties); + }; + + /** + * Encodes the specified UserEvent message. Does not implicitly {@link google.cloud.retail.v2beta.UserEvent.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {google.cloud.retail.v2beta.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.eventType != null && Object.hasOwnProperty.call(message, "eventType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.eventType); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.visitorId); + if (message.eventTime != null && Object.hasOwnProperty.call(message, "eventTime")) + $root.google.protobuf.Timestamp.encode(message.eventTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.experimentIds != null && message.experimentIds.length) + for (var i = 0; i < message.experimentIds.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.experimentIds[i]); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.productDetails != null && message.productDetails.length) + for (var i = 0; i < message.productDetails.length; ++i) + $root.google.cloud.retail.v2beta.ProductDetail.encode(message.productDetails[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.retail.v2beta.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.cartId != null && Object.hasOwnProperty.call(message, "cartId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.cartId); + if (message.purchaseTransaction != null && Object.hasOwnProperty.call(message, "purchaseTransaction")) + $root.google.cloud.retail.v2beta.PurchaseTransaction.encode(message.purchaseTransaction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.searchQuery != null && Object.hasOwnProperty.call(message, "searchQuery")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.searchQuery); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.pageCategories[i]); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2beta.UserInfo.encode(message.userInfo, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.uri); + if (message.referrerUri != null && Object.hasOwnProperty.call(message, "referrerUri")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.referrerUri); + if (message.pageViewId != null && Object.hasOwnProperty.call(message, "pageViewId")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.pageViewId); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.orderBy); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 18, wireType 0 =*/144).int32(message.offset); + if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId")) + writer.uint32(/* id 21, wireType 2 =*/170).string(message.sessionId); + if (message.completionDetail != null && Object.hasOwnProperty.call(message, "completionDetail")) + $root.google.cloud.retail.v2beta.CompletionDetail.encode(message.completionDetail, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UserEvent message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UserEvent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {google.cloud.retail.v2beta.IUserEvent} message UserEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserEvent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.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.cloud.retail.v2beta.UserEvent(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.eventType = reader.string(); + break; + } + case 2: { + message.visitorId = reader.string(); + break; + } + case 21: { + message.sessionId = reader.string(); + break; + } + case 3: { + message.eventTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.experimentIds && message.experimentIds.length)) + message.experimentIds = []; + message.experimentIds.push(reader.string()); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + if (!(message.productDetails && message.productDetails.length)) + message.productDetails = []; + message.productDetails.push($root.google.cloud.retail.v2beta.ProductDetail.decode(reader, reader.uint32())); + break; + } + case 22: { + message.completionDetail = $root.google.cloud.retail.v2beta.CompletionDetail.decode(reader, reader.uint32()); + break; + } + case 7: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2beta.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + case 8: { + message.cartId = reader.string(); + break; + } + case 9: { + message.purchaseTransaction = $root.google.cloud.retail.v2beta.PurchaseTransaction.decode(reader, reader.uint32()); + break; + } + case 10: { + message.searchQuery = reader.string(); + break; + } + case 16: { + message.filter = reader.string(); + break; + } + case 17: { + message.orderBy = reader.string(); + break; + } + case 18: { + message.offset = reader.int32(); + break; + } + case 11: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 12: { + message.userInfo = $root.google.cloud.retail.v2beta.UserInfo.decode(reader, reader.uint32()); + break; + } + case 13: { + message.uri = reader.string(); + break; + } + case 14: { + message.referrerUri = reader.string(); + break; + } + case 15: { + message.pageViewId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserEvent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UserEvent} UserEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserEvent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserEvent message. + * @function verify + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserEvent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.eventType != null && message.hasOwnProperty("eventType")) + if (!$util.isString(message.eventType)) + return "eventType: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + if (!$util.isString(message.sessionId)) + return "sessionId: string expected"; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.eventTime); + if (error) + return "eventTime." + error; + } + if (message.experimentIds != null && message.hasOwnProperty("experimentIds")) { + if (!Array.isArray(message.experimentIds)) + return "experimentIds: array expected"; + for (var i = 0; i < message.experimentIds.length; ++i) + if (!$util.isString(message.experimentIds[i])) + return "experimentIds: string[] expected"; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.productDetails != null && message.hasOwnProperty("productDetails")) { + if (!Array.isArray(message.productDetails)) + return "productDetails: array expected"; + for (var i = 0; i < message.productDetails.length; ++i) { + var error = $root.google.cloud.retail.v2beta.ProductDetail.verify(message.productDetails[i]); + if (error) + return "productDetails." + error; + } + } + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) { + var error = $root.google.cloud.retail.v2beta.CompletionDetail.verify(message.completionDetail); + if (error) + return "completionDetail." + error; + } + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + if (!$util.isString(message.cartId)) + return "cartId: string expected"; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) { + var error = $root.google.cloud.retail.v2beta.PurchaseTransaction.verify(message.purchaseTransaction); + if (error) + return "purchaseTransaction." + error; + } + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + if (!$util.isString(message.searchQuery)) + return "searchQuery: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2beta.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + if (!$util.isString(message.referrerUri)) + return "referrerUri: string expected"; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + if (!$util.isString(message.pageViewId)) + return "pageViewId: string expected"; + return null; + }; + + /** + * Creates a UserEvent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UserEvent} UserEvent + */ + UserEvent.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UserEvent) + return object; + var message = new $root.google.cloud.retail.v2beta.UserEvent(); + if (object.eventType != null) + message.eventType = String(object.eventType); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.sessionId != null) + message.sessionId = String(object.sessionId); + if (object.eventTime != null) { + if (typeof object.eventTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.eventTime: object expected"); + message.eventTime = $root.google.protobuf.Timestamp.fromObject(object.eventTime); + } + if (object.experimentIds) { + if (!Array.isArray(object.experimentIds)) + throw TypeError(".google.cloud.retail.v2beta.UserEvent.experimentIds: array expected"); + message.experimentIds = []; + for (var i = 0; i < object.experimentIds.length; ++i) + message.experimentIds[i] = String(object.experimentIds[i]); + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.productDetails) { + if (!Array.isArray(object.productDetails)) + throw TypeError(".google.cloud.retail.v2beta.UserEvent.productDetails: array expected"); + message.productDetails = []; + for (var i = 0; i < object.productDetails.length; ++i) { + if (typeof object.productDetails[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.productDetails: object expected"); + message.productDetails[i] = $root.google.cloud.retail.v2beta.ProductDetail.fromObject(object.productDetails[i]); + } + } + if (object.completionDetail != null) { + if (typeof object.completionDetail !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.completionDetail: object expected"); + message.completionDetail = $root.google.cloud.retail.v2beta.CompletionDetail.fromObject(object.completionDetail); + } + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2beta.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + if (object.cartId != null) + message.cartId = String(object.cartId); + if (object.purchaseTransaction != null) { + if (typeof object.purchaseTransaction !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.purchaseTransaction: object expected"); + message.purchaseTransaction = $root.google.cloud.retail.v2beta.PurchaseTransaction.fromObject(object.purchaseTransaction); + } + if (object.searchQuery != null) + message.searchQuery = String(object.searchQuery); + if (object.filter != null) + message.filter = String(object.filter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2beta.UserEvent.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.UserEvent.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2beta.UserInfo.fromObject(object.userInfo); + } + if (object.uri != null) + message.uri = String(object.uri); + if (object.referrerUri != null) + message.referrerUri = String(object.referrerUri); + if (object.pageViewId != null) + message.pageViewId = String(object.pageViewId); + return message; + }; + + /** + * Creates a plain object from a UserEvent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {google.cloud.retail.v2beta.UserEvent} message UserEvent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserEvent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.experimentIds = []; + object.productDetails = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) { + object.eventType = ""; + object.visitorId = ""; + object.eventTime = null; + object.attributionToken = ""; + object.cartId = ""; + object.purchaseTransaction = null; + object.searchQuery = ""; + object.userInfo = null; + object.uri = ""; + object.referrerUri = ""; + object.pageViewId = ""; + object.filter = ""; + object.orderBy = ""; + object.offset = 0; + object.sessionId = ""; + object.completionDetail = null; + } + if (message.eventType != null && message.hasOwnProperty("eventType")) + object.eventType = message.eventType; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.eventTime != null && message.hasOwnProperty("eventTime")) + object.eventTime = $root.google.protobuf.Timestamp.toObject(message.eventTime, options); + if (message.experimentIds && message.experimentIds.length) { + object.experimentIds = []; + for (var j = 0; j < message.experimentIds.length; ++j) + object.experimentIds[j] = message.experimentIds[j]; + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.productDetails && message.productDetails.length) { + object.productDetails = []; + for (var j = 0; j < message.productDetails.length; ++j) + object.productDetails[j] = $root.google.cloud.retail.v2beta.ProductDetail.toObject(message.productDetails[j], options); + } + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2beta.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + if (message.cartId != null && message.hasOwnProperty("cartId")) + object.cartId = message.cartId; + if (message.purchaseTransaction != null && message.hasOwnProperty("purchaseTransaction")) + object.purchaseTransaction = $root.google.cloud.retail.v2beta.PurchaseTransaction.toObject(message.purchaseTransaction, options); + if (message.searchQuery != null && message.hasOwnProperty("searchQuery")) + object.searchQuery = message.searchQuery; + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2beta.UserInfo.toObject(message.userInfo, options); + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.referrerUri != null && message.hasOwnProperty("referrerUri")) + object.referrerUri = message.referrerUri; + if (message.pageViewId != null && message.hasOwnProperty("pageViewId")) + object.pageViewId = message.pageViewId; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + object.sessionId = message.sessionId; + if (message.completionDetail != null && message.hasOwnProperty("completionDetail")) + object.completionDetail = $root.google.cloud.retail.v2beta.CompletionDetail.toObject(message.completionDetail, options); + return object; + }; + + /** + * Converts this UserEvent to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UserEvent + * @instance + * @returns {Object.} JSON object + */ + UserEvent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UserEvent + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UserEvent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UserEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UserEvent"; + }; + + return UserEvent; + })(); + + v2beta.ProductDetail = (function() { + + /** + * Properties of a ProductDetail. + * @memberof google.cloud.retail.v2beta + * @interface IProductDetail + * @property {google.cloud.retail.v2beta.IProduct|null} [product] ProductDetail product + * @property {google.protobuf.IInt32Value|null} [quantity] ProductDetail quantity + */ + + /** + * Constructs a new ProductDetail. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ProductDetail. + * @implements IProductDetail + * @constructor + * @param {google.cloud.retail.v2beta.IProductDetail=} [properties] Properties to set + */ + function ProductDetail(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]]; + } + + /** + * ProductDetail product. + * @member {google.cloud.retail.v2beta.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2beta.ProductDetail + * @instance + */ + ProductDetail.prototype.product = null; + + /** + * ProductDetail quantity. + * @member {google.protobuf.IInt32Value|null|undefined} quantity + * @memberof google.cloud.retail.v2beta.ProductDetail + * @instance + */ + ProductDetail.prototype.quantity = null; + + /** + * Creates a new ProductDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {google.cloud.retail.v2beta.IProductDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ProductDetail} ProductDetail instance + */ + ProductDetail.create = function create(properties) { + return new ProductDetail(properties); + }; + + /** + * Encodes the specified ProductDetail message. Does not implicitly {@link google.cloud.retail.v2beta.ProductDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {google.cloud.retail.v2beta.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2beta.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.quantity != null && Object.hasOwnProperty.call(message, "quantity")) + $root.google.protobuf.Int32Value.encode(message.quantity, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ProductDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ProductDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {google.cloud.retail.v2beta.IProductDetail} message ProductDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ProductDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.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.cloud.retail.v2beta.ProductDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.quantity = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ProductDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ProductDetail} ProductDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ProductDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ProductDetail message. + * @function verify + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ProductDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.quantity != null && message.hasOwnProperty("quantity")) { + var error = $root.google.protobuf.Int32Value.verify(message.quantity); + if (error) + return "quantity." + error; + } + return null; + }; + + /** + * Creates a ProductDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ProductDetail} ProductDetail + */ + ProductDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ProductDetail) + return object; + var message = new $root.google.cloud.retail.v2beta.ProductDetail(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductDetail.product: object expected"); + message.product = $root.google.cloud.retail.v2beta.Product.fromObject(object.product); + } + if (object.quantity != null) { + if (typeof object.quantity !== "object") + throw TypeError(".google.cloud.retail.v2beta.ProductDetail.quantity: object expected"); + message.quantity = $root.google.protobuf.Int32Value.fromObject(object.quantity); + } + return message; + }; + + /** + * Creates a plain object from a ProductDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {google.cloud.retail.v2beta.ProductDetail} message ProductDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ProductDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.quantity = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2beta.Product.toObject(message.product, options); + if (message.quantity != null && message.hasOwnProperty("quantity")) + object.quantity = $root.google.protobuf.Int32Value.toObject(message.quantity, options); + return object; + }; + + /** + * Converts this ProductDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ProductDetail + * @instance + * @returns {Object.} JSON object + */ + ProductDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ProductDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ProductDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ProductDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ProductDetail"; + }; + + return ProductDetail; + })(); + + v2beta.CompletionDetail = (function() { + + /** + * Properties of a CompletionDetail. + * @memberof google.cloud.retail.v2beta + * @interface ICompletionDetail + * @property {string|null} [completionAttributionToken] CompletionDetail completionAttributionToken + * @property {string|null} [selectedSuggestion] CompletionDetail selectedSuggestion + * @property {number|null} [selectedPosition] CompletionDetail selectedPosition + */ + + /** + * Constructs a new CompletionDetail. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompletionDetail. + * @implements ICompletionDetail + * @constructor + * @param {google.cloud.retail.v2beta.ICompletionDetail=} [properties] Properties to set + */ + function CompletionDetail(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]]; + } + + /** + * CompletionDetail completionAttributionToken. + * @member {string} completionAttributionToken + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @instance + */ + CompletionDetail.prototype.completionAttributionToken = ""; + + /** + * CompletionDetail selectedSuggestion. + * @member {string} selectedSuggestion + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedSuggestion = ""; + + /** + * CompletionDetail selectedPosition. + * @member {number} selectedPosition + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @instance + */ + CompletionDetail.prototype.selectedPosition = 0; + + /** + * Creates a new CompletionDetail instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {google.cloud.retail.v2beta.ICompletionDetail=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompletionDetail} CompletionDetail instance + */ + CompletionDetail.create = function create(properties) { + return new CompletionDetail(properties); + }; + + /** + * Encodes the specified CompletionDetail message. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDetail.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {google.cloud.retail.v2beta.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionAttributionToken != null && Object.hasOwnProperty.call(message, "completionAttributionToken")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.completionAttributionToken); + if (message.selectedSuggestion != null && Object.hasOwnProperty.call(message, "selectedSuggestion")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.selectedSuggestion); + if (message.selectedPosition != null && Object.hasOwnProperty.call(message, "selectedPosition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.selectedPosition); + return writer; + }; + + /** + * Encodes the specified CompletionDetail message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompletionDetail.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {google.cloud.retail.v2beta.ICompletionDetail} message CompletionDetail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionDetail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.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.cloud.retail.v2beta.CompletionDetail(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionAttributionToken = reader.string(); + break; + } + case 2: { + message.selectedSuggestion = reader.string(); + break; + } + case 3: { + message.selectedPosition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionDetail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompletionDetail} CompletionDetail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionDetail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionDetail message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionDetail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + if (!$util.isString(message.completionAttributionToken)) + return "completionAttributionToken: string expected"; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + if (!$util.isString(message.selectedSuggestion)) + return "selectedSuggestion: string expected"; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + if (!$util.isInteger(message.selectedPosition)) + return "selectedPosition: integer expected"; + return null; + }; + + /** + * Creates a CompletionDetail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompletionDetail} CompletionDetail + */ + CompletionDetail.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompletionDetail) + return object; + var message = new $root.google.cloud.retail.v2beta.CompletionDetail(); + if (object.completionAttributionToken != null) + message.completionAttributionToken = String(object.completionAttributionToken); + if (object.selectedSuggestion != null) + message.selectedSuggestion = String(object.selectedSuggestion); + if (object.selectedPosition != null) + message.selectedPosition = object.selectedPosition | 0; + return message; + }; + + /** + * Creates a plain object from a CompletionDetail message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {google.cloud.retail.v2beta.CompletionDetail} message CompletionDetail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionDetail.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionAttributionToken = ""; + object.selectedSuggestion = ""; + object.selectedPosition = 0; + } + if (message.completionAttributionToken != null && message.hasOwnProperty("completionAttributionToken")) + object.completionAttributionToken = message.completionAttributionToken; + if (message.selectedSuggestion != null && message.hasOwnProperty("selectedSuggestion")) + object.selectedSuggestion = message.selectedSuggestion; + if (message.selectedPosition != null && message.hasOwnProperty("selectedPosition")) + object.selectedPosition = message.selectedPosition; + return object; + }; + + /** + * Converts this CompletionDetail to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @instance + * @returns {Object.} JSON object + */ + CompletionDetail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionDetail + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompletionDetail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionDetail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompletionDetail"; + }; + + return CompletionDetail; + })(); + + v2beta.PurchaseTransaction = (function() { + + /** + * Properties of a PurchaseTransaction. + * @memberof google.cloud.retail.v2beta + * @interface IPurchaseTransaction + * @property {string|null} [id] PurchaseTransaction id + * @property {number|null} [revenue] PurchaseTransaction revenue + * @property {number|null} [tax] PurchaseTransaction tax + * @property {number|null} [cost] PurchaseTransaction cost + * @property {string|null} [currencyCode] PurchaseTransaction currencyCode + */ + + /** + * Constructs a new PurchaseTransaction. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PurchaseTransaction. + * @implements IPurchaseTransaction + * @constructor + * @param {google.cloud.retail.v2beta.IPurchaseTransaction=} [properties] Properties to set + */ + function PurchaseTransaction(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]]; + } + + /** + * PurchaseTransaction id. + * @member {string} id + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.id = ""; + + /** + * PurchaseTransaction revenue. + * @member {number} revenue + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.revenue = 0; + + /** + * PurchaseTransaction tax. + * @member {number} tax + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.tax = 0; + + /** + * PurchaseTransaction cost. + * @member {number} cost + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.cost = 0; + + /** + * PurchaseTransaction currencyCode. + * @member {string} currencyCode + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + */ + PurchaseTransaction.prototype.currencyCode = ""; + + /** + * Creates a new PurchaseTransaction instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2beta.IPurchaseTransaction=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PurchaseTransaction} PurchaseTransaction instance + */ + PurchaseTransaction.create = function create(properties) { + return new PurchaseTransaction(properties); + }; + + /** + * Encodes the specified PurchaseTransaction message. Does not implicitly {@link google.cloud.retail.v2beta.PurchaseTransaction.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2beta.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.revenue != null && Object.hasOwnProperty.call(message, "revenue")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.revenue); + if (message.tax != null && Object.hasOwnProperty.call(message, "tax")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.tax); + if (message.cost != null && Object.hasOwnProperty.call(message, "cost")) + writer.uint32(/* id 4, wireType 5 =*/37).float(message.cost); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.currencyCode); + return writer; + }; + + /** + * Encodes the specified PurchaseTransaction message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurchaseTransaction.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2beta.IPurchaseTransaction} message PurchaseTransaction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurchaseTransaction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.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.cloud.retail.v2beta.PurchaseTransaction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.revenue = reader.float(); + break; + } + case 3: { + message.tax = reader.float(); + break; + } + case 4: { + message.cost = reader.float(); + break; + } + case 5: { + message.currencyCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurchaseTransaction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PurchaseTransaction} PurchaseTransaction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurchaseTransaction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurchaseTransaction message. + * @function verify + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurchaseTransaction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.revenue != null && message.hasOwnProperty("revenue")) + if (typeof message.revenue !== "number") + return "revenue: number expected"; + if (message.tax != null && message.hasOwnProperty("tax")) + if (typeof message.tax !== "number") + return "tax: number expected"; + if (message.cost != null && message.hasOwnProperty("cost")) + if (typeof message.cost !== "number") + return "cost: number expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + return null; + }; + + /** + * Creates a PurchaseTransaction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PurchaseTransaction} PurchaseTransaction + */ + PurchaseTransaction.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PurchaseTransaction) + return object; + var message = new $root.google.cloud.retail.v2beta.PurchaseTransaction(); + if (object.id != null) + message.id = String(object.id); + if (object.revenue != null) + message.revenue = Number(object.revenue); + if (object.tax != null) + message.tax = Number(object.tax); + if (object.cost != null) + message.cost = Number(object.cost); + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + return message; + }; + + /** + * Creates a plain object from a PurchaseTransaction message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {google.cloud.retail.v2beta.PurchaseTransaction} message PurchaseTransaction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurchaseTransaction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.revenue = 0; + object.tax = 0; + object.cost = 0; + object.currencyCode = ""; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.revenue != null && message.hasOwnProperty("revenue")) + object.revenue = options.json && !isFinite(message.revenue) ? String(message.revenue) : message.revenue; + if (message.tax != null && message.hasOwnProperty("tax")) + object.tax = options.json && !isFinite(message.tax) ? String(message.tax) : message.tax; + if (message.cost != null && message.hasOwnProperty("cost")) + object.cost = options.json && !isFinite(message.cost) ? String(message.cost) : message.cost; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + return object; + }; + + /** + * Converts this PurchaseTransaction to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @instance + * @returns {Object.} JSON object + */ + PurchaseTransaction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurchaseTransaction + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PurchaseTransaction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurchaseTransaction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PurchaseTransaction"; + }; + + return PurchaseTransaction; + })(); + + v2beta.CatalogService = (function() { + + /** + * Constructs a new CatalogService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CatalogService + * @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 CatalogService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CatalogService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CatalogService; + + /** + * Creates new CatalogService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.CatalogService + * @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 {CatalogService} RPC service. Useful where requests and/or responses are streamed. + */ + CatalogService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|listCatalogs}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef ListCatalogsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ListCatalogsResponse} [response] ListCatalogsResponse + */ + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.ListCatalogsCallback} callback Node-style callback called with the error, if any, and ListCatalogsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.listCatalogs = function listCatalogs(request, callback) { + return this.rpcCall(listCatalogs, $root.google.cloud.retail.v2beta.ListCatalogsRequest, $root.google.cloud.retail.v2beta.ListCatalogsResponse, request, callback); + }, "name", { value: "ListCatalogs" }); + + /** + * Calls ListCatalogs. + * @function listCatalogs + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IListCatalogsRequest} request ListCatalogsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateCatalog}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef UpdateCatalogCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Catalog} [response] Catalog + */ + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.UpdateCatalogCallback} callback Node-style callback called with the error, if any, and Catalog + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCatalog = function updateCatalog(request, callback) { + return this.rpcCall(updateCatalog, $root.google.cloud.retail.v2beta.UpdateCatalogRequest, $root.google.cloud.retail.v2beta.Catalog, request, callback); + }, "name", { value: "UpdateCatalog" }); + + /** + * Calls UpdateCatalog. + * @function updateCatalog + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest} request UpdateCatalogRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|setDefaultBranch}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef SetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.SetDefaultBranchCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.setDefaultBranch = function setDefaultBranch(request, callback) { + return this.rpcCall(setDefaultBranch, $root.google.cloud.retail.v2beta.SetDefaultBranchRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "SetDefaultBranch" }); + + /** + * Calls SetDefaultBranch. + * @function setDefaultBranch + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest} request SetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getDefaultBranch}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef GetDefaultBranchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.GetDefaultBranchResponse} [response] GetDefaultBranchResponse + */ + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.GetDefaultBranchCallback} callback Node-style callback called with the error, if any, and GetDefaultBranchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getDefaultBranch = function getDefaultBranch(request, callback) { + return this.rpcCall(getDefaultBranch, $root.google.cloud.retail.v2beta.GetDefaultBranchRequest, $root.google.cloud.retail.v2beta.GetDefaultBranchResponse, request, callback); + }, "name", { value: "GetDefaultBranch" }); + + /** + * Calls GetDefaultBranch. + * @function getDefaultBranch + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest} request GetDefaultBranchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getCompletionConfig}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef GetCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.GetCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getCompletionConfig = function getCompletionConfig(request, callback) { + return this.rpcCall(getCompletionConfig, $root.google.cloud.retail.v2beta.GetCompletionConfigRequest, $root.google.cloud.retail.v2beta.CompletionConfig, request, callback); + }, "name", { value: "GetCompletionConfig" }); + + /** + * Calls GetCompletionConfig. + * @function getCompletionConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest} request GetCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateCompletionConfig}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef UpdateCompletionConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.CompletionConfig} [response] CompletionConfig + */ + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfigCallback} callback Node-style callback called with the error, if any, and CompletionConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateCompletionConfig = function updateCompletionConfig(request, callback) { + return this.rpcCall(updateCompletionConfig, $root.google.cloud.retail.v2beta.UpdateCompletionConfigRequest, $root.google.cloud.retail.v2beta.CompletionConfig, request, callback); + }, "name", { value: "UpdateCompletionConfig" }); + + /** + * Calls UpdateCompletionConfig. + * @function updateCompletionConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest} request UpdateCompletionConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|getAttributesConfig}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef GetAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.GetAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.getAttributesConfig = function getAttributesConfig(request, callback) { + return this.rpcCall(getAttributesConfig, $root.google.cloud.retail.v2beta.GetAttributesConfigRequest, $root.google.cloud.retail.v2beta.AttributesConfig, request, callback); + }, "name", { value: "GetAttributesConfig" }); + + /** + * Calls GetAttributesConfig. + * @function getAttributesConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest} request GetAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|updateAttributesConfig}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef UpdateAttributesConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfigCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.updateAttributesConfig = function updateAttributesConfig(request, callback) { + return this.rpcCall(updateAttributesConfig, $root.google.cloud.retail.v2beta.UpdateAttributesConfigRequest, $root.google.cloud.retail.v2beta.AttributesConfig, request, callback); + }, "name", { value: "UpdateAttributesConfig" }); + + /** + * Calls UpdateAttributesConfig. + * @function updateAttributesConfig + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest} request UpdateAttributesConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|addCatalogAttribute}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef AddCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.AddCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.addCatalogAttribute = function addCatalogAttribute(request, callback) { + return this.rpcCall(addCatalogAttribute, $root.google.cloud.retail.v2beta.AddCatalogAttributeRequest, $root.google.cloud.retail.v2beta.AttributesConfig, request, callback); + }, "name", { value: "AddCatalogAttribute" }); + + /** + * Calls AddCatalogAttribute. + * @function addCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest} request AddCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|removeCatalogAttribute}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef RemoveCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.removeCatalogAttribute = function removeCatalogAttribute(request, callback) { + return this.rpcCall(removeCatalogAttribute, $root.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest, $root.google.cloud.retail.v2beta.AttributesConfig, request, callback); + }, "name", { value: "RemoveCatalogAttribute" }); + + /** + * Calls RemoveCatalogAttribute. + * @function removeCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest} request RemoveCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|batchRemoveCatalogAttributes}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef BatchRemoveCatalogAttributesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} [response] BatchRemoveCatalogAttributesResponse + */ + + /** + * Calls BatchRemoveCatalogAttributes. + * @function batchRemoveCatalogAttributes + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest} request BatchRemoveCatalogAttributesRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributesCallback} callback Node-style callback called with the error, if any, and BatchRemoveCatalogAttributesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.batchRemoveCatalogAttributes = function batchRemoveCatalogAttributes(request, callback) { + return this.rpcCall(batchRemoveCatalogAttributes, $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest, $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse, request, callback); + }, "name", { value: "BatchRemoveCatalogAttributes" }); + + /** + * Calls BatchRemoveCatalogAttributes. + * @function batchRemoveCatalogAttributes + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest} request BatchRemoveCatalogAttributesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CatalogService|replaceCatalogAttribute}. + * @memberof google.cloud.retail.v2beta.CatalogService + * @typedef ReplaceCatalogAttributeCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.AttributesConfig} [response] AttributesConfig + */ + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @param {google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttributeCallback} callback Node-style callback called with the error, if any, and AttributesConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CatalogService.prototype.replaceCatalogAttribute = function replaceCatalogAttribute(request, callback) { + return this.rpcCall(replaceCatalogAttribute, $root.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest, $root.google.cloud.retail.v2beta.AttributesConfig, request, callback); + }, "name", { value: "ReplaceCatalogAttribute" }); + + /** + * Calls ReplaceCatalogAttribute. + * @function replaceCatalogAttribute + * @memberof google.cloud.retail.v2beta.CatalogService + * @instance + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest} request ReplaceCatalogAttributeRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CatalogService; + })(); + + v2beta.ListCatalogsRequest = (function() { + + /** + * Properties of a ListCatalogsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IListCatalogsRequest + * @property {string|null} [parent] ListCatalogsRequest parent + * @property {number|null} [pageSize] ListCatalogsRequest pageSize + * @property {string|null} [pageToken] ListCatalogsRequest pageToken + */ + + /** + * Constructs a new ListCatalogsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListCatalogsRequest. + * @implements IListCatalogsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IListCatalogsRequest=} [properties] Properties to set + */ + function ListCatalogsRequest(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]]; + } + + /** + * ListCatalogsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.parent = ""; + + /** + * ListCatalogsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageSize = 0; + + /** + * ListCatalogsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @instance + */ + ListCatalogsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListCatalogsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListCatalogsRequest} ListCatalogsRequest instance + */ + ListCatalogsRequest.create = function create(properties) { + return new ListCatalogsRequest(properties); + }; + + /** + * Encodes the specified ListCatalogsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListCatalogsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsRequest} message ListCatalogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.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.cloud.retail.v2beta.ListCatalogsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListCatalogsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListCatalogsRequest} ListCatalogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListCatalogsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListCatalogsRequest} ListCatalogsRequest + */ + ListCatalogsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListCatalogsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ListCatalogsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListCatalogsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {google.cloud.retail.v2beta.ListCatalogsRequest} message ListCatalogsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListCatalogsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListCatalogsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListCatalogsRequest"; + }; + + return ListCatalogsRequest; + })(); + + v2beta.ListCatalogsResponse = (function() { + + /** + * Properties of a ListCatalogsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IListCatalogsResponse + * @property {Array.|null} [catalogs] ListCatalogsResponse catalogs + * @property {string|null} [nextPageToken] ListCatalogsResponse nextPageToken + */ + + /** + * Constructs a new ListCatalogsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListCatalogsResponse. + * @implements IListCatalogsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IListCatalogsResponse=} [properties] Properties to set + */ + function ListCatalogsResponse(properties) { + this.catalogs = []; + 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]]; + } + + /** + * ListCatalogsResponse catalogs. + * @member {Array.} catalogs + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.catalogs = $util.emptyArray; + + /** + * ListCatalogsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @instance + */ + ListCatalogsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListCatalogsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListCatalogsResponse} ListCatalogsResponse instance + */ + ListCatalogsResponse.create = function create(properties) { + return new ListCatalogsResponse(properties); + }; + + /** + * Encodes the specified ListCatalogsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalogs != null && message.catalogs.length) + for (var i = 0; i < message.catalogs.length; ++i) + $root.google.cloud.retail.v2beta.Catalog.encode(message.catalogs[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 ListCatalogsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListCatalogsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2beta.IListCatalogsResponse} message ListCatalogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCatalogsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.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.cloud.retail.v2beta.ListCatalogsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.catalogs && message.catalogs.length)) + message.catalogs = []; + message.catalogs.push($root.google.cloud.retail.v2beta.Catalog.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCatalogsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListCatalogsResponse} ListCatalogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCatalogsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCatalogsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCatalogsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalogs != null && message.hasOwnProperty("catalogs")) { + if (!Array.isArray(message.catalogs)) + return "catalogs: array expected"; + for (var i = 0; i < message.catalogs.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Catalog.verify(message.catalogs[i]); + if (error) + return "catalogs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListCatalogsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListCatalogsResponse} ListCatalogsResponse + */ + ListCatalogsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListCatalogsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ListCatalogsResponse(); + if (object.catalogs) { + if (!Array.isArray(object.catalogs)) + throw TypeError(".google.cloud.retail.v2beta.ListCatalogsResponse.catalogs: array expected"); + message.catalogs = []; + for (var i = 0; i < object.catalogs.length; ++i) { + if (typeof object.catalogs[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListCatalogsResponse.catalogs: object expected"); + message.catalogs[i] = $root.google.cloud.retail.v2beta.Catalog.fromObject(object.catalogs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCatalogsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {google.cloud.retail.v2beta.ListCatalogsResponse} message ListCatalogsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCatalogsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.catalogs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.catalogs && message.catalogs.length) { + object.catalogs = []; + for (var j = 0; j < message.catalogs.length; ++j) + object.catalogs[j] = $root.google.cloud.retail.v2beta.Catalog.toObject(message.catalogs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCatalogsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @instance + * @returns {Object.} JSON object + */ + ListCatalogsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListCatalogsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListCatalogsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListCatalogsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListCatalogsResponse"; + }; + + return ListCatalogsResponse; + })(); + + v2beta.UpdateCatalogRequest = (function() { + + /** + * Properties of an UpdateCatalogRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateCatalogRequest + * @property {google.cloud.retail.v2beta.ICatalog|null} [catalog] UpdateCatalogRequest catalog + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCatalogRequest updateMask + */ + + /** + * Constructs a new UpdateCatalogRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateCatalogRequest. + * @implements IUpdateCatalogRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest=} [properties] Properties to set + */ + function UpdateCatalogRequest(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]]; + } + + /** + * UpdateCatalogRequest catalog. + * @member {google.cloud.retail.v2beta.ICatalog|null|undefined} catalog + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.catalog = null; + + /** + * UpdateCatalogRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @instance + */ + UpdateCatalogRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCatalogRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateCatalogRequest} UpdateCatalogRequest instance + */ + UpdateCatalogRequest.create = function create(properties) { + return new UpdateCatalogRequest(properties); + }; + + /** + * Encodes the specified UpdateCatalogRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCatalogRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + $root.google.cloud.retail.v2beta.Catalog.encode(message.catalog, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCatalogRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCatalogRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCatalogRequest} message UpdateCatalogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCatalogRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.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.cloud.retail.v2beta.UpdateCatalogRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = $root.google.cloud.retail.v2beta.Catalog.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCatalogRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateCatalogRequest} UpdateCatalogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCatalogRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCatalogRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCatalogRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) { + var error = $root.google.cloud.retail.v2beta.Catalog.verify(message.catalog); + if (error) + return "catalog." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCatalogRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateCatalogRequest} UpdateCatalogRequest + */ + UpdateCatalogRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateCatalogRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateCatalogRequest(); + if (object.catalog != null) { + if (typeof object.catalog !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateCatalogRequest.catalog: object expected"); + message.catalog = $root.google.cloud.retail.v2beta.Catalog.fromObject(object.catalog); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateCatalogRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCatalogRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateCatalogRequest} message UpdateCatalogRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCatalogRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = null; + object.updateMask = null; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = $root.google.cloud.retail.v2beta.Catalog.toObject(message.catalog, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCatalogRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCatalogRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCatalogRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateCatalogRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCatalogRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateCatalogRequest"; + }; + + return UpdateCatalogRequest; + })(); + + v2beta.SetDefaultBranchRequest = (function() { + + /** + * Properties of a SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2beta + * @interface ISetDefaultBranchRequest + * @property {string|null} [catalog] SetDefaultBranchRequest catalog + * @property {string|null} [branchId] SetDefaultBranchRequest branchId + * @property {string|null} [note] SetDefaultBranchRequest note + * @property {boolean|null} [force] SetDefaultBranchRequest force + */ + + /** + * Constructs a new SetDefaultBranchRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SetDefaultBranchRequest. + * @implements ISetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest=} [properties] Properties to set + */ + function SetDefaultBranchRequest(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]]; + } + + /** + * SetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.catalog = ""; + + /** + * SetDefaultBranchRequest branchId. + * @member {string} branchId + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.branchId = ""; + + /** + * SetDefaultBranchRequest note. + * @member {string} note + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.note = ""; + + /** + * SetDefaultBranchRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @instance + */ + SetDefaultBranchRequest.prototype.force = false; + + /** + * Creates a new SetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SetDefaultBranchRequest} SetDefaultBranchRequest instance + */ + SetDefaultBranchRequest.create = function create(properties) { + return new SetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified SetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.branchId != null && Object.hasOwnProperty.call(message, "branchId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branchId); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.force); + return writer; + }; + + /** + * Encodes the specified SetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.ISetDefaultBranchRequest} message SetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.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.cloud.retail.v2beta.SetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.branchId = reader.string(); + break; + } + case 3: { + message.note = reader.string(); + break; + } + case 4: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SetDefaultBranchRequest} SetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.branchId != null && message.hasOwnProperty("branchId")) + if (!$util.isString(message.branchId)) + return "branchId: string expected"; + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a SetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SetDefaultBranchRequest} SetDefaultBranchRequest + */ + SetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.SetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.branchId != null) + message.branchId = String(object.branchId); + if (object.note != null) + message.note = String(object.note); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a SetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.SetDefaultBranchRequest} message SetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.catalog = ""; + object.branchId = ""; + object.note = ""; + object.force = false; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.branchId != null && message.hasOwnProperty("branchId")) + object.branchId = message.branchId; + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this SetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + SetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SetDefaultBranchRequest"; + }; + + return SetDefaultBranchRequest; + })(); + + v2beta.GetDefaultBranchRequest = (function() { + + /** + * Properties of a GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetDefaultBranchRequest + * @property {string|null} [catalog] GetDefaultBranchRequest catalog + */ + + /** + * Constructs a new GetDefaultBranchRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetDefaultBranchRequest. + * @implements IGetDefaultBranchRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest=} [properties] Properties to set + */ + function GetDefaultBranchRequest(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]]; + } + + /** + * GetDefaultBranchRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @instance + */ + GetDefaultBranchRequest.prototype.catalog = ""; + + /** + * Creates a new GetDefaultBranchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetDefaultBranchRequest} GetDefaultBranchRequest instance + */ + GetDefaultBranchRequest.create = function create(properties) { + return new GetDefaultBranchRequest(properties); + }; + + /** + * Encodes the specified GetDefaultBranchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchRequest} message GetDefaultBranchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.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.cloud.retail.v2beta.GetDefaultBranchRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetDefaultBranchRequest} GetDefaultBranchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetDefaultBranchRequest} GetDefaultBranchRequest + */ + GetDefaultBranchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetDefaultBranchRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetDefaultBranchRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {google.cloud.retail.v2beta.GetDefaultBranchRequest} message GetDefaultBranchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.catalog = ""; + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + return object; + }; + + /** + * Converts this GetDefaultBranchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetDefaultBranchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetDefaultBranchRequest"; + }; + + return GetDefaultBranchRequest; + })(); + + v2beta.GetDefaultBranchResponse = (function() { + + /** + * Properties of a GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2beta + * @interface IGetDefaultBranchResponse + * @property {string|null} [branch] GetDefaultBranchResponse branch + * @property {google.protobuf.ITimestamp|null} [setTime] GetDefaultBranchResponse setTime + * @property {string|null} [note] GetDefaultBranchResponse note + */ + + /** + * Constructs a new GetDefaultBranchResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetDefaultBranchResponse. + * @implements IGetDefaultBranchResponse + * @constructor + * @param {google.cloud.retail.v2beta.IGetDefaultBranchResponse=} [properties] Properties to set + */ + function GetDefaultBranchResponse(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]]; + } + + /** + * GetDefaultBranchResponse branch. + * @member {string} branch + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.branch = ""; + + /** + * GetDefaultBranchResponse setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.setTime = null; + + /** + * GetDefaultBranchResponse note. + * @member {string} note + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @instance + */ + GetDefaultBranchResponse.prototype.note = ""; + + /** + * Creates a new GetDefaultBranchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetDefaultBranchResponse} GetDefaultBranchResponse instance + */ + GetDefaultBranchResponse.create = function create(properties) { + return new GetDefaultBranchResponse(properties); + }; + + /** + * Encodes the specified GetDefaultBranchResponse message. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.branch); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.note != null && Object.hasOwnProperty.call(message, "note")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.note); + return writer; + }; + + /** + * Encodes the specified GetDefaultBranchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetDefaultBranchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2beta.IGetDefaultBranchResponse} message GetDefaultBranchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDefaultBranchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.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.cloud.retail.v2beta.GetDefaultBranchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.branch = reader.string(); + break; + } + case 2: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.note = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDefaultBranchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetDefaultBranchResponse} GetDefaultBranchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDefaultBranchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDefaultBranchResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDefaultBranchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.note != null && message.hasOwnProperty("note")) + if (!$util.isString(message.note)) + return "note: string expected"; + return null; + }; + + /** + * Creates a GetDefaultBranchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetDefaultBranchResponse} GetDefaultBranchResponse + */ + GetDefaultBranchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetDefaultBranchResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.GetDefaultBranchResponse(); + if (object.branch != null) + message.branch = String(object.branch); + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.GetDefaultBranchResponse.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.note != null) + message.note = String(object.note); + return message; + }; + + /** + * Creates a plain object from a GetDefaultBranchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {google.cloud.retail.v2beta.GetDefaultBranchResponse} message GetDefaultBranchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDefaultBranchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.branch = ""; + object.setTime = null; + object.note = ""; + } + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.note != null && message.hasOwnProperty("note")) + object.note = message.note; + return object; + }; + + /** + * Converts this GetDefaultBranchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @instance + * @returns {Object.} JSON object + */ + GetDefaultBranchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDefaultBranchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetDefaultBranchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDefaultBranchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetDefaultBranchResponse"; + }; + + return GetDefaultBranchResponse; + })(); + + v2beta.GetCompletionConfigRequest = (function() { + + /** + * Properties of a GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetCompletionConfigRequest + * @property {string|null} [name] GetCompletionConfigRequest name + */ + + /** + * Constructs a new GetCompletionConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetCompletionConfigRequest. + * @implements IGetCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest=} [properties] Properties to set + */ + function GetCompletionConfigRequest(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]]; + } + + /** + * GetCompletionConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @instance + */ + GetCompletionConfigRequest.prototype.name = ""; + + /** + * Creates a new GetCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetCompletionConfigRequest} GetCompletionConfigRequest instance + */ + GetCompletionConfigRequest.create = function create(properties) { + return new GetCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified GetCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetCompletionConfigRequest} message GetCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.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.cloud.retail.v2beta.GetCompletionConfigRequest(); + 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 GetCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetCompletionConfigRequest} GetCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetCompletionConfigRequest} GetCompletionConfigRequest + */ + GetCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetCompletionConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.GetCompletionConfigRequest} message GetCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCompletionConfigRequest.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 GetCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetCompletionConfigRequest"; + }; + + return GetCompletionConfigRequest; + })(); + + v2beta.UpdateCompletionConfigRequest = (function() { + + /** + * Properties of an UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateCompletionConfigRequest + * @property {google.cloud.retail.v2beta.ICompletionConfig|null} [completionConfig] UpdateCompletionConfigRequest completionConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCompletionConfigRequest updateMask + */ + + /** + * Constructs a new UpdateCompletionConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateCompletionConfigRequest. + * @implements IUpdateCompletionConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest=} [properties] Properties to set + */ + function UpdateCompletionConfigRequest(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]]; + } + + /** + * UpdateCompletionConfigRequest completionConfig. + * @member {google.cloud.retail.v2beta.ICompletionConfig|null|undefined} completionConfig + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.completionConfig = null; + + /** + * UpdateCompletionConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @instance + */ + UpdateCompletionConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCompletionConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest instance + */ + UpdateCompletionConfigRequest.create = function create(properties) { + return new UpdateCompletionConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionConfig != null && Object.hasOwnProperty.call(message, "completionConfig")) + $root.google.cloud.retail.v2beta.CompletionConfig.encode(message.completionConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCompletionConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateCompletionConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateCompletionConfigRequest} message UpdateCompletionConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCompletionConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.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.cloud.retail.v2beta.UpdateCompletionConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.completionConfig = $root.google.cloud.retail.v2beta.CompletionConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCompletionConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCompletionConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCompletionConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCompletionConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) { + var error = $root.google.cloud.retail.v2beta.CompletionConfig.verify(message.completionConfig); + if (error) + return "completionConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCompletionConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateCompletionConfigRequest} UpdateCompletionConfigRequest + */ + UpdateCompletionConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateCompletionConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateCompletionConfigRequest(); + if (object.completionConfig != null) { + if (typeof object.completionConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateCompletionConfigRequest.completionConfig: object expected"); + message.completionConfig = $root.google.cloud.retail.v2beta.CompletionConfig.fromObject(object.completionConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateCompletionConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCompletionConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateCompletionConfigRequest} message UpdateCompletionConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCompletionConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.completionConfig = null; + object.updateMask = null; + } + if (message.completionConfig != null && message.hasOwnProperty("completionConfig")) + object.completionConfig = $root.google.cloud.retail.v2beta.CompletionConfig.toObject(message.completionConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCompletionConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCompletionConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateCompletionConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateCompletionConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateCompletionConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateCompletionConfigRequest"; + }; + + return UpdateCompletionConfigRequest; + })(); + + v2beta.GetAttributesConfigRequest = (function() { + + /** + * Properties of a GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetAttributesConfigRequest + * @property {string|null} [name] GetAttributesConfigRequest name + */ + + /** + * Constructs a new GetAttributesConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetAttributesConfigRequest. + * @implements IGetAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest=} [properties] Properties to set + */ + function GetAttributesConfigRequest(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]]; + } + + /** + * GetAttributesConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @instance + */ + GetAttributesConfigRequest.prototype.name = ""; + + /** + * Creates a new GetAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetAttributesConfigRequest} GetAttributesConfigRequest instance + */ + GetAttributesConfigRequest.create = function create(properties) { + return new GetAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified GetAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetAttributesConfigRequest} message GetAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.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.cloud.retail.v2beta.GetAttributesConfigRequest(); + 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 GetAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetAttributesConfigRequest} GetAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetAttributesConfigRequest} GetAttributesConfigRequest + */ + GetAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetAttributesConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.GetAttributesConfigRequest} message GetAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetAttributesConfigRequest.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 GetAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetAttributesConfigRequest"; + }; + + return GetAttributesConfigRequest; + })(); + + v2beta.UpdateAttributesConfigRequest = (function() { + + /** + * Properties of an UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateAttributesConfigRequest + * @property {google.cloud.retail.v2beta.IAttributesConfig|null} [attributesConfig] UpdateAttributesConfigRequest attributesConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateAttributesConfigRequest updateMask + */ + + /** + * Constructs a new UpdateAttributesConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateAttributesConfigRequest. + * @implements IUpdateAttributesConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest=} [properties] Properties to set + */ + function UpdateAttributesConfigRequest(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]]; + } + + /** + * UpdateAttributesConfigRequest attributesConfig. + * @member {google.cloud.retail.v2beta.IAttributesConfig|null|undefined} attributesConfig + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.attributesConfig = null; + + /** + * UpdateAttributesConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @instance + */ + UpdateAttributesConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateAttributesConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest instance + */ + UpdateAttributesConfigRequest.create = function create(properties) { + return new UpdateAttributesConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + $root.google.cloud.retail.v2beta.AttributesConfig.encode(message.attributesConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateAttributesConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateAttributesConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateAttributesConfigRequest} message UpdateAttributesConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateAttributesConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.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.cloud.retail.v2beta.UpdateAttributesConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = $root.google.cloud.retail.v2beta.AttributesConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateAttributesConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateAttributesConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateAttributesConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateAttributesConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) { + var error = $root.google.cloud.retail.v2beta.AttributesConfig.verify(message.attributesConfig); + if (error) + return "attributesConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateAttributesConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateAttributesConfigRequest} UpdateAttributesConfigRequest + */ + UpdateAttributesConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateAttributesConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateAttributesConfigRequest(); + if (object.attributesConfig != null) { + if (typeof object.attributesConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateAttributesConfigRequest.attributesConfig: object expected"); + message.attributesConfig = $root.google.cloud.retail.v2beta.AttributesConfig.fromObject(object.attributesConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateAttributesConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateAttributesConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateAttributesConfigRequest} message UpdateAttributesConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateAttributesConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = $root.google.cloud.retail.v2beta.AttributesConfig.toObject(message.attributesConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateAttributesConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateAttributesConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateAttributesConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateAttributesConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateAttributesConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateAttributesConfigRequest"; + }; + + return UpdateAttributesConfigRequest; + })(); + + v2beta.AddCatalogAttributeRequest = (function() { + + /** + * Properties of an AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @interface IAddCatalogAttributeRequest + * @property {string|null} [attributesConfig] AddCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2beta.ICatalogAttribute|null} [catalogAttribute] AddCatalogAttributeRequest catalogAttribute + */ + + /** + * Constructs a new AddCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddCatalogAttributeRequest. + * @implements IAddCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest=} [properties] Properties to set + */ + function AddCatalogAttributeRequest(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]]; + } + + /** + * AddCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * AddCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2beta.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @instance + */ + AddCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * Creates a new AddCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddCatalogAttributeRequest} AddCatalogAttributeRequest instance + */ + AddCatalogAttributeRequest.create = function create(properties) { + return new AddCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2beta.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AddCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IAddCatalogAttributeRequest} message AddCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.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.cloud.retail.v2beta.AddCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddCatalogAttributeRequest} AddCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2beta.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + return null; + }; + + /** + * Creates an AddCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddCatalogAttributeRequest} AddCatalogAttributeRequest + */ + AddCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.AddCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2beta.AddCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.fromObject(object.catalogAttribute); + } + return message; + }; + + /** + * Creates a plain object from an AddCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.AddCatalogAttributeRequest} message AddCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.toObject(message.catalogAttribute, options); + return object; + }; + + /** + * Converts this AddCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + AddCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddCatalogAttributeRequest"; + }; + + return AddCatalogAttributeRequest; + })(); + + v2beta.RemoveCatalogAttributeRequest = (function() { + + /** + * Properties of a RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveCatalogAttributeRequest + * @property {string|null} [attributesConfig] RemoveCatalogAttributeRequest attributesConfig + * @property {string|null} [key] RemoveCatalogAttributeRequest key + */ + + /** + * Constructs a new RemoveCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveCatalogAttributeRequest. + * @implements IRemoveCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest=} [properties] Properties to set + */ + function RemoveCatalogAttributeRequest(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]]; + } + + /** + * RemoveCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * RemoveCatalogAttributeRequest key. + * @member {string} key + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @instance + */ + RemoveCatalogAttributeRequest.prototype.key = ""; + + /** + * Creates a new RemoveCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest instance + */ + RemoveCatalogAttributeRequest.create = function create(properties) { + return new RemoveCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.key); + return writer; + }; + + /** + * Encodes the specified RemoveCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.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.cloud.retail.v2beta.RemoveCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.key = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + return null; + }; + + /** + * Creates a RemoveCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveCatalogAttributeRequest} RemoveCatalogAttributeRequest + */ + RemoveCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.key != null) + message.key = String(object.key); + return message; + }; + + /** + * Creates a plain object from a RemoveCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.RemoveCatalogAttributeRequest} message RemoveCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.key = ""; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + return object; + }; + + /** + * Converts this RemoveCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveCatalogAttributeRequest"; + }; + + return RemoveCatalogAttributeRequest; + })(); + + v2beta.BatchRemoveCatalogAttributesRequest = (function() { + + /** + * Properties of a BatchRemoveCatalogAttributesRequest. + * @memberof google.cloud.retail.v2beta + * @interface IBatchRemoveCatalogAttributesRequest + * @property {string|null} [attributesConfig] BatchRemoveCatalogAttributesRequest attributesConfig + * @property {Array.|null} [attributeKeys] BatchRemoveCatalogAttributesRequest attributeKeys + */ + + /** + * Constructs a new BatchRemoveCatalogAttributesRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a BatchRemoveCatalogAttributesRequest. + * @implements IBatchRemoveCatalogAttributesRequest + * @constructor + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest=} [properties] Properties to set + */ + function BatchRemoveCatalogAttributesRequest(properties) { + this.attributeKeys = []; + 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]]; + } + + /** + * BatchRemoveCatalogAttributesRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @instance + */ + BatchRemoveCatalogAttributesRequest.prototype.attributesConfig = ""; + + /** + * BatchRemoveCatalogAttributesRequest attributeKeys. + * @member {Array.} attributeKeys + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @instance + */ + BatchRemoveCatalogAttributesRequest.prototype.attributeKeys = $util.emptyArray; + + /** + * Creates a new BatchRemoveCatalogAttributesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest} BatchRemoveCatalogAttributesRequest instance + */ + BatchRemoveCatalogAttributesRequest.create = function create(properties) { + return new BatchRemoveCatalogAttributesRequest(properties); + }; + + /** + * Encodes the specified BatchRemoveCatalogAttributesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest} message BatchRemoveCatalogAttributesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRemoveCatalogAttributesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.attributeKeys != null && message.attributeKeys.length) + for (var i = 0; i < message.attributeKeys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributeKeys[i]); + return writer; + }; + + /** + * Encodes the specified BatchRemoveCatalogAttributesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest} message BatchRemoveCatalogAttributesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRemoveCatalogAttributesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRemoveCatalogAttributesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest} BatchRemoveCatalogAttributesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRemoveCatalogAttributesRequest.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.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + if (!(message.attributeKeys && message.attributeKeys.length)) + message.attributeKeys = []; + message.attributeKeys.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRemoveCatalogAttributesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest} BatchRemoveCatalogAttributesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRemoveCatalogAttributesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRemoveCatalogAttributesRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRemoveCatalogAttributesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.attributeKeys != null && message.hasOwnProperty("attributeKeys")) { + if (!Array.isArray(message.attributeKeys)) + return "attributeKeys: array expected"; + for (var i = 0; i < message.attributeKeys.length; ++i) + if (!$util.isString(message.attributeKeys[i])) + return "attributeKeys: string[] expected"; + } + return null; + }; + + /** + * Creates a BatchRemoveCatalogAttributesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest} BatchRemoveCatalogAttributesRequest + */ + BatchRemoveCatalogAttributesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.attributeKeys) { + if (!Array.isArray(object.attributeKeys)) + throw TypeError(".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest.attributeKeys: array expected"); + message.attributeKeys = []; + for (var i = 0; i < object.attributeKeys.length; ++i) + message.attributeKeys[i] = String(object.attributeKeys[i]); + } + return message; + }; + + /** + * Creates a plain object from a BatchRemoveCatalogAttributesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest} message BatchRemoveCatalogAttributesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRemoveCatalogAttributesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.attributeKeys = []; + if (options.defaults) + object.attributesConfig = ""; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.attributeKeys && message.attributeKeys.length) { + object.attributeKeys = []; + for (var j = 0; j < message.attributeKeys.length; ++j) + object.attributeKeys[j] = message.attributeKeys[j]; + } + return object; + }; + + /** + * Converts this BatchRemoveCatalogAttributesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @instance + * @returns {Object.} JSON object + */ + BatchRemoveCatalogAttributesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRemoveCatalogAttributesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRemoveCatalogAttributesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest"; + }; + + return BatchRemoveCatalogAttributesRequest; + })(); + + v2beta.BatchRemoveCatalogAttributesResponse = (function() { + + /** + * Properties of a BatchRemoveCatalogAttributesResponse. + * @memberof google.cloud.retail.v2beta + * @interface IBatchRemoveCatalogAttributesResponse + * @property {Array.|null} [deletedCatalogAttributes] BatchRemoveCatalogAttributesResponse deletedCatalogAttributes + * @property {Array.|null} [resetCatalogAttributes] BatchRemoveCatalogAttributesResponse resetCatalogAttributes + */ + + /** + * Constructs a new BatchRemoveCatalogAttributesResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a BatchRemoveCatalogAttributesResponse. + * @implements IBatchRemoveCatalogAttributesResponse + * @constructor + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse=} [properties] Properties to set + */ + function BatchRemoveCatalogAttributesResponse(properties) { + this.deletedCatalogAttributes = []; + this.resetCatalogAttributes = []; + 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]]; + } + + /** + * BatchRemoveCatalogAttributesResponse deletedCatalogAttributes. + * @member {Array.} deletedCatalogAttributes + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @instance + */ + BatchRemoveCatalogAttributesResponse.prototype.deletedCatalogAttributes = $util.emptyArray; + + /** + * BatchRemoveCatalogAttributesResponse resetCatalogAttributes. + * @member {Array.} resetCatalogAttributes + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @instance + */ + BatchRemoveCatalogAttributesResponse.prototype.resetCatalogAttributes = $util.emptyArray; + + /** + * Creates a new BatchRemoveCatalogAttributesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} BatchRemoveCatalogAttributesResponse instance + */ + BatchRemoveCatalogAttributesResponse.create = function create(properties) { + return new BatchRemoveCatalogAttributesResponse(properties); + }; + + /** + * Encodes the specified BatchRemoveCatalogAttributesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse} message BatchRemoveCatalogAttributesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRemoveCatalogAttributesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deletedCatalogAttributes != null && message.deletedCatalogAttributes.length) + for (var i = 0; i < message.deletedCatalogAttributes.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.deletedCatalogAttributes[i]); + if (message.resetCatalogAttributes != null && message.resetCatalogAttributes.length) + for (var i = 0; i < message.resetCatalogAttributes.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.resetCatalogAttributes[i]); + return writer; + }; + + /** + * Encodes the specified BatchRemoveCatalogAttributesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse} message BatchRemoveCatalogAttributesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BatchRemoveCatalogAttributesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BatchRemoveCatalogAttributesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} BatchRemoveCatalogAttributesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRemoveCatalogAttributesResponse.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.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.deletedCatalogAttributes && message.deletedCatalogAttributes.length)) + message.deletedCatalogAttributes = []; + message.deletedCatalogAttributes.push(reader.string()); + break; + } + case 2: { + if (!(message.resetCatalogAttributes && message.resetCatalogAttributes.length)) + message.resetCatalogAttributes = []; + message.resetCatalogAttributes.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BatchRemoveCatalogAttributesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} BatchRemoveCatalogAttributesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BatchRemoveCatalogAttributesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BatchRemoveCatalogAttributesResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BatchRemoveCatalogAttributesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deletedCatalogAttributes != null && message.hasOwnProperty("deletedCatalogAttributes")) { + if (!Array.isArray(message.deletedCatalogAttributes)) + return "deletedCatalogAttributes: array expected"; + for (var i = 0; i < message.deletedCatalogAttributes.length; ++i) + if (!$util.isString(message.deletedCatalogAttributes[i])) + return "deletedCatalogAttributes: string[] expected"; + } + if (message.resetCatalogAttributes != null && message.hasOwnProperty("resetCatalogAttributes")) { + if (!Array.isArray(message.resetCatalogAttributes)) + return "resetCatalogAttributes: array expected"; + for (var i = 0; i < message.resetCatalogAttributes.length; ++i) + if (!$util.isString(message.resetCatalogAttributes[i])) + return "resetCatalogAttributes: string[] expected"; + } + return null; + }; + + /** + * Creates a BatchRemoveCatalogAttributesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} BatchRemoveCatalogAttributesResponse + */ + BatchRemoveCatalogAttributesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse(); + if (object.deletedCatalogAttributes) { + if (!Array.isArray(object.deletedCatalogAttributes)) + throw TypeError(".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.deletedCatalogAttributes: array expected"); + message.deletedCatalogAttributes = []; + for (var i = 0; i < object.deletedCatalogAttributes.length; ++i) + message.deletedCatalogAttributes[i] = String(object.deletedCatalogAttributes[i]); + } + if (object.resetCatalogAttributes) { + if (!Array.isArray(object.resetCatalogAttributes)) + throw TypeError(".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse.resetCatalogAttributes: array expected"); + message.resetCatalogAttributes = []; + for (var i = 0; i < object.resetCatalogAttributes.length; ++i) + message.resetCatalogAttributes[i] = String(object.resetCatalogAttributes[i]); + } + return message; + }; + + /** + * Creates a plain object from a BatchRemoveCatalogAttributesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse} message BatchRemoveCatalogAttributesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BatchRemoveCatalogAttributesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.deletedCatalogAttributes = []; + object.resetCatalogAttributes = []; + } + if (message.deletedCatalogAttributes && message.deletedCatalogAttributes.length) { + object.deletedCatalogAttributes = []; + for (var j = 0; j < message.deletedCatalogAttributes.length; ++j) + object.deletedCatalogAttributes[j] = message.deletedCatalogAttributes[j]; + } + if (message.resetCatalogAttributes && message.resetCatalogAttributes.length) { + object.resetCatalogAttributes = []; + for (var j = 0; j < message.resetCatalogAttributes.length; ++j) + object.resetCatalogAttributes[j] = message.resetCatalogAttributes[j]; + } + return object; + }; + + /** + * Converts this BatchRemoveCatalogAttributesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @instance + * @returns {Object.} JSON object + */ + BatchRemoveCatalogAttributesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BatchRemoveCatalogAttributesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BatchRemoveCatalogAttributesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse"; + }; + + return BatchRemoveCatalogAttributesResponse; + })(); + + v2beta.ReplaceCatalogAttributeRequest = (function() { + + /** + * Properties of a ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @interface IReplaceCatalogAttributeRequest + * @property {string|null} [attributesConfig] ReplaceCatalogAttributeRequest attributesConfig + * @property {google.cloud.retail.v2beta.ICatalogAttribute|null} [catalogAttribute] ReplaceCatalogAttributeRequest catalogAttribute + * @property {google.protobuf.IFieldMask|null} [updateMask] ReplaceCatalogAttributeRequest updateMask + */ + + /** + * Constructs a new ReplaceCatalogAttributeRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ReplaceCatalogAttributeRequest. + * @implements IReplaceCatalogAttributeRequest + * @constructor + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest=} [properties] Properties to set + */ + function ReplaceCatalogAttributeRequest(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]]; + } + + /** + * ReplaceCatalogAttributeRequest attributesConfig. + * @member {string} attributesConfig + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.attributesConfig = ""; + + /** + * ReplaceCatalogAttributeRequest catalogAttribute. + * @member {google.cloud.retail.v2beta.ICatalogAttribute|null|undefined} catalogAttribute + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.catalogAttribute = null; + + /** + * ReplaceCatalogAttributeRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @instance + */ + ReplaceCatalogAttributeRequest.prototype.updateMask = null; + + /** + * Creates a new ReplaceCatalogAttributeRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest instance + */ + ReplaceCatalogAttributeRequest.create = function create(properties) { + return new ReplaceCatalogAttributeRequest(properties); + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.attributesConfig != null && Object.hasOwnProperty.call(message, "attributesConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.attributesConfig); + if (message.catalogAttribute != null && Object.hasOwnProperty.call(message, "catalogAttribute")) + $root.google.cloud.retail.v2beta.CatalogAttribute.encode(message.catalogAttribute, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReplaceCatalogAttributeRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReplaceCatalogAttributeRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.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.cloud.retail.v2beta.ReplaceCatalogAttributeRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.attributesConfig = reader.string(); + break; + } + case 2: { + message.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.decode(reader, reader.uint32()); + break; + } + case 3: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReplaceCatalogAttributeRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReplaceCatalogAttributeRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReplaceCatalogAttributeRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReplaceCatalogAttributeRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + if (!$util.isString(message.attributesConfig)) + return "attributesConfig: string expected"; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) { + var error = $root.google.cloud.retail.v2beta.CatalogAttribute.verify(message.catalogAttribute); + if (error) + return "catalogAttribute." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates a ReplaceCatalogAttributeRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest} ReplaceCatalogAttributeRequest + */ + ReplaceCatalogAttributeRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest(); + if (object.attributesConfig != null) + message.attributesConfig = String(object.attributesConfig); + if (object.catalogAttribute != null) { + if (typeof object.catalogAttribute !== "object") + throw TypeError(".google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.catalogAttribute: object expected"); + message.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.fromObject(object.catalogAttribute); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from a ReplaceCatalogAttributeRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest} message ReplaceCatalogAttributeRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReplaceCatalogAttributeRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.attributesConfig = ""; + object.catalogAttribute = null; + object.updateMask = null; + } + if (message.attributesConfig != null && message.hasOwnProperty("attributesConfig")) + object.attributesConfig = message.attributesConfig; + if (message.catalogAttribute != null && message.hasOwnProperty("catalogAttribute")) + object.catalogAttribute = $root.google.cloud.retail.v2beta.CatalogAttribute.toObject(message.catalogAttribute, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this ReplaceCatalogAttributeRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @instance + * @returns {Object.} JSON object + */ + ReplaceCatalogAttributeRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReplaceCatalogAttributeRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReplaceCatalogAttributeRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest"; + }; + + return ReplaceCatalogAttributeRequest; + })(); + + v2beta.CompletionService = (function() { + + /** + * Constructs a new CompletionService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompletionService + * @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 CompletionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (CompletionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = CompletionService; + + /** + * Creates new CompletionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.CompletionService + * @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 {CompletionService} RPC service. Useful where requests and/or responses are streamed. + */ + CompletionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CompletionService|completeQuery}. + * @memberof google.cloud.retail.v2beta.CompletionService + * @typedef CompleteQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.CompleteQueryResponse} [response] CompleteQueryResponse + */ + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2beta.CompletionService + * @instance + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @param {google.cloud.retail.v2beta.CompletionService.CompleteQueryCallback} callback Node-style callback called with the error, if any, and CompleteQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.completeQuery = function completeQuery(request, callback) { + return this.rpcCall(completeQuery, $root.google.cloud.retail.v2beta.CompleteQueryRequest, $root.google.cloud.retail.v2beta.CompleteQueryResponse, request, callback); + }, "name", { value: "CompleteQuery" }); + + /** + * Calls CompleteQuery. + * @function completeQuery + * @memberof google.cloud.retail.v2beta.CompletionService + * @instance + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest} request CompleteQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.CompletionService|importCompletionData}. + * @memberof google.cloud.retail.v2beta.CompletionService + * @typedef ImportCompletionDataCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2beta.CompletionService + * @instance + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @param {google.cloud.retail.v2beta.CompletionService.ImportCompletionDataCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CompletionService.prototype.importCompletionData = function importCompletionData(request, callback) { + return this.rpcCall(importCompletionData, $root.google.cloud.retail.v2beta.ImportCompletionDataRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportCompletionData" }); + + /** + * Calls ImportCompletionData. + * @function importCompletionData + * @memberof google.cloud.retail.v2beta.CompletionService + * @instance + * @param {google.cloud.retail.v2beta.IImportCompletionDataRequest} request ImportCompletionDataRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return CompletionService; + })(); + + v2beta.CompleteQueryRequest = (function() { + + /** + * Properties of a CompleteQueryRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICompleteQueryRequest + * @property {string|null} [catalog] CompleteQueryRequest catalog + * @property {string|null} [query] CompleteQueryRequest query + * @property {string|null} [visitorId] CompleteQueryRequest visitorId + * @property {Array.|null} [languageCodes] CompleteQueryRequest languageCodes + * @property {string|null} [deviceType] CompleteQueryRequest deviceType + * @property {string|null} [dataset] CompleteQueryRequest dataset + * @property {number|null} [maxSuggestions] CompleteQueryRequest maxSuggestions + */ + + /** + * Constructs a new CompleteQueryRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompleteQueryRequest. + * @implements ICompleteQueryRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest=} [properties] Properties to set + */ + function CompleteQueryRequest(properties) { + this.languageCodes = []; + 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]]; + } + + /** + * CompleteQueryRequest catalog. + * @member {string} catalog + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.catalog = ""; + + /** + * CompleteQueryRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.query = ""; + + /** + * CompleteQueryRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.visitorId = ""; + + /** + * CompleteQueryRequest languageCodes. + * @member {Array.} languageCodes + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.languageCodes = $util.emptyArray; + + /** + * CompleteQueryRequest deviceType. + * @member {string} deviceType + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.deviceType = ""; + + /** + * CompleteQueryRequest dataset. + * @member {string} dataset + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.dataset = ""; + + /** + * CompleteQueryRequest maxSuggestions. + * @member {number} maxSuggestions + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + */ + CompleteQueryRequest.prototype.maxSuggestions = 0; + + /** + * Creates a new CompleteQueryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompleteQueryRequest} CompleteQueryRequest instance + */ + CompleteQueryRequest.create = function create(properties) { + return new CompleteQueryRequest(properties); + }; + + /** + * Encodes the specified CompleteQueryRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.catalog != null && Object.hasOwnProperty.call(message, "catalog")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.catalog); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.query); + if (message.languageCodes != null && message.languageCodes.length) + for (var i = 0; i < message.languageCodes.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.languageCodes[i]); + if (message.deviceType != null && Object.hasOwnProperty.call(message, "deviceType")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.deviceType); + if (message.maxSuggestions != null && Object.hasOwnProperty.call(message, "maxSuggestions")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.maxSuggestions); + if (message.dataset != null && Object.hasOwnProperty.call(message, "dataset")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.dataset); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.visitorId); + return writer; + }; + + /** + * Encodes the specified CompleteQueryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryRequest} message CompleteQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.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.cloud.retail.v2beta.CompleteQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.catalog = reader.string(); + break; + } + case 2: { + message.query = reader.string(); + break; + } + case 7: { + message.visitorId = reader.string(); + break; + } + case 3: { + if (!(message.languageCodes && message.languageCodes.length)) + message.languageCodes = []; + message.languageCodes.push(reader.string()); + break; + } + case 4: { + message.deviceType = reader.string(); + break; + } + case 6: { + message.dataset = reader.string(); + break; + } + case 5: { + message.maxSuggestions = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompleteQueryRequest} CompleteQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.catalog != null && message.hasOwnProperty("catalog")) + if (!$util.isString(message.catalog)) + return "catalog: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.languageCodes != null && message.hasOwnProperty("languageCodes")) { + if (!Array.isArray(message.languageCodes)) + return "languageCodes: array expected"; + for (var i = 0; i < message.languageCodes.length; ++i) + if (!$util.isString(message.languageCodes[i])) + return "languageCodes: string[] expected"; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + if (!$util.isString(message.deviceType)) + return "deviceType: string expected"; + if (message.dataset != null && message.hasOwnProperty("dataset")) + if (!$util.isString(message.dataset)) + return "dataset: string expected"; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + if (!$util.isInteger(message.maxSuggestions)) + return "maxSuggestions: integer expected"; + return null; + }; + + /** + * Creates a CompleteQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompleteQueryRequest} CompleteQueryRequest + */ + CompleteQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompleteQueryRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CompleteQueryRequest(); + if (object.catalog != null) + message.catalog = String(object.catalog); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.languageCodes) { + if (!Array.isArray(object.languageCodes)) + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryRequest.languageCodes: array expected"); + message.languageCodes = []; + for (var i = 0; i < object.languageCodes.length; ++i) + message.languageCodes[i] = String(object.languageCodes[i]); + } + if (object.deviceType != null) + message.deviceType = String(object.deviceType); + if (object.dataset != null) + message.dataset = String(object.dataset); + if (object.maxSuggestions != null) + message.maxSuggestions = object.maxSuggestions | 0; + return message; + }; + + /** + * Creates a plain object from a CompleteQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryRequest} message CompleteQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.languageCodes = []; + if (options.defaults) { + object.catalog = ""; + object.query = ""; + object.deviceType = ""; + object.maxSuggestions = 0; + object.dataset = ""; + object.visitorId = ""; + } + if (message.catalog != null && message.hasOwnProperty("catalog")) + object.catalog = message.catalog; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.languageCodes && message.languageCodes.length) { + object.languageCodes = []; + for (var j = 0; j < message.languageCodes.length; ++j) + object.languageCodes[j] = message.languageCodes[j]; + } + if (message.deviceType != null && message.hasOwnProperty("deviceType")) + object.deviceType = message.deviceType; + if (message.maxSuggestions != null && message.hasOwnProperty("maxSuggestions")) + object.maxSuggestions = message.maxSuggestions; + if (message.dataset != null && message.hasOwnProperty("dataset")) + object.dataset = message.dataset; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + return object; + }; + + /** + * Converts this CompleteQueryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompleteQueryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompleteQueryRequest"; + }; + + return CompleteQueryRequest; + })(); + + v2beta.CompleteQueryResponse = (function() { + + /** + * Properties of a CompleteQueryResponse. + * @memberof google.cloud.retail.v2beta + * @interface ICompleteQueryResponse + * @property {Array.|null} [completionResults] CompleteQueryResponse completionResults + * @property {string|null} [attributionToken] CompleteQueryResponse attributionToken + * @property {Array.|null} [recentSearchResults] CompleteQueryResponse recentSearchResults + */ + + /** + * Constructs a new CompleteQueryResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CompleteQueryResponse. + * @implements ICompleteQueryResponse + * @constructor + * @param {google.cloud.retail.v2beta.ICompleteQueryResponse=} [properties] Properties to set + */ + function CompleteQueryResponse(properties) { + this.completionResults = []; + this.recentSearchResults = []; + 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]]; + } + + /** + * CompleteQueryResponse completionResults. + * @member {Array.} completionResults + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.completionResults = $util.emptyArray; + + /** + * CompleteQueryResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.attributionToken = ""; + + /** + * CompleteQueryResponse recentSearchResults. + * @member {Array.} recentSearchResults + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @instance + */ + CompleteQueryResponse.prototype.recentSearchResults = $util.emptyArray; + + /** + * Creates a new CompleteQueryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse} CompleteQueryResponse instance + */ + CompleteQueryResponse.create = function create(properties) { + return new CompleteQueryResponse(properties); + }; + + /** + * Encodes the specified CompleteQueryResponse message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.completionResults != null && message.completionResults.length) + for (var i = 0; i < message.completionResults.length; ++i) + $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.encode(message.completionResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.recentSearchResults != null && message.recentSearchResults.length) + for (var i = 0; i < message.recentSearchResults.length; ++i) + $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.encode(message.recentSearchResults[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompleteQueryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2beta.ICompleteQueryResponse} message CompleteQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompleteQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.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.cloud.retail.v2beta.CompleteQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.completionResults && message.completionResults.length)) + message.completionResults = []; + message.completionResults.push($root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.recentSearchResults && message.recentSearchResults.length)) + message.recentSearchResults = []; + message.recentSearchResults.push($root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompleteQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse} CompleteQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompleteQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompleteQueryResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompleteQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.completionResults != null && message.hasOwnProperty("completionResults")) { + if (!Array.isArray(message.completionResults)) + return "completionResults: array expected"; + for (var i = 0; i < message.completionResults.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.verify(message.completionResults[i]); + if (error) + return "completionResults." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.recentSearchResults != null && message.hasOwnProperty("recentSearchResults")) { + if (!Array.isArray(message.recentSearchResults)) + return "recentSearchResults: array expected"; + for (var i = 0; i < message.recentSearchResults.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.verify(message.recentSearchResults[i]); + if (error) + return "recentSearchResults." + error; + } + } + return null; + }; + + /** + * Creates a CompleteQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse} CompleteQueryResponse + */ + CompleteQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompleteQueryResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.CompleteQueryResponse(); + if (object.completionResults) { + if (!Array.isArray(object.completionResults)) + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.completionResults: array expected"); + message.completionResults = []; + for (var i = 0; i < object.completionResults.length; ++i) { + if (typeof object.completionResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.completionResults: object expected"); + message.completionResults[i] = $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.fromObject(object.completionResults[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.recentSearchResults) { + if (!Array.isArray(object.recentSearchResults)) + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.recentSearchResults: array expected"); + message.recentSearchResults = []; + for (var i = 0; i < object.recentSearchResults.length; ++i) { + if (typeof object.recentSearchResults[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.recentSearchResults: object expected"); + message.recentSearchResults[i] = $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.fromObject(object.recentSearchResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompleteQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse} message CompleteQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompleteQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.completionResults = []; + object.recentSearchResults = []; + } + if (options.defaults) + object.attributionToken = ""; + if (message.completionResults && message.completionResults.length) { + object.completionResults = []; + for (var j = 0; j < message.completionResults.length; ++j) + object.completionResults[j] = $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.toObject(message.completionResults[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.recentSearchResults && message.recentSearchResults.length) { + object.recentSearchResults = []; + for (var j = 0; j < message.recentSearchResults.length; ++j) + object.recentSearchResults[j] = $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.toObject(message.recentSearchResults[j], options); + } + return object; + }; + + /** + * Converts this CompleteQueryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @instance + * @returns {Object.} JSON object + */ + CompleteQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompleteQueryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompleteQueryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompleteQueryResponse"; + }; + + CompleteQueryResponse.CompletionResult = (function() { + + /** + * Properties of a CompletionResult. + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @interface ICompletionResult + * @property {string|null} [suggestion] CompletionResult suggestion + * @property {Object.|null} [attributes] CompletionResult attributes + */ + + /** + * Constructs a new CompletionResult. + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @classdesc Represents a CompletionResult. + * @implements ICompletionResult + * @constructor + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + */ + function CompletionResult(properties) { + this.attributes = {}; + 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]]; + } + + /** + * CompletionResult suggestion. + * @member {string} suggestion + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.suggestion = ""; + + /** + * CompletionResult attributes. + * @member {Object.} attributes + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @instance + */ + CompletionResult.prototype.attributes = $util.emptyObject; + + /** + * Creates a new CompletionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult} CompletionResult instance + */ + CompletionResult.create = function create(properties) { + return new CompletionResult(properties); + }; + + /** + * Encodes the specified CompletionResult message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.suggestion != null && Object.hasOwnProperty.call(message, "suggestion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.suggestion); + if (message.attributes != null && Object.hasOwnProperty.call(message, "attributes")) + for (var keys = Object.keys(message.attributes), 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.cloud.retail.v2beta.CustomAttribute.encode(message.attributes[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified CompletionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.ICompletionResult} message CompletionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompletionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.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.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.suggestion = reader.string(); + break; + } + case 2: { + if (message.attributes === $util.emptyObject) + message.attributes = {}; + 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.cloud.retail.v2beta.CustomAttribute.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.attributes[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompletionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult} CompletionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompletionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompletionResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompletionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + if (!$util.isString(message.suggestion)) + return "suggestion: string expected"; + if (message.attributes != null && message.hasOwnProperty("attributes")) { + if (!$util.isObject(message.attributes)) + return "attributes: object expected"; + var key = Object.keys(message.attributes); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.retail.v2beta.CustomAttribute.verify(message.attributes[key[i]]); + if (error) + return "attributes." + error; + } + } + return null; + }; + + /** + * Creates a CompletionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult} CompletionResult + */ + CompletionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult) + return object; + var message = new $root.google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult(); + if (object.suggestion != null) + message.suggestion = String(object.suggestion); + if (object.attributes) { + if (typeof object.attributes !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes = {}; + for (var keys = Object.keys(object.attributes), i = 0; i < keys.length; ++i) { + if (typeof object.attributes[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.attributes: object expected"); + message.attributes[keys[i]] = $root.google.cloud.retail.v2beta.CustomAttribute.fromObject(object.attributes[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompletionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult} message CompletionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompletionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.attributes = {}; + if (options.defaults) + object.suggestion = ""; + if (message.suggestion != null && message.hasOwnProperty("suggestion")) + object.suggestion = message.suggestion; + var keys2; + if (message.attributes && (keys2 = Object.keys(message.attributes)).length) { + object.attributes = {}; + for (var j = 0; j < keys2.length; ++j) + object.attributes[keys2[j]] = $root.google.cloud.retail.v2beta.CustomAttribute.toObject(message.attributes[keys2[j]], options); + } + return object; + }; + + /** + * Converts this CompletionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @instance + * @returns {Object.} JSON object + */ + CompletionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompletionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompletionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult"; + }; + + return CompletionResult; + })(); + + CompleteQueryResponse.RecentSearchResult = (function() { + + /** + * Properties of a RecentSearchResult. + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @interface IRecentSearchResult + * @property {string|null} [recentSearch] RecentSearchResult recentSearch + */ + + /** + * Constructs a new RecentSearchResult. + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse + * @classdesc Represents a RecentSearchResult. + * @implements IRecentSearchResult + * @constructor + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + */ + function RecentSearchResult(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]]; + } + + /** + * RecentSearchResult recentSearch. + * @member {string} recentSearch + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @instance + */ + RecentSearchResult.prototype.recentSearch = ""; + + /** + * Creates a new RecentSearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult} RecentSearchResult instance + */ + RecentSearchResult.create = function create(properties) { + return new RecentSearchResult(properties); + }; + + /** + * Encodes the specified RecentSearchResult message. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.recentSearch != null && Object.hasOwnProperty.call(message, "recentSearch")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.recentSearch); + return writer; + }; + + /** + * Encodes the specified RecentSearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.IRecentSearchResult} message RecentSearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentSearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.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.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.recentSearch = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentSearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentSearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentSearchResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentSearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + if (!$util.isString(message.recentSearch)) + return "recentSearch: string expected"; + return null; + }; + + /** + * Creates a RecentSearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult} RecentSearchResult + */ + RecentSearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult) + return object; + var message = new $root.google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult(); + if (object.recentSearch != null) + message.recentSearch = String(object.recentSearch); + return message; + }; + + /** + * Creates a plain object from a RecentSearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult} message RecentSearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentSearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.recentSearch = ""; + if (message.recentSearch != null && message.hasOwnProperty("recentSearch")) + object.recentSearch = message.recentSearch; + return object; + }; + + /** + * Converts this RecentSearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @instance + * @returns {Object.} JSON object + */ + RecentSearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RecentSearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RecentSearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CompleteQueryResponse.RecentSearchResult"; + }; + + return RecentSearchResult; + })(); + + return CompleteQueryResponse; + })(); + + v2beta.Control = (function() { + + /** + * Properties of a Control. + * @memberof google.cloud.retail.v2beta + * @interface IControl + * @property {google.cloud.retail.v2beta.SearchRequest.IFacetSpec|null} [facetSpec] Control facetSpec + * @property {google.cloud.retail.v2beta.IRule|null} [rule] Control rule + * @property {string|null} [name] Control name + * @property {string|null} [displayName] Control displayName + * @property {Array.|null} [associatedServingConfigIds] Control associatedServingConfigIds + * @property {Array.|null} [solutionTypes] Control solutionTypes + * @property {Array.|null} [searchSolutionUseCase] Control searchSolutionUseCase + */ + + /** + * Constructs a new Control. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Control. + * @implements IControl + * @constructor + * @param {google.cloud.retail.v2beta.IControl=} [properties] Properties to set + */ + function Control(properties) { + this.associatedServingConfigIds = []; + this.solutionTypes = []; + this.searchSolutionUseCase = []; + 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]]; + } + + /** + * Control facetSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IFacetSpec|null|undefined} facetSpec + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.facetSpec = null; + + /** + * Control rule. + * @member {google.cloud.retail.v2beta.IRule|null|undefined} rule + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.rule = null; + + /** + * Control name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.name = ""; + + /** + * Control displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.displayName = ""; + + /** + * Control associatedServingConfigIds. + * @member {Array.} associatedServingConfigIds + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.associatedServingConfigIds = $util.emptyArray; + + /** + * Control solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.solutionTypes = $util.emptyArray; + + /** + * Control searchSolutionUseCase. + * @member {Array.} searchSolutionUseCase + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Control.prototype.searchSolutionUseCase = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Control control. + * @member {"facetSpec"|"rule"|undefined} control + * @memberof google.cloud.retail.v2beta.Control + * @instance + */ + Object.defineProperty(Control.prototype, "control", { + get: $util.oneOfGetter($oneOfFields = ["facetSpec", "rule"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Control instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {google.cloud.retail.v2beta.IControl=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Control} Control instance + */ + Control.create = function create(properties) { + return new Control(properties); + }; + + /** + * Encodes the specified Control message. Does not implicitly {@link google.cloud.retail.v2beta.Control.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {google.cloud.retail.v2beta.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.facetSpec != null && Object.hasOwnProperty.call(message, "facetSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.encode(message.facetSpec, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.rule != null && Object.hasOwnProperty.call(message, "rule")) + $root.google.cloud.retail.v2beta.Rule.encode(message.rule, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.associatedServingConfigIds != null && message.associatedServingConfigIds.length) + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.associatedServingConfigIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 6, wireType 2 =*/50).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + if (message.searchSolutionUseCase != null && message.searchSolutionUseCase.length) { + writer.uint32(/* id 7, wireType 2 =*/58).fork(); + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + writer.int32(message.searchSolutionUseCase[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Control message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Control.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {google.cloud.retail.v2beta.IControl} message Control message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Control.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Control message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.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.cloud.retail.v2beta.Control(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.facetSpec = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.decode(reader, reader.uint32()); + break; + } + case 4: { + message.rule = $root.google.cloud.retail.v2beta.Rule.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 5: { + if (!(message.associatedServingConfigIds && message.associatedServingConfigIds.length)) + message.associatedServingConfigIds = []; + message.associatedServingConfigIds.push(reader.string()); + break; + } + case 6: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + case 7: { + if (!(message.searchSolutionUseCase && message.searchSolutionUseCase.length)) + message.searchSolutionUseCase = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.searchSolutionUseCase.push(reader.int32()); + } else + message.searchSolutionUseCase.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Control message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Control} Control + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Control.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Control message. + * @function verify + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Control.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.facetSpec != null && message.hasOwnProperty("facetSpec")) { + properties.control = 1; + { + var error = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify(message.facetSpec); + if (error) + return "facetSpec." + error; + } + } + if (message.rule != null && message.hasOwnProperty("rule")) { + if (properties.control === 1) + return "control: multiple values"; + properties.control = 1; + { + var error = $root.google.cloud.retail.v2beta.Rule.verify(message.rule); + if (error) + return "rule." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.associatedServingConfigIds != null && message.hasOwnProperty("associatedServingConfigIds")) { + if (!Array.isArray(message.associatedServingConfigIds)) + return "associatedServingConfigIds: array expected"; + for (var i = 0; i < message.associatedServingConfigIds.length; ++i) + if (!$util.isString(message.associatedServingConfigIds[i])) + return "associatedServingConfigIds: string[] expected"; + } + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + if (message.searchSolutionUseCase != null && message.hasOwnProperty("searchSolutionUseCase")) { + if (!Array.isArray(message.searchSolutionUseCase)) + return "searchSolutionUseCase: array expected"; + for (var i = 0; i < message.searchSolutionUseCase.length; ++i) + switch (message.searchSolutionUseCase[i]) { + default: + return "searchSolutionUseCase: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a Control message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Control} Control + */ + Control.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Control) + return object; + var message = new $root.google.cloud.retail.v2beta.Control(); + if (object.facetSpec != null) { + if (typeof object.facetSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.Control.facetSpec: object expected"); + message.facetSpec = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.fromObject(object.facetSpec); + } + if (object.rule != null) { + if (typeof object.rule !== "object") + throw TypeError(".google.cloud.retail.v2beta.Control.rule: object expected"); + message.rule = $root.google.cloud.retail.v2beta.Rule.fromObject(object.rule); + } + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.associatedServingConfigIds) { + if (!Array.isArray(object.associatedServingConfigIds)) + throw TypeError(".google.cloud.retail.v2beta.Control.associatedServingConfigIds: array expected"); + message.associatedServingConfigIds = []; + for (var i = 0; i < object.associatedServingConfigIds.length; ++i) + message.associatedServingConfigIds[i] = String(object.associatedServingConfigIds[i]); + } + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2beta.Control.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + if (object.searchSolutionUseCase) { + if (!Array.isArray(object.searchSolutionUseCase)) + throw TypeError(".google.cloud.retail.v2beta.Control.searchSolutionUseCase: array expected"); + message.searchSolutionUseCase = []; + for (var i = 0; i < object.searchSolutionUseCase.length; ++i) + switch (object.searchSolutionUseCase[i]) { + default: + if (typeof object.searchSolutionUseCase[i] === "number") { + message.searchSolutionUseCase[i] = object.searchSolutionUseCase[i]; + break; + } + case "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": + case 0: + message.searchSolutionUseCase[i] = 0; + break; + case "SEARCH_SOLUTION_USE_CASE_SEARCH": + case 1: + message.searchSolutionUseCase[i] = 1; + break; + case "SEARCH_SOLUTION_USE_CASE_BROWSE": + case 2: + message.searchSolutionUseCase[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a Control message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {google.cloud.retail.v2beta.Control} message Control + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Control.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.associatedServingConfigIds = []; + object.solutionTypes = []; + object.searchSolutionUseCase = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.facetSpec != null && message.hasOwnProperty("facetSpec")) { + object.facetSpec = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.toObject(message.facetSpec, options); + if (options.oneofs) + object.control = "facetSpec"; + } + if (message.rule != null && message.hasOwnProperty("rule")) { + object.rule = $root.google.cloud.retail.v2beta.Rule.toObject(message.rule, options); + if (options.oneofs) + object.control = "rule"; + } + if (message.associatedServingConfigIds && message.associatedServingConfigIds.length) { + object.associatedServingConfigIds = []; + for (var j = 0; j < message.associatedServingConfigIds.length; ++j) + object.associatedServingConfigIds[j] = message.associatedServingConfigIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2beta.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2beta.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + if (message.searchSolutionUseCase && message.searchSolutionUseCase.length) { + object.searchSolutionUseCase = []; + for (var j = 0; j < message.searchSolutionUseCase.length; ++j) + object.searchSolutionUseCase[j] = options.enums === String ? $root.google.cloud.retail.v2beta.SearchSolutionUseCase[message.searchSolutionUseCase[j]] === undefined ? message.searchSolutionUseCase[j] : $root.google.cloud.retail.v2beta.SearchSolutionUseCase[message.searchSolutionUseCase[j]] : message.searchSolutionUseCase[j]; + } + return object; + }; + + /** + * Converts this Control to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Control + * @instance + * @returns {Object.} JSON object + */ + Control.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Control + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Control + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Control.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Control"; + }; + + return Control; + })(); + + v2beta.SearchService = (function() { + + /** + * Constructs a new SearchService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SearchService + * @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 SearchService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (SearchService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = SearchService; + + /** + * Creates new SearchService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.SearchService + * @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 {SearchService} RPC service. Useful where requests and/or responses are streamed. + */ + SearchService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.SearchService|search}. + * @memberof google.cloud.retail.v2beta.SearchService + * @typedef SearchCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.SearchResponse} [response] SearchResponse + */ + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2beta.SearchService + * @instance + * @param {google.cloud.retail.v2beta.ISearchRequest} request SearchRequest message or plain object + * @param {google.cloud.retail.v2beta.SearchService.SearchCallback} callback Node-style callback called with the error, if any, and SearchResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(SearchService.prototype.search = function search(request, callback) { + return this.rpcCall(search, $root.google.cloud.retail.v2beta.SearchRequest, $root.google.cloud.retail.v2beta.SearchResponse, request, callback); + }, "name", { value: "Search" }); + + /** + * Calls Search. + * @function search + * @memberof google.cloud.retail.v2beta.SearchService + * @instance + * @param {google.cloud.retail.v2beta.ISearchRequest} request SearchRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return SearchService; + })(); + + v2beta.SearchRequest = (function() { + + /** + * Properties of a SearchRequest. + * @memberof google.cloud.retail.v2beta + * @interface ISearchRequest + * @property {string|null} [placement] SearchRequest placement + * @property {string|null} [branch] SearchRequest branch + * @property {string|null} [query] SearchRequest query + * @property {string|null} [visitorId] SearchRequest visitorId + * @property {google.cloud.retail.v2beta.IUserInfo|null} [userInfo] SearchRequest userInfo + * @property {number|null} [pageSize] SearchRequest pageSize + * @property {string|null} [pageToken] SearchRequest pageToken + * @property {number|null} [offset] SearchRequest offset + * @property {string|null} [filter] SearchRequest filter + * @property {string|null} [canonicalFilter] SearchRequest canonicalFilter + * @property {string|null} [orderBy] SearchRequest orderBy + * @property {Array.|null} [facetSpecs] SearchRequest facetSpecs + * @property {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] SearchRequest dynamicFacetSpec + * @property {google.cloud.retail.v2beta.SearchRequest.IBoostSpec|null} [boostSpec] SearchRequest boostSpec + * @property {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec|null} [queryExpansionSpec] SearchRequest queryExpansionSpec + * @property {Array.|null} [variantRollupKeys] SearchRequest variantRollupKeys + * @property {Array.|null} [pageCategories] SearchRequest pageCategories + * @property {google.cloud.retail.v2beta.SearchRequest.SearchMode|null} [searchMode] SearchRequest searchMode + * @property {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] SearchRequest personalizationSpec + * @property {Object.|null} [labels] SearchRequest labels + * @property {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec|null} [spellCorrectionSpec] SearchRequest spellCorrectionSpec + */ + + /** + * Constructs a new SearchRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SearchRequest. + * @implements ISearchRequest + * @constructor + * @param {google.cloud.retail.v2beta.ISearchRequest=} [properties] Properties to set + */ + function SearchRequest(properties) { + this.facetSpecs = []; + this.variantRollupKeys = []; + this.pageCategories = []; + 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]]; + } + + /** + * SearchRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.placement = ""; + + /** + * SearchRequest branch. + * @member {string} branch + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.branch = ""; + + /** + * SearchRequest query. + * @member {string} query + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.query = ""; + + /** + * SearchRequest visitorId. + * @member {string} visitorId + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.visitorId = ""; + + /** + * SearchRequest userInfo. + * @member {google.cloud.retail.v2beta.IUserInfo|null|undefined} userInfo + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.userInfo = null; + + /** + * SearchRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.pageSize = 0; + + /** + * SearchRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.pageToken = ""; + + /** + * SearchRequest offset. + * @member {number} offset + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.offset = 0; + + /** + * SearchRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.filter = ""; + + /** + * SearchRequest canonicalFilter. + * @member {string} canonicalFilter + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.canonicalFilter = ""; + + /** + * SearchRequest orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.orderBy = ""; + + /** + * SearchRequest facetSpecs. + * @member {Array.} facetSpecs + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.facetSpecs = $util.emptyArray; + + /** + * SearchRequest dynamicFacetSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.dynamicFacetSpec = null; + + /** + * SearchRequest boostSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IBoostSpec|null|undefined} boostSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.boostSpec = null; + + /** + * SearchRequest queryExpansionSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec|null|undefined} queryExpansionSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.queryExpansionSpec = null; + + /** + * SearchRequest variantRollupKeys. + * @member {Array.} variantRollupKeys + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.variantRollupKeys = $util.emptyArray; + + /** + * SearchRequest pageCategories. + * @member {Array.} pageCategories + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.pageCategories = $util.emptyArray; + + /** + * SearchRequest searchMode. + * @member {google.cloud.retail.v2beta.SearchRequest.SearchMode} searchMode + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.searchMode = 0; + + /** + * SearchRequest personalizationSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null|undefined} personalizationSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.personalizationSpec = null; + + /** + * SearchRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.labels = $util.emptyObject; + + /** + * SearchRequest spellCorrectionSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec|null|undefined} spellCorrectionSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + SearchRequest.prototype.spellCorrectionSpec = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * SearchRequest _spellCorrectionSpec. + * @member {"spellCorrectionSpec"|undefined} _spellCorrectionSpec + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + */ + Object.defineProperty(SearchRequest.prototype, "_spellCorrectionSpec", { + get: $util.oneOfGetter($oneOfFields = ["spellCorrectionSpec"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new SearchRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {google.cloud.retail.v2beta.ISearchRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest} SearchRequest instance + */ + SearchRequest.create = function create(properties) { + return new SearchRequest(properties); + }; + + /** + * Encodes the specified SearchRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {google.cloud.retail.v2beta.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.branch != null && Object.hasOwnProperty.call(message, "branch")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.branch); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.query); + if (message.visitorId != null && Object.hasOwnProperty.call(message, "visitorId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.visitorId); + if (message.userInfo != null && Object.hasOwnProperty.call(message, "userInfo")) + $root.google.cloud.retail.v2beta.UserInfo.encode(message.userInfo, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.pageToken); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.offset); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.filter); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.orderBy); + if (message.facetSpecs != null && message.facetSpecs.length) + for (var i = 0; i < message.facetSpecs.length; ++i) + $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.encode(message.facetSpecs[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.boostSpec != null && Object.hasOwnProperty.call(message, "boostSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.encode(message.boostSpec, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + if (message.queryExpansionSpec != null && Object.hasOwnProperty.call(message, "queryExpansionSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.encode(message.queryExpansionSpec, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.variantRollupKeys != null && message.variantRollupKeys.length) + for (var i = 0; i < message.variantRollupKeys.length; ++i) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.variantRollupKeys[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.pageCategories != null && message.pageCategories.length) + for (var i = 0; i < message.pageCategories.length; ++i) + writer.uint32(/* id 23, wireType 2 =*/186).string(message.pageCategories[i]); + if (message.canonicalFilter != null && Object.hasOwnProperty.call(message, "canonicalFilter")) + writer.uint32(/* id 28, wireType 2 =*/226).string(message.canonicalFilter); + if (message.searchMode != null && Object.hasOwnProperty.call(message, "searchMode")) + writer.uint32(/* id 31, wireType 0 =*/248).int32(message.searchMode); + if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 32, wireType 2 =*/258).fork()).ldelim(); + 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 34, wireType 2 =*/274).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.spellCorrectionSpec != null && Object.hasOwnProperty.call(message, "spellCorrectionSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.encode(message.spellCorrectionSpec, writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {google.cloud.retail.v2beta.ISearchRequest} message SearchRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.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.cloud.retail.v2beta.SearchRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.branch = reader.string(); + break; + } + case 3: { + message.query = reader.string(); + break; + } + case 4: { + message.visitorId = reader.string(); + break; + } + case 5: { + message.userInfo = $root.google.cloud.retail.v2beta.UserInfo.decode(reader, reader.uint32()); + break; + } + case 7: { + message.pageSize = reader.int32(); + break; + } + case 8: { + message.pageToken = reader.string(); + break; + } + case 9: { + message.offset = reader.int32(); + break; + } + case 10: { + message.filter = reader.string(); + break; + } + case 28: { + message.canonicalFilter = reader.string(); + break; + } + case 11: { + message.orderBy = reader.string(); + break; + } + case 12: { + if (!(message.facetSpecs && message.facetSpecs.length)) + message.facetSpecs = []; + message.facetSpecs.push($root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.decode(reader, reader.uint32())); + break; + } + case 21: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 13: { + message.boostSpec = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.decode(reader, reader.uint32()); + break; + } + case 14: { + message.queryExpansionSpec = $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.decode(reader, reader.uint32()); + break; + } + case 17: { + if (!(message.variantRollupKeys && message.variantRollupKeys.length)) + message.variantRollupKeys = []; + message.variantRollupKeys.push(reader.string()); + break; + } + case 23: { + if (!(message.pageCategories && message.pageCategories.length)) + message.pageCategories = []; + message.pageCategories.push(reader.string()); + break; + } + case 31: { + message.searchMode = reader.int32(); + break; + } + case 32: { + message.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); + break; + } + case 34: { + 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 35: { + message.spellCorrectionSpec = $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest} SearchRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.branch != null && message.hasOwnProperty("branch")) + if (!$util.isString(message.branch)) + return "branch: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + if (!$util.isString(message.visitorId)) + return "visitorId: string expected"; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) { + var error = $root.google.cloud.retail.v2beta.UserInfo.verify(message.userInfo); + if (error) + return "userInfo." + error; + } + 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"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + if (!$util.isString(message.canonicalFilter)) + return "canonicalFilter: string expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.facetSpecs != null && message.hasOwnProperty("facetSpecs")) { + if (!Array.isArray(message.facetSpecs)) + return "facetSpecs: array expected"; + for (var i = 0; i < message.facetSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify(message.facetSpecs[i]); + if (error) + return "facetSpecs." + error; + } + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.verify(message.boostSpec); + if (error) + return "boostSpec." + error; + } + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.verify(message.queryExpansionSpec); + if (error) + return "queryExpansionSpec." + error; + } + if (message.variantRollupKeys != null && message.hasOwnProperty("variantRollupKeys")) { + if (!Array.isArray(message.variantRollupKeys)) + return "variantRollupKeys: array expected"; + for (var i = 0; i < message.variantRollupKeys.length; ++i) + if (!$util.isString(message.variantRollupKeys[i])) + return "variantRollupKeys: string[] expected"; + } + if (message.pageCategories != null && message.hasOwnProperty("pageCategories")) { + if (!Array.isArray(message.pageCategories)) + return "pageCategories: array expected"; + for (var i = 0; i < message.pageCategories.length; ++i) + if (!$util.isString(message.pageCategories[i])) + return "pageCategories: string[] expected"; + } + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + switch (message.searchMode) { + default: + return "searchMode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify(message.personalizationSpec); + if (error) + return "personalizationSpec." + error; + } + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + properties._spellCorrectionSpec = 1; + { + var error = $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.verify(message.spellCorrectionSpec); + if (error) + return "spellCorrectionSpec." + error; + } + } + return null; + }; + + /** + * Creates a SearchRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest} SearchRequest + */ + SearchRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.branch != null) + message.branch = String(object.branch); + if (object.query != null) + message.query = String(object.query); + if (object.visitorId != null) + message.visitorId = String(object.visitorId); + if (object.userInfo != null) { + if (typeof object.userInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.userInfo: object expected"); + message.userInfo = $root.google.cloud.retail.v2beta.UserInfo.fromObject(object.userInfo); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.offset != null) + message.offset = object.offset | 0; + if (object.filter != null) + message.filter = String(object.filter); + if (object.canonicalFilter != null) + message.canonicalFilter = String(object.canonicalFilter); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.facetSpecs) { + if (!Array.isArray(object.facetSpecs)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.facetSpecs: array expected"); + message.facetSpecs = []; + for (var i = 0; i < object.facetSpecs.length; ++i) { + if (typeof object.facetSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.facetSpecs: object expected"); + message.facetSpecs[i] = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.fromObject(object.facetSpecs[i]); + } + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostSpec != null) { + if (typeof object.boostSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.boostSpec: object expected"); + message.boostSpec = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.fromObject(object.boostSpec); + } + if (object.queryExpansionSpec != null) { + if (typeof object.queryExpansionSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.queryExpansionSpec: object expected"); + message.queryExpansionSpec = $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.fromObject(object.queryExpansionSpec); + } + if (object.variantRollupKeys) { + if (!Array.isArray(object.variantRollupKeys)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.variantRollupKeys: array expected"); + message.variantRollupKeys = []; + for (var i = 0; i < object.variantRollupKeys.length; ++i) + message.variantRollupKeys[i] = String(object.variantRollupKeys[i]); + } + if (object.pageCategories) { + if (!Array.isArray(object.pageCategories)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.pageCategories: array expected"); + message.pageCategories = []; + for (var i = 0; i < object.pageCategories.length; ++i) + message.pageCategories[i] = String(object.pageCategories[i]); + } + switch (object.searchMode) { + default: + if (typeof object.searchMode === "number") { + message.searchMode = object.searchMode; + break; + } + break; + case "SEARCH_MODE_UNSPECIFIED": + case 0: + message.searchMode = 0; + break; + case "PRODUCT_SEARCH_ONLY": + case 1: + message.searchMode = 1; + break; + case "FACETED_SEARCH_ONLY": + case 2: + message.searchMode = 2; + break; + } + if (object.personalizationSpec != null) { + if (typeof object.personalizationSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.personalizationSpec: object expected"); + message.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.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.spellCorrectionSpec != null) { + if (typeof object.spellCorrectionSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.spellCorrectionSpec: object expected"); + message.spellCorrectionSpec = $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.fromObject(object.spellCorrectionSpec); + } + return message; + }; + + /** + * Creates a plain object from a SearchRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {google.cloud.retail.v2beta.SearchRequest} message SearchRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetSpecs = []; + object.variantRollupKeys = []; + object.pageCategories = []; + } + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.placement = ""; + object.branch = ""; + object.query = ""; + object.visitorId = ""; + object.userInfo = null; + object.pageSize = 0; + object.pageToken = ""; + object.offset = 0; + object.filter = ""; + object.orderBy = ""; + object.boostSpec = null; + object.queryExpansionSpec = null; + object.dynamicFacetSpec = null; + object.canonicalFilter = ""; + object.searchMode = options.enums === String ? "SEARCH_MODE_UNSPECIFIED" : 0; + object.personalizationSpec = null; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.branch != null && message.hasOwnProperty("branch")) + object.branch = message.branch; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.visitorId != null && message.hasOwnProperty("visitorId")) + object.visitorId = message.visitorId; + if (message.userInfo != null && message.hasOwnProperty("userInfo")) + object.userInfo = $root.google.cloud.retail.v2beta.UserInfo.toObject(message.userInfo, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.facetSpecs && message.facetSpecs.length) { + object.facetSpecs = []; + for (var j = 0; j < message.facetSpecs.length; ++j) + object.facetSpecs[j] = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.toObject(message.facetSpecs[j], options); + } + if (message.boostSpec != null && message.hasOwnProperty("boostSpec")) + object.boostSpec = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.toObject(message.boostSpec, options); + if (message.queryExpansionSpec != null && message.hasOwnProperty("queryExpansionSpec")) + object.queryExpansionSpec = $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.toObject(message.queryExpansionSpec, options); + if (message.variantRollupKeys && message.variantRollupKeys.length) { + object.variantRollupKeys = []; + for (var j = 0; j < message.variantRollupKeys.length; ++j) + object.variantRollupKeys[j] = message.variantRollupKeys[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.pageCategories && message.pageCategories.length) { + object.pageCategories = []; + for (var j = 0; j < message.pageCategories.length; ++j) + object.pageCategories[j] = message.pageCategories[j]; + } + if (message.canonicalFilter != null && message.hasOwnProperty("canonicalFilter")) + object.canonicalFilter = message.canonicalFilter; + if (message.searchMode != null && message.hasOwnProperty("searchMode")) + object.searchMode = options.enums === String ? $root.google.cloud.retail.v2beta.SearchRequest.SearchMode[message.searchMode] === undefined ? message.searchMode : $root.google.cloud.retail.v2beta.SearchRequest.SearchMode[message.searchMode] : message.searchMode; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) + object.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + 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.spellCorrectionSpec != null && message.hasOwnProperty("spellCorrectionSpec")) { + object.spellCorrectionSpec = $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.toObject(message.spellCorrectionSpec, options); + if (options.oneofs) + object._spellCorrectionSpec = "spellCorrectionSpec"; + } + return object; + }; + + /** + * Converts this SearchRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest + * @instance + * @returns {Object.} JSON object + */ + SearchRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest"; + }; + + SearchRequest.FacetSpec = (function() { + + /** + * Properties of a FacetSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface IFacetSpec + * @property {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey|null} [facetKey] FacetSpec facetKey + * @property {number|null} [limit] FacetSpec limit + * @property {Array.|null} [excludedFilterKeys] FacetSpec excludedFilterKeys + * @property {boolean|null} [enableDynamicPosition] FacetSpec enableDynamicPosition + */ + + /** + * Constructs a new FacetSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a FacetSpec. + * @implements IFacetSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.IFacetSpec=} [properties] Properties to set + */ + function FacetSpec(properties) { + this.excludedFilterKeys = []; + 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]]; + } + + /** + * FacetSpec facetKey. + * @member {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey|null|undefined} facetKey + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.facetKey = null; + + /** + * FacetSpec limit. + * @member {number} limit + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.limit = 0; + + /** + * FacetSpec excludedFilterKeys. + * @member {Array.} excludedFilterKeys + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.excludedFilterKeys = $util.emptyArray; + + /** + * FacetSpec enableDynamicPosition. + * @member {boolean} enableDynamicPosition + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @instance + */ + FacetSpec.prototype.enableDynamicPosition = false; + + /** + * Creates a new FacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec} FacetSpec instance + */ + FacetSpec.create = function create(properties) { + return new FacetSpec(properties); + }; + + /** + * Encodes the specified FacetSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.facetKey != null && Object.hasOwnProperty.call(message, "facetKey")) + $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.encode(message.facetKey, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.limit); + if (message.excludedFilterKeys != null && message.excludedFilterKeys.length) + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.excludedFilterKeys[i]); + if (message.enableDynamicPosition != null && Object.hasOwnProperty.call(message, "enableDynamicPosition")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.enableDynamicPosition); + return writer; + }; + + /** + * Encodes the specified FacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IFacetSpec} message FacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.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.cloud.retail.v2beta.SearchRequest.FacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.facetKey = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.decode(reader, reader.uint32()); + break; + } + case 2: { + message.limit = reader.int32(); + break; + } + case 3: { + if (!(message.excludedFilterKeys && message.excludedFilterKeys.length)) + message.excludedFilterKeys = []; + message.excludedFilterKeys.push(reader.string()); + break; + } + case 4: { + message.enableDynamicPosition = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec} FacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.facetKey != null && message.hasOwnProperty("facetKey")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.verify(message.facetKey); + if (error) + return "facetKey." + error; + } + if (message.limit != null && message.hasOwnProperty("limit")) + if (!$util.isInteger(message.limit)) + return "limit: integer expected"; + if (message.excludedFilterKeys != null && message.hasOwnProperty("excludedFilterKeys")) { + if (!Array.isArray(message.excludedFilterKeys)) + return "excludedFilterKeys: array expected"; + for (var i = 0; i < message.excludedFilterKeys.length; ++i) + if (!$util.isString(message.excludedFilterKeys[i])) + return "excludedFilterKeys: string[] expected"; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + if (typeof message.enableDynamicPosition !== "boolean") + return "enableDynamicPosition: boolean expected"; + return null; + }; + + /** + * Creates a FacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec} FacetSpec + */ + FacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec(); + if (object.facetKey != null) { + if (typeof object.facetKey !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.facetKey: object expected"); + message.facetKey = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.fromObject(object.facetKey); + } + if (object.limit != null) + message.limit = object.limit | 0; + if (object.excludedFilterKeys) { + if (!Array.isArray(object.excludedFilterKeys)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.excludedFilterKeys: array expected"); + message.excludedFilterKeys = []; + for (var i = 0; i < object.excludedFilterKeys.length; ++i) + message.excludedFilterKeys[i] = String(object.excludedFilterKeys[i]); + } + if (object.enableDynamicPosition != null) + message.enableDynamicPosition = Boolean(object.enableDynamicPosition); + return message; + }; + + /** + * Creates a plain object from a FacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec} message FacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.excludedFilterKeys = []; + if (options.defaults) { + object.facetKey = null; + object.limit = 0; + object.enableDynamicPosition = false; + } + if (message.facetKey != null && message.hasOwnProperty("facetKey")) + object.facetKey = $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.toObject(message.facetKey, options); + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = message.limit; + if (message.excludedFilterKeys && message.excludedFilterKeys.length) { + object.excludedFilterKeys = []; + for (var j = 0; j < message.excludedFilterKeys.length; ++j) + object.excludedFilterKeys[j] = message.excludedFilterKeys[j]; + } + if (message.enableDynamicPosition != null && message.hasOwnProperty("enableDynamicPosition")) + object.enableDynamicPosition = message.enableDynamicPosition; + return object; + }; + + /** + * Converts this FacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @instance + * @returns {Object.} JSON object + */ + FacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.FacetSpec"; + }; + + FacetSpec.FacetKey = (function() { + + /** + * Properties of a FacetKey. + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @interface IFacetKey + * @property {string|null} [key] FacetKey key + * @property {Array.|null} [intervals] FacetKey intervals + * @property {Array.|null} [restrictedValues] FacetKey restrictedValues + * @property {Array.|null} [prefixes] FacetKey prefixes + * @property {Array.|null} [contains] FacetKey contains + * @property {boolean|null} [caseInsensitive] FacetKey caseInsensitive + * @property {string|null} [orderBy] FacetKey orderBy + * @property {string|null} [query] FacetKey query + * @property {boolean|null} [returnMinMax] FacetKey returnMinMax + */ + + /** + * Constructs a new FacetKey. + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec + * @classdesc Represents a FacetKey. + * @implements IFacetKey + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + */ + function FacetKey(properties) { + this.intervals = []; + this.restrictedValues = []; + this.prefixes = []; + this.contains = []; + 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]]; + } + + /** + * FacetKey key. + * @member {string} key + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.key = ""; + + /** + * FacetKey intervals. + * @member {Array.} intervals + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.intervals = $util.emptyArray; + + /** + * FacetKey restrictedValues. + * @member {Array.} restrictedValues + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.restrictedValues = $util.emptyArray; + + /** + * FacetKey prefixes. + * @member {Array.} prefixes + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.prefixes = $util.emptyArray; + + /** + * FacetKey contains. + * @member {Array.} contains + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.contains = $util.emptyArray; + + /** + * FacetKey caseInsensitive. + * @member {boolean} caseInsensitive + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.caseInsensitive = false; + + /** + * FacetKey orderBy. + * @member {string} orderBy + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.orderBy = ""; + + /** + * FacetKey query. + * @member {string} query + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.query = ""; + + /** + * FacetKey returnMinMax. + * @member {boolean} returnMinMax + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + */ + FacetKey.prototype.returnMinMax = false; + + /** + * Creates a new FacetKey instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey} FacetKey instance + */ + FacetKey.create = function create(properties) { + return new FacetKey(properties); + }; + + /** + * Encodes the specified FacetKey message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.intervals != null && message.intervals.length) + for (var i = 0; i < message.intervals.length; ++i) + $root.google.cloud.retail.v2beta.Interval.encode(message.intervals[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.restrictedValues != null && message.restrictedValues.length) + for (var i = 0; i < message.restrictedValues.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.restrictedValues[i]); + if (message.orderBy != null && Object.hasOwnProperty.call(message, "orderBy")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.orderBy); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.query); + if (message.prefixes != null && message.prefixes.length) + for (var i = 0; i < message.prefixes.length; ++i) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.prefixes[i]); + if (message.contains != null && message.contains.length) + for (var i = 0; i < message.contains.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.contains[i]); + if (message.caseInsensitive != null && Object.hasOwnProperty.call(message, "caseInsensitive")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.caseInsensitive); + if (message.returnMinMax != null && Object.hasOwnProperty.call(message, "returnMinMax")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.returnMinMax); + return writer; + }; + + /** + * Encodes the specified FacetKey message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec.IFacetKey} message FacetKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.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.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.intervals && message.intervals.length)) + message.intervals = []; + message.intervals.push($root.google.cloud.retail.v2beta.Interval.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.restrictedValues && message.restrictedValues.length)) + message.restrictedValues = []; + message.restrictedValues.push(reader.string()); + break; + } + case 8: { + if (!(message.prefixes && message.prefixes.length)) + message.prefixes = []; + message.prefixes.push(reader.string()); + break; + } + case 9: { + if (!(message.contains && message.contains.length)) + message.contains = []; + message.contains.push(reader.string()); + break; + } + case 10: { + message.caseInsensitive = reader.bool(); + break; + } + case 4: { + message.orderBy = reader.string(); + break; + } + case 5: { + message.query = reader.string(); + break; + } + case 11: { + message.returnMinMax = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey} FacetKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetKey message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string expected"; + if (message.intervals != null && message.hasOwnProperty("intervals")) { + if (!Array.isArray(message.intervals)) + return "intervals: array expected"; + for (var i = 0; i < message.intervals.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Interval.verify(message.intervals[i]); + if (error) + return "intervals." + error; + } + } + if (message.restrictedValues != null && message.hasOwnProperty("restrictedValues")) { + if (!Array.isArray(message.restrictedValues)) + return "restrictedValues: array expected"; + for (var i = 0; i < message.restrictedValues.length; ++i) + if (!$util.isString(message.restrictedValues[i])) + return "restrictedValues: string[] expected"; + } + if (message.prefixes != null && message.hasOwnProperty("prefixes")) { + if (!Array.isArray(message.prefixes)) + return "prefixes: array expected"; + for (var i = 0; i < message.prefixes.length; ++i) + if (!$util.isString(message.prefixes[i])) + return "prefixes: string[] expected"; + } + if (message.contains != null && message.hasOwnProperty("contains")) { + if (!Array.isArray(message.contains)) + return "contains: array expected"; + for (var i = 0; i < message.contains.length; ++i) + if (!$util.isString(message.contains[i])) + return "contains: string[] expected"; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + if (typeof message.caseInsensitive !== "boolean") + return "caseInsensitive: boolean expected"; + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + if (!$util.isString(message.orderBy)) + return "orderBy: string expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + if (typeof message.returnMinMax !== "boolean") + return "returnMinMax: boolean expected"; + return null; + }; + + /** + * Creates a FacetKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey} FacetKey + */ + FacetKey.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey(); + if (object.key != null) + message.key = String(object.key); + if (object.intervals) { + if (!Array.isArray(object.intervals)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals: array expected"); + message.intervals = []; + for (var i = 0; i < object.intervals.length; ++i) { + if (typeof object.intervals[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.intervals: object expected"); + message.intervals[i] = $root.google.cloud.retail.v2beta.Interval.fromObject(object.intervals[i]); + } + } + if (object.restrictedValues) { + if (!Array.isArray(object.restrictedValues)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.restrictedValues: array expected"); + message.restrictedValues = []; + for (var i = 0; i < object.restrictedValues.length; ++i) + message.restrictedValues[i] = String(object.restrictedValues[i]); + } + if (object.prefixes) { + if (!Array.isArray(object.prefixes)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.prefixes: array expected"); + message.prefixes = []; + for (var i = 0; i < object.prefixes.length; ++i) + message.prefixes[i] = String(object.prefixes[i]); + } + if (object.contains) { + if (!Array.isArray(object.contains)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.contains: array expected"); + message.contains = []; + for (var i = 0; i < object.contains.length; ++i) + message.contains[i] = String(object.contains[i]); + } + if (object.caseInsensitive != null) + message.caseInsensitive = Boolean(object.caseInsensitive); + if (object.orderBy != null) + message.orderBy = String(object.orderBy); + if (object.query != null) + message.query = String(object.query); + if (object.returnMinMax != null) + message.returnMinMax = Boolean(object.returnMinMax); + return message; + }; + + /** + * Creates a plain object from a FacetKey message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey} message FacetKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.intervals = []; + object.restrictedValues = []; + object.prefixes = []; + object.contains = []; + } + if (options.defaults) { + object.key = ""; + object.orderBy = ""; + object.query = ""; + object.caseInsensitive = false; + object.returnMinMax = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.intervals && message.intervals.length) { + object.intervals = []; + for (var j = 0; j < message.intervals.length; ++j) + object.intervals[j] = $root.google.cloud.retail.v2beta.Interval.toObject(message.intervals[j], options); + } + if (message.restrictedValues && message.restrictedValues.length) { + object.restrictedValues = []; + for (var j = 0; j < message.restrictedValues.length; ++j) + object.restrictedValues[j] = message.restrictedValues[j]; + } + if (message.orderBy != null && message.hasOwnProperty("orderBy")) + object.orderBy = message.orderBy; + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.prefixes && message.prefixes.length) { + object.prefixes = []; + for (var j = 0; j < message.prefixes.length; ++j) + object.prefixes[j] = message.prefixes[j]; + } + if (message.contains && message.contains.length) { + object.contains = []; + for (var j = 0; j < message.contains.length; ++j) + object.contains[j] = message.contains[j]; + } + if (message.caseInsensitive != null && message.hasOwnProperty("caseInsensitive")) + object.caseInsensitive = message.caseInsensitive; + if (message.returnMinMax != null && message.hasOwnProperty("returnMinMax")) + object.returnMinMax = message.returnMinMax; + return object; + }; + + /** + * Converts this FacetKey to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @instance + * @returns {Object.} JSON object + */ + FacetKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetKey + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey"; + }; + + return FacetKey; + })(); + + return FacetSpec; + })(); + + SearchRequest.DynamicFacetSpec = (function() { + + /** + * Properties of a DynamicFacetSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface IDynamicFacetSpec + * @property {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode|null} [mode] DynamicFacetSpec mode + */ + + /** + * Constructs a new DynamicFacetSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a DynamicFacetSpec. + * @implements IDynamicFacetSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + */ + function DynamicFacetSpec(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]]; + } + + /** + * DynamicFacetSpec mode. + * @member {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode} mode + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @instance + */ + DynamicFacetSpec.prototype.mode = 0; + + /** + * Creates a new DynamicFacetSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} DynamicFacetSpec instance + */ + DynamicFacetSpec.create = function create(properties) { + return new DynamicFacetSpec(properties); + }; + + /** + * Encodes the specified DynamicFacetSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified DynamicFacetSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec} message DynamicFacetSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DynamicFacetSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.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.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DynamicFacetSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DynamicFacetSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DynamicFacetSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DynamicFacetSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a DynamicFacetSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} DynamicFacetSpec + */ + DynamicFacetSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec(); + 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 "DISABLED": + case 1: + message.mode = 1; + break; + case "ENABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a DynamicFacetSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} message DynamicFacetSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DynamicFacetSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this DynamicFacetSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @instance + * @returns {Object.} JSON object + */ + DynamicFacetSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DynamicFacetSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DynamicFacetSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} ENABLED=2 ENABLED value + */ + DynamicFacetSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[2] = "ENABLED"] = 2; + return values; + })(); + + return DynamicFacetSpec; + })(); + + SearchRequest.BoostSpec = (function() { + + /** + * Properties of a BoostSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface IBoostSpec + * @property {Array.|null} [conditionBoostSpecs] BoostSpec conditionBoostSpecs + * @property {boolean|null} [skipBoostSpecValidation] BoostSpec skipBoostSpecValidation + */ + + /** + * Constructs a new BoostSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a BoostSpec. + * @implements IBoostSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.IBoostSpec=} [properties] Properties to set + */ + function BoostSpec(properties) { + this.conditionBoostSpecs = []; + 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]]; + } + + /** + * BoostSpec conditionBoostSpecs. + * @member {Array.} conditionBoostSpecs + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.conditionBoostSpecs = $util.emptyArray; + + /** + * BoostSpec skipBoostSpecValidation. + * @member {boolean|null|undefined} skipBoostSpecValidation + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @instance + */ + BoostSpec.prototype.skipBoostSpecValidation = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * BoostSpec _skipBoostSpecValidation. + * @member {"skipBoostSpecValidation"|undefined} _skipBoostSpecValidation + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @instance + */ + Object.defineProperty(BoostSpec.prototype, "_skipBoostSpecValidation", { + get: $util.oneOfGetter($oneOfFields = ["skipBoostSpecValidation"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new BoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec} BoostSpec instance + */ + BoostSpec.create = function create(properties) { + return new BoostSpec(properties); + }; + + /** + * Encodes the specified BoostSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.conditionBoostSpecs != null && message.conditionBoostSpecs.length) + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.conditionBoostSpecs[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.skipBoostSpecValidation != null && Object.hasOwnProperty.call(message, "skipBoostSpecValidation")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.skipBoostSpecValidation); + return writer; + }; + + /** + * Encodes the specified BoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IBoostSpec} message BoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.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.cloud.retail.v2beta.SearchRequest.BoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.conditionBoostSpecs && message.conditionBoostSpecs.length)) + message.conditionBoostSpecs = []; + message.conditionBoostSpecs.push($root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + case 2: { + message.skipBoostSpecValidation = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec} BoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.conditionBoostSpecs != null && message.hasOwnProperty("conditionBoostSpecs")) { + if (!Array.isArray(message.conditionBoostSpecs)) + return "conditionBoostSpecs: array expected"; + for (var i = 0; i < message.conditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.conditionBoostSpecs[i]); + if (error) + return "conditionBoostSpecs." + error; + } + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + properties._skipBoostSpecValidation = 1; + if (typeof message.skipBoostSpecValidation !== "boolean") + return "skipBoostSpecValidation: boolean expected"; + } + return null; + }; + + /** + * Creates a BoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec} BoostSpec + */ + BoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec(); + if (object.conditionBoostSpecs) { + if (!Array.isArray(object.conditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.BoostSpec.conditionBoostSpecs: array expected"); + message.conditionBoostSpecs = []; + for (var i = 0; i < object.conditionBoostSpecs.length; ++i) { + if (typeof object.conditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchRequest.BoostSpec.conditionBoostSpecs: object expected"); + message.conditionBoostSpecs[i] = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.conditionBoostSpecs[i]); + } + } + if (object.skipBoostSpecValidation != null) + message.skipBoostSpecValidation = Boolean(object.skipBoostSpecValidation); + return message; + }; + + /** + * Creates a plain object from a BoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} message BoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.conditionBoostSpecs = []; + if (message.conditionBoostSpecs && message.conditionBoostSpecs.length) { + object.conditionBoostSpecs = []; + for (var j = 0; j < message.conditionBoostSpecs.length; ++j) + object.conditionBoostSpecs[j] = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.conditionBoostSpecs[j], options); + } + if (message.skipBoostSpecValidation != null && message.hasOwnProperty("skipBoostSpecValidation")) { + object.skipBoostSpecValidation = message.skipBoostSpecValidation; + if (options.oneofs) + object._skipBoostSpecValidation = "skipBoostSpecValidation"; + } + return object; + }; + + /** + * Converts this BoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @instance + * @returns {Object.} JSON object + */ + BoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.BoostSpec"; + }; + + BoostSpec.ConditionBoostSpec = (function() { + + /** + * Properties of a ConditionBoostSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @interface IConditionBoostSpec + * @property {string|null} [condition] ConditionBoostSpec condition + * @property {number|null} [boost] ConditionBoostSpec boost + */ + + /** + * Constructs a new ConditionBoostSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec + * @classdesc Represents a ConditionBoostSpec. + * @implements IConditionBoostSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + */ + function ConditionBoostSpec(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]]; + } + + /** + * ConditionBoostSpec condition. + * @member {string} condition + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.condition = ""; + + /** + * ConditionBoostSpec boost. + * @member {number} boost + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + */ + ConditionBoostSpec.prototype.boost = 0; + + /** + * Creates a new ConditionBoostSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec instance + */ + ConditionBoostSpec.create = function create(properties) { + return new ConditionBoostSpec(properties); + }; + + /** + * Encodes the specified ConditionBoostSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.condition); + if (message.boost != null && Object.hasOwnProperty.call(message, "boost")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.boost); + return writer; + }; + + /** + * Encodes the specified ConditionBoostSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec.IConditionBoostSpec} message ConditionBoostSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConditionBoostSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.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.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.string(); + break; + } + case 2: { + message.boost = reader.float(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ConditionBoostSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConditionBoostSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ConditionBoostSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ConditionBoostSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + if (!$util.isString(message.condition)) + return "condition: string expected"; + if (message.boost != null && message.hasOwnProperty("boost")) + if (typeof message.boost !== "number") + return "boost: number expected"; + return null; + }; + + /** + * Creates a ConditionBoostSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec} ConditionBoostSpec + */ + ConditionBoostSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec(); + if (object.condition != null) + message.condition = String(object.condition); + if (object.boost != null) + message.boost = Number(object.boost); + return message; + }; + + /** + * Creates a plain object from a ConditionBoostSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec} message ConditionBoostSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ConditionBoostSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = ""; + object.boost = 0; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = message.condition; + if (message.boost != null && message.hasOwnProperty("boost")) + object.boost = options.json && !isFinite(message.boost) ? String(message.boost) : message.boost; + return object; + }; + + /** + * Converts this ConditionBoostSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @instance + * @returns {Object.} JSON object + */ + ConditionBoostSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ConditionBoostSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ConditionBoostSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec"; + }; + + return ConditionBoostSpec; + })(); + + return BoostSpec; + })(); + + SearchRequest.QueryExpansionSpec = (function() { + + /** + * Properties of a QueryExpansionSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface IQueryExpansionSpec + * @property {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition|null} [condition] QueryExpansionSpec condition + * @property {boolean|null} [pinUnexpandedResults] QueryExpansionSpec pinUnexpandedResults + */ + + /** + * Constructs a new QueryExpansionSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a QueryExpansionSpec. + * @implements IQueryExpansionSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + */ + function QueryExpansionSpec(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]]; + } + + /** + * QueryExpansionSpec condition. + * @member {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition} condition + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.condition = 0; + + /** + * QueryExpansionSpec pinUnexpandedResults. + * @member {boolean} pinUnexpandedResults + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @instance + */ + QueryExpansionSpec.prototype.pinUnexpandedResults = false; + + /** + * Creates a new QueryExpansionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} QueryExpansionSpec instance + */ + QueryExpansionSpec.create = function create(properties) { + return new QueryExpansionSpec(properties); + }; + + /** + * Encodes the specified QueryExpansionSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.condition != null && Object.hasOwnProperty.call(message, "condition")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.condition); + if (message.pinUnexpandedResults != null && Object.hasOwnProperty.call(message, "pinUnexpandedResults")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.pinUnexpandedResults); + return writer; + }; + + /** + * Encodes the specified QueryExpansionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IQueryExpansionSpec} message QueryExpansionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.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.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.condition = reader.int32(); + break; + } + case 2: { + message.pinUnexpandedResults = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.condition != null && message.hasOwnProperty("condition")) + switch (message.condition) { + default: + return "condition: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + if (typeof message.pinUnexpandedResults !== "boolean") + return "pinUnexpandedResults: boolean expected"; + return null; + }; + + /** + * Creates a QueryExpansionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} QueryExpansionSpec + */ + QueryExpansionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec(); + switch (object.condition) { + default: + if (typeof object.condition === "number") { + message.condition = object.condition; + break; + } + break; + case "CONDITION_UNSPECIFIED": + case 0: + message.condition = 0; + break; + case "DISABLED": + case 1: + message.condition = 1; + break; + case "AUTO": + case 3: + message.condition = 3; + break; + } + if (object.pinUnexpandedResults != null) + message.pinUnexpandedResults = Boolean(object.pinUnexpandedResults); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} message QueryExpansionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.condition = options.enums === String ? "CONDITION_UNSPECIFIED" : 0; + object.pinUnexpandedResults = false; + } + if (message.condition != null && message.hasOwnProperty("condition")) + object.condition = options.enums === String ? $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition[message.condition] === undefined ? message.condition : $root.google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition[message.condition] : message.condition; + if (message.pinUnexpandedResults != null && message.hasOwnProperty("pinUnexpandedResults")) + object.pinUnexpandedResults = message.pinUnexpandedResults; + return object; + }; + + /** + * Converts this QueryExpansionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec"; + }; + + /** + * Condition enum. + * @name google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec.Condition + * @enum {number} + * @property {number} CONDITION_UNSPECIFIED=0 CONDITION_UNSPECIFIED value + * @property {number} DISABLED=1 DISABLED value + * @property {number} AUTO=3 AUTO value + */ + QueryExpansionSpec.Condition = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CONDITION_UNSPECIFIED"] = 0; + values[valuesById[1] = "DISABLED"] = 1; + values[valuesById[3] = "AUTO"] = 3; + return values; + })(); + + return QueryExpansionSpec; + })(); + + SearchRequest.PersonalizationSpec = (function() { + + /** + * Properties of a PersonalizationSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface IPersonalizationSpec + * @property {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode|null} [mode] PersonalizationSpec mode + */ + + /** + * Constructs a new PersonalizationSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a PersonalizationSpec. + * @implements IPersonalizationSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + */ + function PersonalizationSpec(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]]; + } + + /** + * PersonalizationSpec mode. + * @member {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode} mode + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @instance + */ + PersonalizationSpec.prototype.mode = 0; + + /** + * Creates a new PersonalizationSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} PersonalizationSpec instance + */ + PersonalizationSpec.create = function create(properties) { + return new PersonalizationSpec(properties); + }; + + /** + * Encodes the specified PersonalizationSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified PersonalizationSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec} message PersonalizationSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PersonalizationSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.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.cloud.retail.v2beta.SearchRequest.PersonalizationSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PersonalizationSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} PersonalizationSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PersonalizationSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PersonalizationSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PersonalizationSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a PersonalizationSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} PersonalizationSpec + */ + PersonalizationSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec(); + 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 "AUTO": + case 1: + message.mode = 1; + break; + case "DISABLED": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a PersonalizationSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} message PersonalizationSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PersonalizationSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this PersonalizationSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @instance + * @returns {Object.} JSON object + */ + PersonalizationSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PersonalizationSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PersonalizationSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} AUTO=1 AUTO value + * @property {number} DISABLED=2 DISABLED value + */ + PersonalizationSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "AUTO"] = 1; + values[valuesById[2] = "DISABLED"] = 2; + return values; + })(); + + return PersonalizationSpec; + })(); + + SearchRequest.SpellCorrectionSpec = (function() { + + /** + * Properties of a SpellCorrectionSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @interface ISpellCorrectionSpec + * @property {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode|null} [mode] SpellCorrectionSpec mode + */ + + /** + * Constructs a new SpellCorrectionSpec. + * @memberof google.cloud.retail.v2beta.SearchRequest + * @classdesc Represents a SpellCorrectionSpec. + * @implements ISpellCorrectionSpec + * @constructor + * @param {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + */ + function SpellCorrectionSpec(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]]; + } + + /** + * SpellCorrectionSpec mode. + * @member {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode} mode + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @instance + */ + SpellCorrectionSpec.prototype.mode = 0; + + /** + * Creates a new SpellCorrectionSpec instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec instance + */ + SpellCorrectionSpec.create = function create(properties) { + return new SpellCorrectionSpec(properties); + }; + + /** + * Encodes the specified SpellCorrectionSpec message. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.mode); + return writer; + }; + + /** + * Encodes the specified SpellCorrectionSpec message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.ISpellCorrectionSpec} message SpellCorrectionSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpellCorrectionSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.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.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.mode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpellCorrectionSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpellCorrectionSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpellCorrectionSpec message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpellCorrectionSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a SpellCorrectionSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} SpellCorrectionSpec + */ + SpellCorrectionSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec(); + 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 "SUGGESTION_ONLY": + case 1: + message.mode = 1; + break; + case "AUTO": + case 2: + message.mode = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a SpellCorrectionSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} message SpellCorrectionSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpellCorrectionSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode[message.mode] === undefined ? message.mode : $root.google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode[message.mode] : message.mode; + return object; + }; + + /** + * Converts this SpellCorrectionSpec to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @instance + * @returns {Object.} JSON object + */ + SpellCorrectionSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpellCorrectionSpec + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpellCorrectionSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec"; + }; + + /** + * Mode enum. + * @name google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} SUGGESTION_ONLY=1 SUGGESTION_ONLY value + * @property {number} AUTO=2 AUTO value + */ + SpellCorrectionSpec.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "SUGGESTION_ONLY"] = 1; + values[valuesById[2] = "AUTO"] = 2; + return values; + })(); + + return SpellCorrectionSpec; + })(); + + /** + * SearchMode enum. + * @name google.cloud.retail.v2beta.SearchRequest.SearchMode + * @enum {number} + * @property {number} SEARCH_MODE_UNSPECIFIED=0 SEARCH_MODE_UNSPECIFIED value + * @property {number} PRODUCT_SEARCH_ONLY=1 PRODUCT_SEARCH_ONLY value + * @property {number} FACETED_SEARCH_ONLY=2 FACETED_SEARCH_ONLY value + */ + SearchRequest.SearchMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SEARCH_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PRODUCT_SEARCH_ONLY"] = 1; + values[valuesById[2] = "FACETED_SEARCH_ONLY"] = 2; + return values; + })(); + + return SearchRequest; + })(); + + v2beta.SearchResponse = (function() { + + /** + * Properties of a SearchResponse. + * @memberof google.cloud.retail.v2beta + * @interface ISearchResponse + * @property {Array.|null} [results] SearchResponse results + * @property {Array.|null} [facets] SearchResponse facets + * @property {number|null} [totalSize] SearchResponse totalSize + * @property {string|null} [correctedQuery] SearchResponse correctedQuery + * @property {string|null} [attributionToken] SearchResponse attributionToken + * @property {string|null} [nextPageToken] SearchResponse nextPageToken + * @property {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo|null} [queryExpansionInfo] SearchResponse queryExpansionInfo + * @property {string|null} [redirectUri] SearchResponse redirectUri + * @property {Array.|null} [appliedControls] SearchResponse appliedControls + * @property {Array.|null} [invalidConditionBoostSpecs] SearchResponse invalidConditionBoostSpecs + */ + + /** + * Constructs a new SearchResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SearchResponse. + * @implements ISearchResponse + * @constructor + * @param {google.cloud.retail.v2beta.ISearchResponse=} [properties] Properties to set + */ + function SearchResponse(properties) { + this.results = []; + this.facets = []; + this.appliedControls = []; + this.invalidConditionBoostSpecs = []; + 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]]; + } + + /** + * SearchResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.results = $util.emptyArray; + + /** + * SearchResponse facets. + * @member {Array.} facets + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.facets = $util.emptyArray; + + /** + * SearchResponse totalSize. + * @member {number} totalSize + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.totalSize = 0; + + /** + * SearchResponse correctedQuery. + * @member {string} correctedQuery + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.correctedQuery = ""; + + /** + * SearchResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.attributionToken = ""; + + /** + * SearchResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.nextPageToken = ""; + + /** + * SearchResponse queryExpansionInfo. + * @member {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo|null|undefined} queryExpansionInfo + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.queryExpansionInfo = null; + + /** + * SearchResponse redirectUri. + * @member {string} redirectUri + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.redirectUri = ""; + + /** + * SearchResponse appliedControls. + * @member {Array.} appliedControls + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.appliedControls = $util.emptyArray; + + /** + * SearchResponse invalidConditionBoostSpecs. + * @member {Array.} invalidConditionBoostSpecs + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + */ + SearchResponse.prototype.invalidConditionBoostSpecs = $util.emptyArray; + + /** + * Creates a new SearchResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {google.cloud.retail.v2beta.ISearchResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchResponse} SearchResponse instance + */ + SearchResponse.create = function create(properties) { + return new SearchResponse(properties); + }; + + /** + * Encodes the specified SearchResponse message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {google.cloud.retail.v2beta.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2beta.SearchResponse.SearchResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.facets != null && message.facets.length) + for (var i = 0; i < message.facets.length; ++i) + $root.google.cloud.retail.v2beta.SearchResponse.Facet.encode(message.facets[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.totalSize != null && Object.hasOwnProperty.call(message, "totalSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.totalSize); + if (message.correctedQuery != null && Object.hasOwnProperty.call(message, "correctedQuery")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.correctedQuery); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.attributionToken); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.nextPageToken); + if (message.queryExpansionInfo != null && Object.hasOwnProperty.call(message, "queryExpansionInfo")) + $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.encode(message.queryExpansionInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.redirectUri != null && Object.hasOwnProperty.call(message, "redirectUri")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectUri); + if (message.appliedControls != null && message.appliedControls.length) + for (var i = 0; i < message.appliedControls.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.appliedControls[i]); + if (message.invalidConditionBoostSpecs != null && message.invalidConditionBoostSpecs.length) + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) + $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.encode(message.invalidConditionBoostSpecs[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SearchResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {google.cloud.retail.v2beta.ISearchResponse} message SearchResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.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.cloud.retail.v2beta.SearchResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2beta.SearchResponse.SearchResult.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.facets && message.facets.length)) + message.facets = []; + message.facets.push($root.google.cloud.retail.v2beta.SearchResponse.Facet.decode(reader, reader.uint32())); + break; + } + case 3: { + message.totalSize = reader.int32(); + break; + } + case 4: { + message.correctedQuery = reader.string(); + break; + } + case 5: { + message.attributionToken = reader.string(); + break; + } + case 6: { + message.nextPageToken = reader.string(); + break; + } + case 7: { + message.queryExpansionInfo = $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.decode(reader, reader.uint32()); + break; + } + case 10: { + message.redirectUri = reader.string(); + break; + } + case 12: { + if (!(message.appliedControls && message.appliedControls.length)) + message.appliedControls = []; + message.appliedControls.push(reader.string()); + break; + } + case 14: { + if (!(message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length)) + message.invalidConditionBoostSpecs = []; + message.invalidConditionBoostSpecs.push($root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchResponse} SearchResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2beta.SearchResponse.SearchResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.facets != null && message.hasOwnProperty("facets")) { + if (!Array.isArray(message.facets)) + return "facets: array expected"; + for (var i = 0; i < message.facets.length; ++i) { + var error = $root.google.cloud.retail.v2beta.SearchResponse.Facet.verify(message.facets[i]); + if (error) + return "facets." + error; + } + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + if (!$util.isInteger(message.totalSize)) + return "totalSize: integer expected"; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + if (!$util.isString(message.correctedQuery)) + return "correctedQuery: string expected"; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) { + var error = $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.verify(message.queryExpansionInfo); + if (error) + return "queryExpansionInfo." + error; + } + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + if (!$util.isString(message.redirectUri)) + return "redirectUri: string expected"; + if (message.appliedControls != null && message.hasOwnProperty("appliedControls")) { + if (!Array.isArray(message.appliedControls)) + return "appliedControls: array expected"; + for (var i = 0; i < message.appliedControls.length; ++i) + if (!$util.isString(message.appliedControls[i])) + return "appliedControls: string[] expected"; + } + if (message.invalidConditionBoostSpecs != null && message.hasOwnProperty("invalidConditionBoostSpecs")) { + if (!Array.isArray(message.invalidConditionBoostSpecs)) + return "invalidConditionBoostSpecs: array expected"; + for (var i = 0; i < message.invalidConditionBoostSpecs.length; ++i) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.verify(message.invalidConditionBoostSpecs[i]); + if (error) + return "invalidConditionBoostSpecs." + error; + } + } + return null; + }; + + /** + * Creates a SearchResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchResponse} SearchResponse + */ + SearchResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2beta.SearchResponse.SearchResult.fromObject(object.results[i]); + } + } + if (object.facets) { + if (!Array.isArray(object.facets)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.facets: array expected"); + message.facets = []; + for (var i = 0; i < object.facets.length; ++i) { + if (typeof object.facets[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.facets: object expected"); + message.facets[i] = $root.google.cloud.retail.v2beta.SearchResponse.Facet.fromObject(object.facets[i]); + } + } + if (object.totalSize != null) + message.totalSize = object.totalSize | 0; + if (object.correctedQuery != null) + message.correctedQuery = String(object.correctedQuery); + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + if (object.queryExpansionInfo != null) { + if (typeof object.queryExpansionInfo !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.queryExpansionInfo: object expected"); + message.queryExpansionInfo = $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.fromObject(object.queryExpansionInfo); + } + if (object.redirectUri != null) + message.redirectUri = String(object.redirectUri); + if (object.appliedControls) { + if (!Array.isArray(object.appliedControls)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.appliedControls: array expected"); + message.appliedControls = []; + for (var i = 0; i < object.appliedControls.length; ++i) + message.appliedControls[i] = String(object.appliedControls[i]); + } + if (object.invalidConditionBoostSpecs) { + if (!Array.isArray(object.invalidConditionBoostSpecs)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.invalidConditionBoostSpecs: array expected"); + message.invalidConditionBoostSpecs = []; + for (var i = 0; i < object.invalidConditionBoostSpecs.length; ++i) { + if (typeof object.invalidConditionBoostSpecs[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.invalidConditionBoostSpecs: object expected"); + message.invalidConditionBoostSpecs[i] = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.fromObject(object.invalidConditionBoostSpecs[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SearchResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {google.cloud.retail.v2beta.SearchResponse} message SearchResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.facets = []; + object.appliedControls = []; + object.invalidConditionBoostSpecs = []; + } + if (options.defaults) { + object.totalSize = 0; + object.correctedQuery = ""; + object.attributionToken = ""; + object.nextPageToken = ""; + object.queryExpansionInfo = null; + object.redirectUri = ""; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2beta.SearchResponse.SearchResult.toObject(message.results[j], options); + } + if (message.facets && message.facets.length) { + object.facets = []; + for (var j = 0; j < message.facets.length; ++j) + object.facets[j] = $root.google.cloud.retail.v2beta.SearchResponse.Facet.toObject(message.facets[j], options); + } + if (message.totalSize != null && message.hasOwnProperty("totalSize")) + object.totalSize = message.totalSize; + if (message.correctedQuery != null && message.hasOwnProperty("correctedQuery")) + object.correctedQuery = message.correctedQuery; + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + if (message.queryExpansionInfo != null && message.hasOwnProperty("queryExpansionInfo")) + object.queryExpansionInfo = $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.toObject(message.queryExpansionInfo, options); + if (message.redirectUri != null && message.hasOwnProperty("redirectUri")) + object.redirectUri = message.redirectUri; + if (message.appliedControls && message.appliedControls.length) { + object.appliedControls = []; + for (var j = 0; j < message.appliedControls.length; ++j) + object.appliedControls[j] = message.appliedControls[j]; + } + if (message.invalidConditionBoostSpecs && message.invalidConditionBoostSpecs.length) { + object.invalidConditionBoostSpecs = []; + for (var j = 0; j < message.invalidConditionBoostSpecs.length; ++j) + object.invalidConditionBoostSpecs[j] = $root.google.cloud.retail.v2beta.SearchRequest.BoostSpec.ConditionBoostSpec.toObject(message.invalidConditionBoostSpecs[j], options); + } + return object; + }; + + /** + * Converts this SearchResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchResponse + * @instance + * @returns {Object.} JSON object + */ + SearchResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchResponse"; + }; + + SearchResponse.SearchResult = (function() { + + /** + * Properties of a SearchResult. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @interface ISearchResult + * @property {string|null} [id] SearchResult id + * @property {google.cloud.retail.v2beta.IProduct|null} [product] SearchResult product + * @property {number|null} [matchingVariantCount] SearchResult matchingVariantCount + * @property {Object.|null} [matchingVariantFields] SearchResult matchingVariantFields + * @property {Object.|null} [variantRollupValues] SearchResult variantRollupValues + * @property {Array.|null} [personalLabels] SearchResult personalLabels + */ + + /** + * Constructs a new SearchResult. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @classdesc Represents a SearchResult. + * @implements ISearchResult + * @constructor + * @param {google.cloud.retail.v2beta.SearchResponse.ISearchResult=} [properties] Properties to set + */ + function SearchResult(properties) { + this.matchingVariantFields = {}; + this.variantRollupValues = {}; + this.personalLabels = []; + 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]]; + } + + /** + * SearchResult id. + * @member {string} id + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.id = ""; + + /** + * SearchResult product. + * @member {google.cloud.retail.v2beta.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.product = null; + + /** + * SearchResult matchingVariantCount. + * @member {number} matchingVariantCount + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantCount = 0; + + /** + * SearchResult matchingVariantFields. + * @member {Object.} matchingVariantFields + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.matchingVariantFields = $util.emptyObject; + + /** + * SearchResult variantRollupValues. + * @member {Object.} variantRollupValues + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.variantRollupValues = $util.emptyObject; + + /** + * SearchResult personalLabels. + * @member {Array.} personalLabels + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + */ + SearchResult.prototype.personalLabels = $util.emptyArray; + + /** + * Creates a new SearchResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.ISearchResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchResponse.SearchResult} SearchResult instance + */ + SearchResult.create = function create(properties) { + return new SearchResult(properties); + }; + + /** + * Encodes the specified SearchResult message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.SearchResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2beta.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.matchingVariantCount != null && Object.hasOwnProperty.call(message, "matchingVariantCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.matchingVariantCount); + if (message.matchingVariantFields != null && Object.hasOwnProperty.call(message, "matchingVariantFields")) + for (var keys = Object.keys(message.matchingVariantFields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.FieldMask.encode(message.matchingVariantFields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.variantRollupValues != null && Object.hasOwnProperty.call(message, "variantRollupValues")) + for (var keys = Object.keys(message.variantRollupValues), 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.protobuf.Value.encode(message.variantRollupValues[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.personalLabels != null && message.personalLabels.length) + for (var i = 0; i < message.personalLabels.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.personalLabels[i]); + return writer; + }; + + /** + * Encodes the specified SearchResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.SearchResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.ISearchResult} message SearchResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SearchResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.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.cloud.retail.v2beta.SearchResponse.SearchResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.matchingVariantCount = reader.int32(); + break; + } + case 4: { + if (message.matchingVariantFields === $util.emptyObject) + message.matchingVariantFields = {}; + 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.FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.matchingVariantFields[key] = value; + break; + } + case 5: { + if (message.variantRollupValues === $util.emptyObject) + message.variantRollupValues = {}; + 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.variantRollupValues[key] = value; + break; + } + case 7: { + if (!(message.personalLabels && message.personalLabels.length)) + message.personalLabels = []; + message.personalLabels.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SearchResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchResponse.SearchResult} SearchResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SearchResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SearchResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SearchResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + if (!$util.isInteger(message.matchingVariantCount)) + return "matchingVariantCount: integer expected"; + if (message.matchingVariantFields != null && message.hasOwnProperty("matchingVariantFields")) { + if (!$util.isObject(message.matchingVariantFields)) + return "matchingVariantFields: object expected"; + var key = Object.keys(message.matchingVariantFields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.FieldMask.verify(message.matchingVariantFields[key[i]]); + if (error) + return "matchingVariantFields." + error; + } + } + if (message.variantRollupValues != null && message.hasOwnProperty("variantRollupValues")) { + if (!$util.isObject(message.variantRollupValues)) + return "variantRollupValues: object expected"; + var key = Object.keys(message.variantRollupValues); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.variantRollupValues[key[i]]); + if (error) + return "variantRollupValues." + error; + } + } + if (message.personalLabels != null && message.hasOwnProperty("personalLabels")) { + if (!Array.isArray(message.personalLabels)) + return "personalLabels: array expected"; + for (var i = 0; i < message.personalLabels.length; ++i) + if (!$util.isString(message.personalLabels[i])) + return "personalLabels: string[] expected"; + } + return null; + }; + + /** + * Creates a SearchResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchResponse.SearchResult} SearchResult + */ + SearchResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchResponse.SearchResult) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchResponse.SearchResult(); + if (object.id != null) + message.id = String(object.id); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.product: object expected"); + message.product = $root.google.cloud.retail.v2beta.Product.fromObject(object.product); + } + if (object.matchingVariantCount != null) + message.matchingVariantCount = object.matchingVariantCount | 0; + if (object.matchingVariantFields) { + if (typeof object.matchingVariantFields !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields = {}; + for (var keys = Object.keys(object.matchingVariantFields), i = 0; i < keys.length; ++i) { + if (typeof object.matchingVariantFields[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.matchingVariantFields: object expected"); + message.matchingVariantFields[keys[i]] = $root.google.protobuf.FieldMask.fromObject(object.matchingVariantFields[keys[i]]); + } + } + if (object.variantRollupValues) { + if (typeof object.variantRollupValues !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues = {}; + for (var keys = Object.keys(object.variantRollupValues), i = 0; i < keys.length; ++i) { + if (typeof object.variantRollupValues[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.variantRollupValues: object expected"); + message.variantRollupValues[keys[i]] = $root.google.protobuf.Value.fromObject(object.variantRollupValues[keys[i]]); + } + } + if (object.personalLabels) { + if (!Array.isArray(object.personalLabels)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.SearchResult.personalLabels: array expected"); + message.personalLabels = []; + for (var i = 0; i < object.personalLabels.length; ++i) + message.personalLabels[i] = String(object.personalLabels[i]); + } + return message; + }; + + /** + * Creates a plain object from a SearchResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.SearchResult} message SearchResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SearchResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.personalLabels = []; + if (options.objects || options.defaults) { + object.matchingVariantFields = {}; + object.variantRollupValues = {}; + } + if (options.defaults) { + object.id = ""; + object.product = null; + object.matchingVariantCount = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2beta.Product.toObject(message.product, options); + if (message.matchingVariantCount != null && message.hasOwnProperty("matchingVariantCount")) + object.matchingVariantCount = message.matchingVariantCount; + var keys2; + if (message.matchingVariantFields && (keys2 = Object.keys(message.matchingVariantFields)).length) { + object.matchingVariantFields = {}; + for (var j = 0; j < keys2.length; ++j) + object.matchingVariantFields[keys2[j]] = $root.google.protobuf.FieldMask.toObject(message.matchingVariantFields[keys2[j]], options); + } + if (message.variantRollupValues && (keys2 = Object.keys(message.variantRollupValues)).length) { + object.variantRollupValues = {}; + for (var j = 0; j < keys2.length; ++j) + object.variantRollupValues[keys2[j]] = $root.google.protobuf.Value.toObject(message.variantRollupValues[keys2[j]], options); + } + if (message.personalLabels && message.personalLabels.length) { + object.personalLabels = []; + for (var j = 0; j < message.personalLabels.length; ++j) + object.personalLabels[j] = message.personalLabels[j]; + } + return object; + }; + + /** + * Converts this SearchResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @instance + * @returns {Object.} JSON object + */ + SearchResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SearchResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchResponse.SearchResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SearchResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchResponse.SearchResult"; + }; + + return SearchResult; + })(); + + SearchResponse.Facet = (function() { + + /** + * Properties of a Facet. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @interface IFacet + * @property {string|null} [key] Facet key + * @property {Array.|null} [values] Facet values + * @property {boolean|null} [dynamicFacet] Facet dynamicFacet + */ + + /** + * Constructs a new Facet. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @classdesc Represents a Facet. + * @implements IFacet + * @constructor + * @param {google.cloud.retail.v2beta.SearchResponse.IFacet=} [properties] Properties to set + */ + function Facet(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]]; + } + + /** + * Facet key. + * @member {string} key + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @instance + */ + Facet.prototype.key = ""; + + /** + * Facet values. + * @member {Array.} values + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @instance + */ + Facet.prototype.values = $util.emptyArray; + + /** + * Facet dynamicFacet. + * @member {boolean} dynamicFacet + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @instance + */ + Facet.prototype.dynamicFacet = false; + + /** + * Creates a new Facet instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IFacet=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet} Facet instance + */ + Facet.create = function create(properties) { + return new Facet(properties); + }; + + /** + * Encodes the specified Facet message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.key); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.encode(message.values[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.dynamicFacet != null && Object.hasOwnProperty.call(message, "dynamicFacet")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.dynamicFacet); + return writer; + }; + + /** + * Encodes the specified Facet message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IFacet} message Facet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Facet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Facet message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.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.cloud.retail.v2beta.SearchResponse.Facet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = reader.string(); + break; + } + case 2: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.decode(reader, reader.uint32())); + break; + } + case 3: { + message.dynamicFacet = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Facet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet} Facet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Facet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Facet message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Facet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!$util.isString(message.key)) + return "key: string 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.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.verify(message.values[i]); + if (error) + return "values." + error; + } + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + if (typeof message.dynamicFacet !== "boolean") + return "dynamicFacet: boolean expected"; + return null; + }; + + /** + * Creates a Facet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet} Facet + */ + Facet.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchResponse.Facet) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchResponse.Facet(); + if (object.key != null) + message.key = String(object.key); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.Facet.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.Facet.values: object expected"); + message.values[i] = $root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.fromObject(object.values[i]); + } + } + if (object.dynamicFacet != null) + message.dynamicFacet = Boolean(object.dynamicFacet); + return message; + }; + + /** + * Creates a plain object from a Facet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.Facet} message Facet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Facet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (options.defaults) { + object.key = ""; + object.dynamicFacet = false; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = message.key; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.toObject(message.values[j], options); + } + if (message.dynamicFacet != null && message.hasOwnProperty("dynamicFacet")) + object.dynamicFacet = message.dynamicFacet; + return object; + }; + + /** + * Converts this Facet to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @instance + * @returns {Object.} JSON object + */ + Facet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Facet + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Facet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchResponse.Facet"; + }; + + Facet.FacetValue = (function() { + + /** + * Properties of a FacetValue. + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @interface IFacetValue + * @property {string|null} [value] FacetValue value + * @property {google.cloud.retail.v2beta.IInterval|null} [interval] FacetValue interval + * @property {number|Long|null} [count] FacetValue count + * @property {number|null} [minValue] FacetValue minValue + * @property {number|null} [maxValue] FacetValue maxValue + */ + + /** + * Constructs a new FacetValue. + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet + * @classdesc Represents a FacetValue. + * @implements IFacetValue + * @constructor + * @param {google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + */ + function FacetValue(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]]; + } + + /** + * FacetValue value. + * @member {string|null|undefined} value + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.value = null; + + /** + * FacetValue interval. + * @member {google.cloud.retail.v2beta.IInterval|null|undefined} interval + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.interval = null; + + /** + * FacetValue count. + * @member {number|Long} count + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.count = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * FacetValue minValue. + * @member {number} minValue + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.minValue = 0; + + /** + * FacetValue maxValue. + * @member {number} maxValue + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + FacetValue.prototype.maxValue = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * FacetValue facetValue. + * @member {"value"|"interval"|undefined} facetValue + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + */ + Object.defineProperty(FacetValue.prototype, "facetValue", { + get: $util.oneOfGetter($oneOfFields = ["value", "interval"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new FacetValue instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue} FacetValue instance + */ + FacetValue.create = function create(properties) { + return new FacetValue(properties); + }; + + /** + * Encodes the specified FacetValue message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.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); + if (message.interval != null && Object.hasOwnProperty.call(message, "interval")) + $root.google.cloud.retail.v2beta.Interval.encode(message.interval, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.count); + if (message.minValue != null && Object.hasOwnProperty.call(message, "minValue")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.minValue); + if (message.maxValue != null && Object.hasOwnProperty.call(message, "maxValue")) + writer.uint32(/* id 6, wireType 1 =*/49).double(message.maxValue); + return writer; + }; + + /** + * Encodes the specified FacetValue message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.Facet.IFacetValue} message FacetValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FacetValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.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.cloud.retail.v2beta.SearchResponse.Facet.FacetValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + case 2: { + message.interval = $root.google.cloud.retail.v2beta.Interval.decode(reader, reader.uint32()); + break; + } + case 3: { + message.count = reader.int64(); + break; + } + case 5: { + message.minValue = reader.double(); + break; + } + case 6: { + message.maxValue = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FacetValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue} FacetValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FacetValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FacetValue message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FacetValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.value != null && message.hasOwnProperty("value")) { + properties.facetValue = 1; + if (!$util.isString(message.value)) + return "value: string expected"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + if (properties.facetValue === 1) + return "facetValue: multiple values"; + properties.facetValue = 1; + { + var error = $root.google.cloud.retail.v2beta.Interval.verify(message.interval); + if (error) + return "interval." + error; + } + } + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count) && !(message.count && $util.isInteger(message.count.low) && $util.isInteger(message.count.high))) + return "count: integer|Long expected"; + if (message.minValue != null && message.hasOwnProperty("minValue")) + if (typeof message.minValue !== "number") + return "minValue: number expected"; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + if (typeof message.maxValue !== "number") + return "maxValue: number expected"; + return null; + }; + + /** + * Creates a FacetValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue} FacetValue + */ + FacetValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue(); + if (object.value != null) + message.value = String(object.value); + if (object.interval != null) { + if (typeof object.interval !== "object") + throw TypeError(".google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval: object expected"); + message.interval = $root.google.cloud.retail.v2beta.Interval.fromObject(object.interval); + } + if (object.count != null) + if ($util.Long) + (message.count = $util.Long.fromValue(object.count)).unsigned = false; + else if (typeof object.count === "string") + message.count = parseInt(object.count, 10); + else if (typeof object.count === "number") + message.count = object.count; + else if (typeof object.count === "object") + message.count = new $util.LongBits(object.count.low >>> 0, object.count.high >>> 0).toNumber(); + if (object.minValue != null) + message.minValue = Number(object.minValue); + if (object.maxValue != null) + message.maxValue = Number(object.maxValue); + return message; + }; + + /** + * Creates a plain object from a FacetValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue} message FacetValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FacetValue.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.count = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.count = options.longs === String ? "0" : 0; + object.minValue = 0; + object.maxValue = 0; + } + if (message.value != null && message.hasOwnProperty("value")) { + object.value = message.value; + if (options.oneofs) + object.facetValue = "value"; + } + if (message.interval != null && message.hasOwnProperty("interval")) { + object.interval = $root.google.cloud.retail.v2beta.Interval.toObject(message.interval, options); + if (options.oneofs) + object.facetValue = "interval"; + } + if (message.count != null && message.hasOwnProperty("count")) + if (typeof message.count === "number") + object.count = options.longs === String ? String(message.count) : message.count; + else + object.count = options.longs === String ? $util.Long.prototype.toString.call(message.count) : options.longs === Number ? new $util.LongBits(message.count.low >>> 0, message.count.high >>> 0).toNumber() : message.count; + if (message.minValue != null && message.hasOwnProperty("minValue")) + object.minValue = options.json && !isFinite(message.minValue) ? String(message.minValue) : message.minValue; + if (message.maxValue != null && message.hasOwnProperty("maxValue")) + object.maxValue = options.json && !isFinite(message.maxValue) ? String(message.maxValue) : message.maxValue; + return object; + }; + + /** + * Converts this FacetValue to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @instance + * @returns {Object.} JSON object + */ + FacetValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FacetValue + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FacetValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue"; + }; + + return FacetValue; + })(); + + return Facet; + })(); + + SearchResponse.QueryExpansionInfo = (function() { + + /** + * Properties of a QueryExpansionInfo. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @interface IQueryExpansionInfo + * @property {boolean|null} [expandedQuery] QueryExpansionInfo expandedQuery + * @property {number|Long|null} [pinnedResultCount] QueryExpansionInfo pinnedResultCount + */ + + /** + * Constructs a new QueryExpansionInfo. + * @memberof google.cloud.retail.v2beta.SearchResponse + * @classdesc Represents a QueryExpansionInfo. + * @implements IQueryExpansionInfo + * @constructor + * @param {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + */ + function QueryExpansionInfo(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]]; + } + + /** + * QueryExpansionInfo expandedQuery. + * @member {boolean} expandedQuery + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.expandedQuery = false; + + /** + * QueryExpansionInfo pinnedResultCount. + * @member {number|Long} pinnedResultCount + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @instance + */ + QueryExpansionInfo.prototype.pinnedResultCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new QueryExpansionInfo instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo} QueryExpansionInfo instance + */ + QueryExpansionInfo.create = function create(properties) { + return new QueryExpansionInfo(properties); + }; + + /** + * Encodes the specified QueryExpansionInfo message. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.expandedQuery != null && Object.hasOwnProperty.call(message, "expandedQuery")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.expandedQuery); + if (message.pinnedResultCount != null && Object.hasOwnProperty.call(message, "pinnedResultCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.pinnedResultCount); + return writer; + }; + + /** + * Encodes the specified QueryExpansionInfo message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.IQueryExpansionInfo} message QueryExpansionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryExpansionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.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.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.expandedQuery = reader.bool(); + break; + } + case 2: { + message.pinnedResultCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryExpansionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryExpansionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryExpansionInfo message. + * @function verify + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryExpansionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + if (typeof message.expandedQuery !== "boolean") + return "expandedQuery: boolean expected"; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (!$util.isInteger(message.pinnedResultCount) && !(message.pinnedResultCount && $util.isInteger(message.pinnedResultCount.low) && $util.isInteger(message.pinnedResultCount.high))) + return "pinnedResultCount: integer|Long expected"; + return null; + }; + + /** + * Creates a QueryExpansionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo} QueryExpansionInfo + */ + QueryExpansionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo) + return object; + var message = new $root.google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo(); + if (object.expandedQuery != null) + message.expandedQuery = Boolean(object.expandedQuery); + if (object.pinnedResultCount != null) + if ($util.Long) + (message.pinnedResultCount = $util.Long.fromValue(object.pinnedResultCount)).unsigned = false; + else if (typeof object.pinnedResultCount === "string") + message.pinnedResultCount = parseInt(object.pinnedResultCount, 10); + else if (typeof object.pinnedResultCount === "number") + message.pinnedResultCount = object.pinnedResultCount; + else if (typeof object.pinnedResultCount === "object") + message.pinnedResultCount = new $util.LongBits(object.pinnedResultCount.low >>> 0, object.pinnedResultCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a QueryExpansionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo} message QueryExpansionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryExpansionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.expandedQuery = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.pinnedResultCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.pinnedResultCount = options.longs === String ? "0" : 0; + } + if (message.expandedQuery != null && message.hasOwnProperty("expandedQuery")) + object.expandedQuery = message.expandedQuery; + if (message.pinnedResultCount != null && message.hasOwnProperty("pinnedResultCount")) + if (typeof message.pinnedResultCount === "number") + object.pinnedResultCount = options.longs === String ? String(message.pinnedResultCount) : message.pinnedResultCount; + else + object.pinnedResultCount = options.longs === String ? $util.Long.prototype.toString.call(message.pinnedResultCount) : options.longs === Number ? new $util.LongBits(message.pinnedResultCount.low >>> 0, message.pinnedResultCount.high >>> 0).toNumber() : message.pinnedResultCount; + return object; + }; + + /** + * Converts this QueryExpansionInfo to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @instance + * @returns {Object.} JSON object + */ + QueryExpansionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryExpansionInfo + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryExpansionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SearchResponse.QueryExpansionInfo"; + }; + + return QueryExpansionInfo; + })(); + + return SearchResponse; + })(); + + v2beta.ControlService = (function() { + + /** + * Constructs a new ControlService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ControlService + * @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 ControlService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ControlService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ControlService; + + /** + * Creates new ControlService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.ControlService + * @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 {ControlService} RPC service. Useful where requests and/or responses are streamed. + */ + ControlService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|createControl}. + * @memberof google.cloud.retail.v2beta.ControlService + * @typedef CreateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Control} [response] Control + */ + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.ICreateControlRequest} request CreateControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ControlService.CreateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.createControl = function createControl(request, callback) { + return this.rpcCall(createControl, $root.google.cloud.retail.v2beta.CreateControlRequest, $root.google.cloud.retail.v2beta.Control, request, callback); + }, "name", { value: "CreateControl" }); + + /** + * Calls CreateControl. + * @function createControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.ICreateControlRequest} request CreateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|deleteControl}. + * @memberof google.cloud.retail.v2beta.ControlService + * @typedef DeleteControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ControlService.DeleteControlCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.deleteControl = function deleteControl(request, callback) { + return this.rpcCall(deleteControl, $root.google.cloud.retail.v2beta.DeleteControlRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteControl" }); + + /** + * Calls DeleteControl. + * @function deleteControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteControlRequest} request DeleteControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|updateControl}. + * @memberof google.cloud.retail.v2beta.ControlService + * @typedef UpdateControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Control} [response] Control + */ + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ControlService.UpdateControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.updateControl = function updateControl(request, callback) { + return this.rpcCall(updateControl, $root.google.cloud.retail.v2beta.UpdateControlRequest, $root.google.cloud.retail.v2beta.Control, request, callback); + }, "name", { value: "UpdateControl" }); + + /** + * Calls UpdateControl. + * @function updateControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateControlRequest} request UpdateControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|getControl}. + * @memberof google.cloud.retail.v2beta.ControlService + * @typedef GetControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Control} [response] Control + */ + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IGetControlRequest} request GetControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ControlService.GetControlCallback} callback Node-style callback called with the error, if any, and Control + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.getControl = function getControl(request, callback) { + return this.rpcCall(getControl, $root.google.cloud.retail.v2beta.GetControlRequest, $root.google.cloud.retail.v2beta.Control, request, callback); + }, "name", { value: "GetControl" }); + + /** + * Calls GetControl. + * @function getControl + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IGetControlRequest} request GetControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ControlService|listControls}. + * @memberof google.cloud.retail.v2beta.ControlService + * @typedef ListControlsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ListControlsResponse} [response] ListControlsResponse + */ + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IListControlsRequest} request ListControlsRequest message or plain object + * @param {google.cloud.retail.v2beta.ControlService.ListControlsCallback} callback Node-style callback called with the error, if any, and ListControlsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ControlService.prototype.listControls = function listControls(request, callback) { + return this.rpcCall(listControls, $root.google.cloud.retail.v2beta.ListControlsRequest, $root.google.cloud.retail.v2beta.ListControlsResponse, request, callback); + }, "name", { value: "ListControls" }); + + /** + * Calls ListControls. + * @function listControls + * @memberof google.cloud.retail.v2beta.ControlService + * @instance + * @param {google.cloud.retail.v2beta.IListControlsRequest} request ListControlsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ControlService; + })(); + + v2beta.CreateControlRequest = (function() { + + /** + * Properties of a CreateControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICreateControlRequest + * @property {string|null} [parent] CreateControlRequest parent + * @property {google.cloud.retail.v2beta.IControl|null} [control] CreateControlRequest control + * @property {string|null} [controlId] CreateControlRequest controlId + */ + + /** + * Constructs a new CreateControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CreateControlRequest. + * @implements ICreateControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICreateControlRequest=} [properties] Properties to set + */ + function CreateControlRequest(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]]; + } + + /** + * CreateControlRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.parent = ""; + + /** + * CreateControlRequest control. + * @member {google.cloud.retail.v2beta.IControl|null|undefined} control + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.control = null; + + /** + * CreateControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @instance + */ + CreateControlRequest.prototype.controlId = ""; + + /** + * Creates a new CreateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CreateControlRequest} CreateControlRequest instance + */ + CreateControlRequest.create = function create(properties) { + return new CreateControlRequest(properties); + }; + + /** + * Encodes the specified CreateControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2beta.Control.encode(message.control, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified CreateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateControlRequest} message CreateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.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.cloud.retail.v2beta.CreateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.control = $root.google.cloud.retail.v2beta.Control.decode(reader, reader.uint32()); + break; + } + case 3: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CreateControlRequest} CreateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2beta.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a CreateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CreateControlRequest} CreateControlRequest + */ + CreateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CreateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CreateControlRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2beta.CreateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2beta.Control.fromObject(object.control); + } + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a CreateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {google.cloud.retail.v2beta.CreateControlRequest} message CreateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.control = null; + object.controlId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2beta.Control.toObject(message.control, options); + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this CreateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @instance + * @returns {Object.} JSON object + */ + CreateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CreateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CreateControlRequest"; + }; + + return CreateControlRequest; + })(); + + v2beta.UpdateControlRequest = (function() { + + /** + * Properties of an UpdateControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateControlRequest + * @property {google.cloud.retail.v2beta.IControl|null} [control] UpdateControlRequest control + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateControlRequest updateMask + */ + + /** + * Constructs a new UpdateControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateControlRequest. + * @implements IUpdateControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateControlRequest=} [properties] Properties to set + */ + function UpdateControlRequest(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]]; + } + + /** + * UpdateControlRequest control. + * @member {google.cloud.retail.v2beta.IControl|null|undefined} control + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.control = null; + + /** + * UpdateControlRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @instance + */ + UpdateControlRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateControlRequest} UpdateControlRequest instance + */ + UpdateControlRequest.create = function create(properties) { + return new UpdateControlRequest(properties); + }; + + /** + * Encodes the specified UpdateControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.control != null && Object.hasOwnProperty.call(message, "control")) + $root.google.cloud.retail.v2beta.Control.encode(message.control, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateControlRequest} message UpdateControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.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.cloud.retail.v2beta.UpdateControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.control = $root.google.cloud.retail.v2beta.Control.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateControlRequest} UpdateControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.control != null && message.hasOwnProperty("control")) { + var error = $root.google.cloud.retail.v2beta.Control.verify(message.control); + if (error) + return "control." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateControlRequest} UpdateControlRequest + */ + UpdateControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateControlRequest(); + if (object.control != null) { + if (typeof object.control !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateControlRequest.control: object expected"); + message.control = $root.google.cloud.retail.v2beta.Control.fromObject(object.control); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateControlRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateControlRequest} message UpdateControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.control = null; + object.updateMask = null; + } + if (message.control != null && message.hasOwnProperty("control")) + object.control = $root.google.cloud.retail.v2beta.Control.toObject(message.control, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateControlRequest"; + }; + + return UpdateControlRequest; + })(); + + v2beta.DeleteControlRequest = (function() { + + /** + * Properties of a DeleteControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface IDeleteControlRequest + * @property {string|null} [name] DeleteControlRequest name + */ + + /** + * Constructs a new DeleteControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a DeleteControlRequest. + * @implements IDeleteControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.IDeleteControlRequest=} [properties] Properties to set + */ + function DeleteControlRequest(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]]; + } + + /** + * DeleteControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @instance + */ + DeleteControlRequest.prototype.name = ""; + + /** + * Creates a new DeleteControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.DeleteControlRequest} DeleteControlRequest instance + */ + DeleteControlRequest.create = function create(properties) { + return new DeleteControlRequest(properties); + }; + + /** + * Encodes the specified DeleteControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.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 DeleteControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteControlRequest} message DeleteControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.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.cloud.retail.v2beta.DeleteControlRequest(); + 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 DeleteControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.DeleteControlRequest} DeleteControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteControlRequest.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 DeleteControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.DeleteControlRequest} DeleteControlRequest + */ + DeleteControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.DeleteControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.DeleteControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {google.cloud.retail.v2beta.DeleteControlRequest} message DeleteControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteControlRequest.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 DeleteControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.DeleteControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.DeleteControlRequest"; + }; + + return DeleteControlRequest; + })(); + + v2beta.GetControlRequest = (function() { + + /** + * Properties of a GetControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetControlRequest + * @property {string|null} [name] GetControlRequest name + */ + + /** + * Constructs a new GetControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetControlRequest. + * @implements IGetControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetControlRequest=} [properties] Properties to set + */ + function GetControlRequest(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]]; + } + + /** + * GetControlRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @instance + */ + GetControlRequest.prototype.name = ""; + + /** + * Creates a new GetControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {google.cloud.retail.v2beta.IGetControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetControlRequest} GetControlRequest instance + */ + GetControlRequest.create = function create(properties) { + return new GetControlRequest(properties); + }; + + /** + * Encodes the specified GetControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {google.cloud.retail.v2beta.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.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 GetControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {google.cloud.retail.v2beta.IGetControlRequest} message GetControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.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.cloud.retail.v2beta.GetControlRequest(); + 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 GetControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetControlRequest} GetControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetControlRequest.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 GetControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetControlRequest} GetControlRequest + */ + GetControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetControlRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {google.cloud.retail.v2beta.GetControlRequest} message GetControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetControlRequest.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 GetControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @instance + * @returns {Object.} JSON object + */ + GetControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetControlRequest"; + }; + + return GetControlRequest; + })(); + + v2beta.ListControlsRequest = (function() { + + /** + * Properties of a ListControlsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IListControlsRequest + * @property {string|null} [parent] ListControlsRequest parent + * @property {number|null} [pageSize] ListControlsRequest pageSize + * @property {string|null} [pageToken] ListControlsRequest pageToken + * @property {string|null} [filter] ListControlsRequest filter + */ + + /** + * Constructs a new ListControlsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListControlsRequest. + * @implements IListControlsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IListControlsRequest=} [properties] Properties to set + */ + function ListControlsRequest(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]]; + } + + /** + * ListControlsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.parent = ""; + + /** + * ListControlsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageSize = 0; + + /** + * ListControlsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.pageToken = ""; + + /** + * ListControlsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @instance + */ + ListControlsRequest.prototype.filter = ""; + + /** + * Creates a new ListControlsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {google.cloud.retail.v2beta.IListControlsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListControlsRequest} ListControlsRequest instance + */ + ListControlsRequest.create = function create(properties) { + return new ListControlsRequest(properties); + }; + + /** + * Encodes the specified ListControlsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {google.cloud.retail.v2beta.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + return writer; + }; + + /** + * Encodes the specified ListControlsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {google.cloud.retail.v2beta.IListControlsRequest} message ListControlsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.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.cloud.retail.v2beta.ListControlsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListControlsRequest} ListControlsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a ListControlsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListControlsRequest} ListControlsRequest + */ + ListControlsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListControlsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ListControlsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a ListControlsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {google.cloud.retail.v2beta.ListControlsRequest} message ListControlsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this ListControlsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @instance + * @returns {Object.} JSON object + */ + ListControlsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListControlsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListControlsRequest"; + }; + + return ListControlsRequest; + })(); + + v2beta.ListControlsResponse = (function() { + + /** + * Properties of a ListControlsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IListControlsResponse + * @property {Array.|null} [controls] ListControlsResponse controls + * @property {string|null} [nextPageToken] ListControlsResponse nextPageToken + */ + + /** + * Constructs a new ListControlsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListControlsResponse. + * @implements IListControlsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IListControlsResponse=} [properties] Properties to set + */ + function ListControlsResponse(properties) { + this.controls = []; + 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]]; + } + + /** + * ListControlsResponse controls. + * @member {Array.} controls + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.controls = $util.emptyArray; + + /** + * ListControlsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @instance + */ + ListControlsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListControlsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {google.cloud.retail.v2beta.IListControlsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListControlsResponse} ListControlsResponse instance + */ + ListControlsResponse.create = function create(properties) { + return new ListControlsResponse(properties); + }; + + /** + * Encodes the specified ListControlsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {google.cloud.retail.v2beta.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.controls != null && message.controls.length) + for (var i = 0; i < message.controls.length; ++i) + $root.google.cloud.retail.v2beta.Control.encode(message.controls[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 ListControlsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListControlsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {google.cloud.retail.v2beta.IListControlsResponse} message ListControlsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListControlsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.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.cloud.retail.v2beta.ListControlsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.controls && message.controls.length)) + message.controls = []; + message.controls.push($root.google.cloud.retail.v2beta.Control.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListControlsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListControlsResponse} ListControlsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListControlsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListControlsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListControlsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.controls != null && message.hasOwnProperty("controls")) { + if (!Array.isArray(message.controls)) + return "controls: array expected"; + for (var i = 0; i < message.controls.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Control.verify(message.controls[i]); + if (error) + return "controls." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListControlsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListControlsResponse} ListControlsResponse + */ + ListControlsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListControlsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ListControlsResponse(); + if (object.controls) { + if (!Array.isArray(object.controls)) + throw TypeError(".google.cloud.retail.v2beta.ListControlsResponse.controls: array expected"); + message.controls = []; + for (var i = 0; i < object.controls.length; ++i) { + if (typeof object.controls[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListControlsResponse.controls: object expected"); + message.controls[i] = $root.google.cloud.retail.v2beta.Control.fromObject(object.controls[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListControlsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {google.cloud.retail.v2beta.ListControlsResponse} message ListControlsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListControlsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.controls = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.controls && message.controls.length) { + object.controls = []; + for (var j = 0; j < message.controls.length; ++j) + object.controls[j] = $root.google.cloud.retail.v2beta.Control.toObject(message.controls[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListControlsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @instance + * @returns {Object.} JSON object + */ + ListControlsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListControlsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListControlsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListControlsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListControlsResponse"; + }; + + return ListControlsResponse; + })(); + + v2beta.ExportErrorsConfig = (function() { + + /** + * Properties of an ExportErrorsConfig. + * @memberof google.cloud.retail.v2beta + * @interface IExportErrorsConfig + * @property {string|null} [gcsPrefix] ExportErrorsConfig gcsPrefix + */ + + /** + * Constructs a new ExportErrorsConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ExportErrorsConfig. + * @implements IExportErrorsConfig + * @constructor + * @param {google.cloud.retail.v2beta.IExportErrorsConfig=} [properties] Properties to set + */ + function ExportErrorsConfig(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]]; + } + + /** + * ExportErrorsConfig gcsPrefix. + * @member {string|null|undefined} gcsPrefix + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @instance + */ + ExportErrorsConfig.prototype.gcsPrefix = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ExportErrorsConfig destination. + * @member {"gcsPrefix"|undefined} destination + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @instance + */ + Object.defineProperty(ExportErrorsConfig.prototype, "destination", { + get: $util.oneOfGetter($oneOfFields = ["gcsPrefix"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ExportErrorsConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IExportErrorsConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ExportErrorsConfig} ExportErrorsConfig instance + */ + ExportErrorsConfig.create = function create(properties) { + return new ExportErrorsConfig(properties); + }; + + /** + * Encodes the specified ExportErrorsConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ExportErrorsConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IExportErrorsConfig} message ExportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportErrorsConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsPrefix != null && Object.hasOwnProperty.call(message, "gcsPrefix")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsPrefix); + return writer; + }; + + /** + * Encodes the specified ExportErrorsConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportErrorsConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.IExportErrorsConfig} message ExportErrorsConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportErrorsConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ExportErrorsConfig} ExportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportErrorsConfig.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.cloud.retail.v2beta.ExportErrorsConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportErrorsConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ExportErrorsConfig} ExportErrorsConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportErrorsConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportErrorsConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportErrorsConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + properties.destination = 1; + if (!$util.isString(message.gcsPrefix)) + return "gcsPrefix: string expected"; + } + return null; + }; + + /** + * Creates an ExportErrorsConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ExportErrorsConfig} ExportErrorsConfig + */ + ExportErrorsConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ExportErrorsConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.ExportErrorsConfig(); + if (object.gcsPrefix != null) + message.gcsPrefix = String(object.gcsPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportErrorsConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {google.cloud.retail.v2beta.ExportErrorsConfig} message ExportErrorsConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportErrorsConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.gcsPrefix != null && message.hasOwnProperty("gcsPrefix")) { + object.gcsPrefix = message.gcsPrefix; + if (options.oneofs) + object.destination = "gcsPrefix"; + } + return object; + }; + + /** + * Converts this ExportErrorsConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @instance + * @returns {Object.} JSON object + */ + ExportErrorsConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportErrorsConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ExportErrorsConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportErrorsConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ExportErrorsConfig"; + }; + + return ExportErrorsConfig; + })(); + + v2beta.ExportMetadata = (function() { + + /** + * Properties of an ExportMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IExportMetadata + * @property {google.protobuf.ITimestamp|null} [createTime] ExportMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ExportMetadata updateTime + */ + + /** + * Constructs a new ExportMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ExportMetadata. + * @implements IExportMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IExportMetadata=} [properties] Properties to set + */ + function ExportMetadata(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]]; + } + + /** + * ExportMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @instance + */ + ExportMetadata.prototype.createTime = null; + + /** + * ExportMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @instance + */ + ExportMetadata.prototype.updateTime = null; + + /** + * Creates a new ExportMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {google.cloud.retail.v2beta.IExportMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ExportMetadata} ExportMetadata instance + */ + ExportMetadata.create = function create(properties) { + return new ExportMetadata(properties); + }; + + /** + * Encodes the specified ExportMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.ExportMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {google.cloud.retail.v2beta.IExportMetadata} message ExportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {google.cloud.retail.v2beta.IExportMetadata} message ExportMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ExportMetadata} ExportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportMetadata.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.cloud.retail.v2beta.ExportMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ExportMetadata} ExportMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object 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; + } + return null; + }; + + /** + * Creates an ExportMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ExportMetadata} ExportMetadata + */ + ExportMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ExportMetadata) + return object; + var message = new $root.google.cloud.retail.v2beta.ExportMetadata(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + return message; + }; + + /** + * Creates a plain object from an ExportMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {google.cloud.retail.v2beta.ExportMetadata} message ExportMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.createTime = null; + object.updateTime = null; + } + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + return object; + }; + + /** + * Converts this ExportMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @instance + * @returns {Object.} JSON object + */ + ExportMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ExportMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ExportMetadata"; + }; + + return ExportMetadata; + })(); + + v2beta.ExportProductsResponse = (function() { + + /** + * Properties of an ExportProductsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IExportProductsResponse + * @property {Array.|null} [errorSamples] ExportProductsResponse errorSamples + * @property {google.cloud.retail.v2beta.IExportErrorsConfig|null} [errorsConfig] ExportProductsResponse errorsConfig + * @property {google.cloud.retail.v2beta.IOutputResult|null} [outputResult] ExportProductsResponse outputResult + */ + + /** + * Constructs a new ExportProductsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ExportProductsResponse. + * @implements IExportProductsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IExportProductsResponse=} [properties] Properties to set + */ + function ExportProductsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ExportProductsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ExportProductsResponse errorsConfig. + * @member {google.cloud.retail.v2beta.IExportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.errorsConfig = null; + + /** + * ExportProductsResponse outputResult. + * @member {google.cloud.retail.v2beta.IOutputResult|null|undefined} outputResult + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @instance + */ + ExportProductsResponse.prototype.outputResult = null; + + /** + * Creates a new ExportProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ExportProductsResponse} ExportProductsResponse instance + */ + ExportProductsResponse.create = function create(properties) { + return new ExportProductsResponse(properties); + }; + + /** + * Encodes the specified ExportProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ExportProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportProductsResponse} message ExportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ExportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.outputResult != null && Object.hasOwnProperty.call(message, "outputResult")) + $root.google.cloud.retail.v2beta.OutputResult.encode(message.outputResult, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportProductsResponse} message ExportProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ExportProductsResponse} ExportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportProductsResponse.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.cloud.retail.v2beta.ExportProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.outputResult = $root.google.cloud.retail.v2beta.OutputResult.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ExportProductsResponse} ExportProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ExportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.outputResult != null && message.hasOwnProperty("outputResult")) { + var error = $root.google.cloud.retail.v2beta.OutputResult.verify(message.outputResult); + if (error) + return "outputResult." + error; + } + return null; + }; + + /** + * Creates an ExportProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ExportProductsResponse} ExportProductsResponse + */ + ExportProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ExportProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ExportProductsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2beta.ExportProductsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportProductsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportProductsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.outputResult != null) { + if (typeof object.outputResult !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportProductsResponse.outputResult: object expected"); + message.outputResult = $root.google.cloud.retail.v2beta.OutputResult.fromObject(object.outputResult); + } + return message; + }; + + /** + * Creates a plain object from an ExportProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {google.cloud.retail.v2beta.ExportProductsResponse} message ExportProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.outputResult = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.toObject(message.errorsConfig, options); + if (message.outputResult != null && message.hasOwnProperty("outputResult")) + object.outputResult = $root.google.cloud.retail.v2beta.OutputResult.toObject(message.outputResult, options); + return object; + }; + + /** + * Converts this ExportProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ExportProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ExportProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ExportProductsResponse"; + }; + + return ExportProductsResponse; + })(); + + v2beta.ExportUserEventsResponse = (function() { + + /** + * Properties of an ExportUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IExportUserEventsResponse + * @property {Array.|null} [errorSamples] ExportUserEventsResponse errorSamples + * @property {google.cloud.retail.v2beta.IExportErrorsConfig|null} [errorsConfig] ExportUserEventsResponse errorsConfig + * @property {google.cloud.retail.v2beta.IOutputResult|null} [outputResult] ExportUserEventsResponse outputResult + */ + + /** + * Constructs a new ExportUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an ExportUserEventsResponse. + * @implements IExportUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IExportUserEventsResponse=} [properties] Properties to set + */ + function ExportUserEventsResponse(properties) { + this.errorSamples = []; + 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]]; + } + + /** + * ExportUserEventsResponse errorSamples. + * @member {Array.} errorSamples + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.errorSamples = $util.emptyArray; + + /** + * ExportUserEventsResponse errorsConfig. + * @member {google.cloud.retail.v2beta.IExportErrorsConfig|null|undefined} errorsConfig + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.errorsConfig = null; + + /** + * ExportUserEventsResponse outputResult. + * @member {google.cloud.retail.v2beta.IOutputResult|null|undefined} outputResult + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @instance + */ + ExportUserEventsResponse.prototype.outputResult = null; + + /** + * Creates a new ExportUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ExportUserEventsResponse} ExportUserEventsResponse instance + */ + ExportUserEventsResponse.create = function create(properties) { + return new ExportUserEventsResponse(properties); + }; + + /** + * Encodes the specified ExportUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ExportUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportUserEventsResponse} message ExportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.errorSamples != null && message.errorSamples.length) + for (var i = 0; i < message.errorSamples.length; ++i) + $root.google.rpc.Status.encode(message.errorSamples[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.errorsConfig != null && Object.hasOwnProperty.call(message, "errorsConfig")) + $root.google.cloud.retail.v2beta.ExportErrorsConfig.encode(message.errorsConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.outputResult != null && Object.hasOwnProperty.call(message, "outputResult")) + $root.google.cloud.retail.v2beta.OutputResult.encode(message.outputResult, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExportUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ExportUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IExportUserEventsResponse} message ExportUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ExportUserEventsResponse} ExportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportUserEventsResponse.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.cloud.retail.v2beta.ExportUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.errorSamples && message.errorSamples.length)) + message.errorSamples = []; + message.errorSamples.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + message.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.outputResult = $root.google.cloud.retail.v2beta.OutputResult.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ExportUserEventsResponse} ExportUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.errorSamples != null && message.hasOwnProperty("errorSamples")) { + if (!Array.isArray(message.errorSamples)) + return "errorSamples: array expected"; + for (var i = 0; i < message.errorSamples.length; ++i) { + var error = $root.google.rpc.Status.verify(message.errorSamples[i]); + if (error) + return "errorSamples." + error; + } + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) { + var error = $root.google.cloud.retail.v2beta.ExportErrorsConfig.verify(message.errorsConfig); + if (error) + return "errorsConfig." + error; + } + if (message.outputResult != null && message.hasOwnProperty("outputResult")) { + var error = $root.google.cloud.retail.v2beta.OutputResult.verify(message.outputResult); + if (error) + return "outputResult." + error; + } + return null; + }; + + /** + * Creates an ExportUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ExportUserEventsResponse} ExportUserEventsResponse + */ + ExportUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ExportUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ExportUserEventsResponse(); + if (object.errorSamples) { + if (!Array.isArray(object.errorSamples)) + throw TypeError(".google.cloud.retail.v2beta.ExportUserEventsResponse.errorSamples: array expected"); + message.errorSamples = []; + for (var i = 0; i < object.errorSamples.length; ++i) { + if (typeof object.errorSamples[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportUserEventsResponse.errorSamples: object expected"); + message.errorSamples[i] = $root.google.rpc.Status.fromObject(object.errorSamples[i]); + } + } + if (object.errorsConfig != null) { + if (typeof object.errorsConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportUserEventsResponse.errorsConfig: object expected"); + message.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.fromObject(object.errorsConfig); + } + if (object.outputResult != null) { + if (typeof object.outputResult !== "object") + throw TypeError(".google.cloud.retail.v2beta.ExportUserEventsResponse.outputResult: object expected"); + message.outputResult = $root.google.cloud.retail.v2beta.OutputResult.fromObject(object.outputResult); + } + return message; + }; + + /** + * Creates a plain object from an ExportUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.ExportUserEventsResponse} message ExportUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportUserEventsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.errorSamples = []; + if (options.defaults) { + object.errorsConfig = null; + object.outputResult = null; + } + if (message.errorSamples && message.errorSamples.length) { + object.errorSamples = []; + for (var j = 0; j < message.errorSamples.length; ++j) + object.errorSamples[j] = $root.google.rpc.Status.toObject(message.errorSamples[j], options); + } + if (message.errorsConfig != null && message.hasOwnProperty("errorsConfig")) + object.errorsConfig = $root.google.cloud.retail.v2beta.ExportErrorsConfig.toObject(message.errorsConfig, options); + if (message.outputResult != null && message.hasOwnProperty("outputResult")) + object.outputResult = $root.google.cloud.retail.v2beta.OutputResult.toObject(message.outputResult, options); + return object; + }; + + /** + * Converts this ExportUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + ExportUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ExportUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ExportUserEventsResponse"; + }; + + return ExportUserEventsResponse; + })(); + + v2beta.OutputResult = (function() { + + /** + * Properties of an OutputResult. + * @memberof google.cloud.retail.v2beta + * @interface IOutputResult + * @property {Array.|null} [bigqueryResult] OutputResult bigqueryResult + */ + + /** + * Constructs a new OutputResult. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an OutputResult. + * @implements IOutputResult + * @constructor + * @param {google.cloud.retail.v2beta.IOutputResult=} [properties] Properties to set + */ + function OutputResult(properties) { + this.bigqueryResult = []; + 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]]; + } + + /** + * OutputResult bigqueryResult. + * @member {Array.} bigqueryResult + * @memberof google.cloud.retail.v2beta.OutputResult + * @instance + */ + OutputResult.prototype.bigqueryResult = $util.emptyArray; + + /** + * Creates a new OutputResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {google.cloud.retail.v2beta.IOutputResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.OutputResult} OutputResult instance + */ + OutputResult.create = function create(properties) { + return new OutputResult(properties); + }; + + /** + * Encodes the specified OutputResult message. Does not implicitly {@link google.cloud.retail.v2beta.OutputResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {google.cloud.retail.v2beta.IOutputResult} message OutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.bigqueryResult != null && message.bigqueryResult.length) + for (var i = 0; i < message.bigqueryResult.length; ++i) + $root.google.cloud.retail.v2beta.BigQueryOutputResult.encode(message.bigqueryResult[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.OutputResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {google.cloud.retail.v2beta.IOutputResult} message OutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OutputResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.OutputResult} OutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputResult.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.cloud.retail.v2beta.OutputResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.bigqueryResult && message.bigqueryResult.length)) + message.bigqueryResult = []; + message.bigqueryResult.push($root.google.cloud.retail.v2beta.BigQueryOutputResult.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OutputResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.OutputResult} OutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OutputResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OutputResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.bigqueryResult != null && message.hasOwnProperty("bigqueryResult")) { + if (!Array.isArray(message.bigqueryResult)) + return "bigqueryResult: array expected"; + for (var i = 0; i < message.bigqueryResult.length; ++i) { + var error = $root.google.cloud.retail.v2beta.BigQueryOutputResult.verify(message.bigqueryResult[i]); + if (error) + return "bigqueryResult." + error; + } + } + return null; + }; + + /** + * Creates an OutputResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.OutputResult} OutputResult + */ + OutputResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.OutputResult) + return object; + var message = new $root.google.cloud.retail.v2beta.OutputResult(); + if (object.bigqueryResult) { + if (!Array.isArray(object.bigqueryResult)) + throw TypeError(".google.cloud.retail.v2beta.OutputResult.bigqueryResult: array expected"); + message.bigqueryResult = []; + for (var i = 0; i < object.bigqueryResult.length; ++i) { + if (typeof object.bigqueryResult[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.OutputResult.bigqueryResult: object expected"); + message.bigqueryResult[i] = $root.google.cloud.retail.v2beta.BigQueryOutputResult.fromObject(object.bigqueryResult[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OutputResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {google.cloud.retail.v2beta.OutputResult} message OutputResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OutputResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.bigqueryResult = []; + if (message.bigqueryResult && message.bigqueryResult.length) { + object.bigqueryResult = []; + for (var j = 0; j < message.bigqueryResult.length; ++j) + object.bigqueryResult[j] = $root.google.cloud.retail.v2beta.BigQueryOutputResult.toObject(message.bigqueryResult[j], options); + } + return object; + }; + + /** + * Converts this OutputResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.OutputResult + * @instance + * @returns {Object.} JSON object + */ + OutputResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OutputResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.OutputResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OutputResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.OutputResult"; + }; + + return OutputResult; + })(); + + v2beta.BigQueryOutputResult = (function() { + + /** + * Properties of a BigQueryOutputResult. + * @memberof google.cloud.retail.v2beta + * @interface IBigQueryOutputResult + * @property {string|null} [datasetId] BigQueryOutputResult datasetId + * @property {string|null} [tableId] BigQueryOutputResult tableId + */ + + /** + * Constructs a new BigQueryOutputResult. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a BigQueryOutputResult. + * @implements IBigQueryOutputResult + * @constructor + * @param {google.cloud.retail.v2beta.IBigQueryOutputResult=} [properties] Properties to set + */ + function BigQueryOutputResult(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]]; + } + + /** + * BigQueryOutputResult datasetId. + * @member {string} datasetId + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @instance + */ + BigQueryOutputResult.prototype.datasetId = ""; + + /** + * BigQueryOutputResult tableId. + * @member {string} tableId + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @instance + */ + BigQueryOutputResult.prototype.tableId = ""; + + /** + * Creates a new BigQueryOutputResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2beta.IBigQueryOutputResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.BigQueryOutputResult} BigQueryOutputResult instance + */ + BigQueryOutputResult.create = function create(properties) { + return new BigQueryOutputResult(properties); + }; + + /** + * Encodes the specified BigQueryOutputResult message. Does not implicitly {@link google.cloud.retail.v2beta.BigQueryOutputResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2beta.IBigQueryOutputResult} message BigQueryOutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOutputResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.datasetId != null && Object.hasOwnProperty.call(message, "datasetId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.datasetId); + if (message.tableId != null && Object.hasOwnProperty.call(message, "tableId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.tableId); + return writer; + }; + + /** + * Encodes the specified BigQueryOutputResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.BigQueryOutputResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2beta.IBigQueryOutputResult} message BigQueryOutputResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOutputResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.BigQueryOutputResult} BigQueryOutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOutputResult.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.cloud.retail.v2beta.BigQueryOutputResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.datasetId = reader.string(); + break; + } + case 2: { + message.tableId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BigQueryOutputResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.BigQueryOutputResult} BigQueryOutputResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOutputResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BigQueryOutputResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQueryOutputResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + if (!$util.isString(message.datasetId)) + return "datasetId: string expected"; + if (message.tableId != null && message.hasOwnProperty("tableId")) + if (!$util.isString(message.tableId)) + return "tableId: string expected"; + return null; + }; + + /** + * Creates a BigQueryOutputResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.BigQueryOutputResult} BigQueryOutputResult + */ + BigQueryOutputResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.BigQueryOutputResult) + return object; + var message = new $root.google.cloud.retail.v2beta.BigQueryOutputResult(); + if (object.datasetId != null) + message.datasetId = String(object.datasetId); + if (object.tableId != null) + message.tableId = String(object.tableId); + return message; + }; + + /** + * Creates a plain object from a BigQueryOutputResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {google.cloud.retail.v2beta.BigQueryOutputResult} message BigQueryOutputResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQueryOutputResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.datasetId = ""; + object.tableId = ""; + } + if (message.datasetId != null && message.hasOwnProperty("datasetId")) + object.datasetId = message.datasetId; + if (message.tableId != null && message.hasOwnProperty("tableId")) + object.tableId = message.tableId; + return object; + }; + + /** + * Converts this BigQueryOutputResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @instance + * @returns {Object.} JSON object + */ + BigQueryOutputResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BigQueryOutputResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.BigQueryOutputResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BigQueryOutputResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.BigQueryOutputResult"; + }; + + return BigQueryOutputResult; + })(); + + v2beta.Model = (function() { + + /** + * Properties of a Model. + * @memberof google.cloud.retail.v2beta + * @interface IModel + * @property {string|null} [name] Model name + * @property {string|null} [displayName] Model displayName + * @property {google.cloud.retail.v2beta.Model.TrainingState|null} [trainingState] Model trainingState + * @property {google.cloud.retail.v2beta.Model.ServingState|null} [servingState] Model servingState + * @property {google.protobuf.ITimestamp|null} [createTime] Model createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] Model updateTime + * @property {string|null} [type] Model type + * @property {string|null} [optimizationObjective] Model optimizationObjective + * @property {google.cloud.retail.v2beta.Model.PeriodicTuningState|null} [periodicTuningState] Model periodicTuningState + * @property {google.protobuf.ITimestamp|null} [lastTuneTime] Model lastTuneTime + * @property {string|null} [tuningOperation] Model tuningOperation + * @property {google.cloud.retail.v2beta.Model.DataState|null} [dataState] Model dataState + * @property {google.cloud.retail.v2beta.RecommendationsFilteringOption|null} [filteringOption] Model filteringOption + * @property {Array.|null} [servingConfigLists] Model servingConfigLists + */ + + /** + * Constructs a new Model. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a Model. + * @implements IModel + * @constructor + * @param {google.cloud.retail.v2beta.IModel=} [properties] Properties to set + */ + function Model(properties) { + this.servingConfigLists = []; + 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]]; + } + + /** + * Model name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.name = ""; + + /** + * Model displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.displayName = ""; + + /** + * Model trainingState. + * @member {google.cloud.retail.v2beta.Model.TrainingState} trainingState + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.trainingState = 0; + + /** + * Model servingState. + * @member {google.cloud.retail.v2beta.Model.ServingState} servingState + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.servingState = 0; + + /** + * Model createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.createTime = null; + + /** + * Model updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.updateTime = null; + + /** + * Model type. + * @member {string} type + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.type = ""; + + /** + * Model optimizationObjective. + * @member {string} optimizationObjective + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.optimizationObjective = ""; + + /** + * Model periodicTuningState. + * @member {google.cloud.retail.v2beta.Model.PeriodicTuningState} periodicTuningState + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.periodicTuningState = 0; + + /** + * Model lastTuneTime. + * @member {google.protobuf.ITimestamp|null|undefined} lastTuneTime + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.lastTuneTime = null; + + /** + * Model tuningOperation. + * @member {string} tuningOperation + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.tuningOperation = ""; + + /** + * Model dataState. + * @member {google.cloud.retail.v2beta.Model.DataState} dataState + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.dataState = 0; + + /** + * Model filteringOption. + * @member {google.cloud.retail.v2beta.RecommendationsFilteringOption} filteringOption + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.filteringOption = 0; + + /** + * Model servingConfigLists. + * @member {Array.} servingConfigLists + * @memberof google.cloud.retail.v2beta.Model + * @instance + */ + Model.prototype.servingConfigLists = $util.emptyArray; + + /** + * Creates a new Model instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {google.cloud.retail.v2beta.IModel=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Model} Model instance + */ + Model.create = function create(properties) { + return new Model(properties); + }; + + /** + * Encodes the specified Model message. Does not implicitly {@link google.cloud.retail.v2beta.Model.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {google.cloud.retail.v2beta.IModel} message Model message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Model.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.trainingState != null && Object.hasOwnProperty.call(message, "trainingState")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.trainingState); + if (message.servingState != null && Object.hasOwnProperty.call(message, "servingState")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.servingState); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + 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.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.type); + if (message.optimizationObjective != null && Object.hasOwnProperty.call(message, "optimizationObjective")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.optimizationObjective); + if (message.periodicTuningState != null && Object.hasOwnProperty.call(message, "periodicTuningState")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.periodicTuningState); + if (message.lastTuneTime != null && Object.hasOwnProperty.call(message, "lastTuneTime")) + $root.google.protobuf.Timestamp.encode(message.lastTuneTime, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.tuningOperation != null && Object.hasOwnProperty.call(message, "tuningOperation")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.tuningOperation); + if (message.dataState != null && Object.hasOwnProperty.call(message, "dataState")) + writer.uint32(/* id 16, wireType 0 =*/128).int32(message.dataState); + if (message.filteringOption != null && Object.hasOwnProperty.call(message, "filteringOption")) + writer.uint32(/* id 18, wireType 0 =*/144).int32(message.filteringOption); + if (message.servingConfigLists != null && message.servingConfigLists.length) + for (var i = 0; i < message.servingConfigLists.length; ++i) + $root.google.cloud.retail.v2beta.Model.ServingConfigList.encode(message.servingConfigLists[i], writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Model message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Model.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {google.cloud.retail.v2beta.IModel} message Model message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Model.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Model message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Model} Model + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Model.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.cloud.retail.v2beta.Model(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 3: { + message.trainingState = reader.int32(); + break; + } + case 4: { + message.servingState = reader.int32(); + break; + } + case 5: { + 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 7: { + message.type = reader.string(); + break; + } + case 8: { + message.optimizationObjective = reader.string(); + break; + } + case 11: { + message.periodicTuningState = reader.int32(); + break; + } + case 12: { + message.lastTuneTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 15: { + message.tuningOperation = reader.string(); + break; + } + case 16: { + message.dataState = reader.int32(); + break; + } + case 18: { + message.filteringOption = reader.int32(); + break; + } + case 19: { + if (!(message.servingConfigLists && message.servingConfigLists.length)) + message.servingConfigLists = []; + message.servingConfigLists.push($root.google.cloud.retail.v2beta.Model.ServingConfigList.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Model message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Model} Model + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Model.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Model message. + * @function verify + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Model.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.trainingState != null && message.hasOwnProperty("trainingState")) + switch (message.trainingState) { + default: + return "trainingState: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.servingState != null && message.hasOwnProperty("servingState")) + switch (message.servingState) { + default: + return "servingState: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + 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.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.optimizationObjective != null && message.hasOwnProperty("optimizationObjective")) + if (!$util.isString(message.optimizationObjective)) + return "optimizationObjective: string expected"; + if (message.periodicTuningState != null && message.hasOwnProperty("periodicTuningState")) + switch (message.periodicTuningState) { + default: + return "periodicTuningState: enum value expected"; + case 0: + case 1: + case 3: + case 2: + break; + } + if (message.lastTuneTime != null && message.hasOwnProperty("lastTuneTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.lastTuneTime); + if (error) + return "lastTuneTime." + error; + } + if (message.tuningOperation != null && message.hasOwnProperty("tuningOperation")) + if (!$util.isString(message.tuningOperation)) + return "tuningOperation: string expected"; + if (message.dataState != null && message.hasOwnProperty("dataState")) + switch (message.dataState) { + default: + return "dataState: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.filteringOption != null && message.hasOwnProperty("filteringOption")) + switch (message.filteringOption) { + default: + return "filteringOption: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.servingConfigLists != null && message.hasOwnProperty("servingConfigLists")) { + if (!Array.isArray(message.servingConfigLists)) + return "servingConfigLists: array expected"; + for (var i = 0; i < message.servingConfigLists.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Model.ServingConfigList.verify(message.servingConfigLists[i]); + if (error) + return "servingConfigLists." + error; + } + } + return null; + }; + + /** + * Creates a Model message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Model} Model + */ + Model.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Model) + return object; + var message = new $root.google.cloud.retail.v2beta.Model(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + switch (object.trainingState) { + default: + if (typeof object.trainingState === "number") { + message.trainingState = object.trainingState; + break; + } + break; + case "TRAINING_STATE_UNSPECIFIED": + case 0: + message.trainingState = 0; + break; + case "PAUSED": + case 1: + message.trainingState = 1; + break; + case "TRAINING": + case 2: + message.trainingState = 2; + break; + } + switch (object.servingState) { + default: + if (typeof object.servingState === "number") { + message.servingState = object.servingState; + break; + } + break; + case "SERVING_STATE_UNSPECIFIED": + case 0: + message.servingState = 0; + break; + case "INACTIVE": + case 1: + message.servingState = 1; + break; + case "ACTIVE": + case 2: + message.servingState = 2; + break; + case "TUNED": + case 3: + message.servingState = 3; + break; + } + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Model.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Model.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.type != null) + message.type = String(object.type); + if (object.optimizationObjective != null) + message.optimizationObjective = String(object.optimizationObjective); + switch (object.periodicTuningState) { + default: + if (typeof object.periodicTuningState === "number") { + message.periodicTuningState = object.periodicTuningState; + break; + } + break; + case "PERIODIC_TUNING_STATE_UNSPECIFIED": + case 0: + message.periodicTuningState = 0; + break; + case "PERIODIC_TUNING_DISABLED": + case 1: + message.periodicTuningState = 1; + break; + case "ALL_TUNING_DISABLED": + case 3: + message.periodicTuningState = 3; + break; + case "PERIODIC_TUNING_ENABLED": + case 2: + message.periodicTuningState = 2; + break; + } + if (object.lastTuneTime != null) { + if (typeof object.lastTuneTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.Model.lastTuneTime: object expected"); + message.lastTuneTime = $root.google.protobuf.Timestamp.fromObject(object.lastTuneTime); + } + if (object.tuningOperation != null) + message.tuningOperation = String(object.tuningOperation); + switch (object.dataState) { + default: + if (typeof object.dataState === "number") { + message.dataState = object.dataState; + break; + } + break; + case "DATA_STATE_UNSPECIFIED": + case 0: + message.dataState = 0; + break; + case "DATA_OK": + case 1: + message.dataState = 1; + break; + case "DATA_ERROR": + case 2: + message.dataState = 2; + break; + } + switch (object.filteringOption) { + default: + if (typeof object.filteringOption === "number") { + message.filteringOption = object.filteringOption; + break; + } + break; + case "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": + case 0: + message.filteringOption = 0; + break; + case "RECOMMENDATIONS_FILTERING_DISABLED": + case 1: + message.filteringOption = 1; + break; + case "RECOMMENDATIONS_FILTERING_ENABLED": + case 3: + message.filteringOption = 3; + break; + } + if (object.servingConfigLists) { + if (!Array.isArray(object.servingConfigLists)) + throw TypeError(".google.cloud.retail.v2beta.Model.servingConfigLists: array expected"); + message.servingConfigLists = []; + for (var i = 0; i < object.servingConfigLists.length; ++i) { + if (typeof object.servingConfigLists[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.Model.servingConfigLists: object expected"); + message.servingConfigLists[i] = $root.google.cloud.retail.v2beta.Model.ServingConfigList.fromObject(object.servingConfigLists[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Model message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {google.cloud.retail.v2beta.Model} message Model + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Model.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigLists = []; + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.trainingState = options.enums === String ? "TRAINING_STATE_UNSPECIFIED" : 0; + object.servingState = options.enums === String ? "SERVING_STATE_UNSPECIFIED" : 0; + object.createTime = null; + object.updateTime = null; + object.type = ""; + object.optimizationObjective = ""; + object.periodicTuningState = options.enums === String ? "PERIODIC_TUNING_STATE_UNSPECIFIED" : 0; + object.lastTuneTime = null; + object.tuningOperation = ""; + object.dataState = options.enums === String ? "DATA_STATE_UNSPECIFIED" : 0; + object.filteringOption = options.enums === String ? "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.trainingState != null && message.hasOwnProperty("trainingState")) + object.trainingState = options.enums === String ? $root.google.cloud.retail.v2beta.Model.TrainingState[message.trainingState] === undefined ? message.trainingState : $root.google.cloud.retail.v2beta.Model.TrainingState[message.trainingState] : message.trainingState; + if (message.servingState != null && message.hasOwnProperty("servingState")) + object.servingState = options.enums === String ? $root.google.cloud.retail.v2beta.Model.ServingState[message.servingState] === undefined ? message.servingState : $root.google.cloud.retail.v2beta.Model.ServingState[message.servingState] : message.servingState; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.optimizationObjective != null && message.hasOwnProperty("optimizationObjective")) + object.optimizationObjective = message.optimizationObjective; + if (message.periodicTuningState != null && message.hasOwnProperty("periodicTuningState")) + object.periodicTuningState = options.enums === String ? $root.google.cloud.retail.v2beta.Model.PeriodicTuningState[message.periodicTuningState] === undefined ? message.periodicTuningState : $root.google.cloud.retail.v2beta.Model.PeriodicTuningState[message.periodicTuningState] : message.periodicTuningState; + if (message.lastTuneTime != null && message.hasOwnProperty("lastTuneTime")) + object.lastTuneTime = $root.google.protobuf.Timestamp.toObject(message.lastTuneTime, options); + if (message.tuningOperation != null && message.hasOwnProperty("tuningOperation")) + object.tuningOperation = message.tuningOperation; + if (message.dataState != null && message.hasOwnProperty("dataState")) + object.dataState = options.enums === String ? $root.google.cloud.retail.v2beta.Model.DataState[message.dataState] === undefined ? message.dataState : $root.google.cloud.retail.v2beta.Model.DataState[message.dataState] : message.dataState; + if (message.filteringOption != null && message.hasOwnProperty("filteringOption")) + object.filteringOption = options.enums === String ? $root.google.cloud.retail.v2beta.RecommendationsFilteringOption[message.filteringOption] === undefined ? message.filteringOption : $root.google.cloud.retail.v2beta.RecommendationsFilteringOption[message.filteringOption] : message.filteringOption; + if (message.servingConfigLists && message.servingConfigLists.length) { + object.servingConfigLists = []; + for (var j = 0; j < message.servingConfigLists.length; ++j) + object.servingConfigLists[j] = $root.google.cloud.retail.v2beta.Model.ServingConfigList.toObject(message.servingConfigLists[j], options); + } + return object; + }; + + /** + * Converts this Model to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Model + * @instance + * @returns {Object.} JSON object + */ + Model.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Model + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Model + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Model.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Model"; + }; + + Model.ServingConfigList = (function() { + + /** + * Properties of a ServingConfigList. + * @memberof google.cloud.retail.v2beta.Model + * @interface IServingConfigList + * @property {Array.|null} [servingConfigIds] ServingConfigList servingConfigIds + */ + + /** + * Constructs a new ServingConfigList. + * @memberof google.cloud.retail.v2beta.Model + * @classdesc Represents a ServingConfigList. + * @implements IServingConfigList + * @constructor + * @param {google.cloud.retail.v2beta.Model.IServingConfigList=} [properties] Properties to set + */ + function ServingConfigList(properties) { + this.servingConfigIds = []; + 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]]; + } + + /** + * ServingConfigList servingConfigIds. + * @member {Array.} servingConfigIds + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @instance + */ + ServingConfigList.prototype.servingConfigIds = $util.emptyArray; + + /** + * Creates a new ServingConfigList instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2beta.Model.IServingConfigList=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.Model.ServingConfigList} ServingConfigList instance + */ + ServingConfigList.create = function create(properties) { + return new ServingConfigList(properties); + }; + + /** + * Encodes the specified ServingConfigList message. Does not implicitly {@link google.cloud.retail.v2beta.Model.ServingConfigList.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2beta.Model.IServingConfigList} message ServingConfigList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfigList.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigIds != null && message.servingConfigIds.length) + for (var i = 0; i < message.servingConfigIds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfigIds[i]); + return writer; + }; + + /** + * Encodes the specified ServingConfigList message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.Model.ServingConfigList.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2beta.Model.IServingConfigList} message ServingConfigList message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfigList.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.Model.ServingConfigList} ServingConfigList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfigList.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.cloud.retail.v2beta.Model.ServingConfigList(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.servingConfigIds && message.servingConfigIds.length)) + message.servingConfigIds = []; + message.servingConfigIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServingConfigList message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.Model.ServingConfigList} ServingConfigList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfigList.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServingConfigList message. + * @function verify + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServingConfigList.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfigIds != null && message.hasOwnProperty("servingConfigIds")) { + if (!Array.isArray(message.servingConfigIds)) + return "servingConfigIds: array expected"; + for (var i = 0; i < message.servingConfigIds.length; ++i) + if (!$util.isString(message.servingConfigIds[i])) + return "servingConfigIds: string[] expected"; + } + return null; + }; + + /** + * Creates a ServingConfigList message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.Model.ServingConfigList} ServingConfigList + */ + ServingConfigList.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.Model.ServingConfigList) + return object; + var message = new $root.google.cloud.retail.v2beta.Model.ServingConfigList(); + if (object.servingConfigIds) { + if (!Array.isArray(object.servingConfigIds)) + throw TypeError(".google.cloud.retail.v2beta.Model.ServingConfigList.servingConfigIds: array expected"); + message.servingConfigIds = []; + for (var i = 0; i < object.servingConfigIds.length; ++i) + message.servingConfigIds[i] = String(object.servingConfigIds[i]); + } + return message; + }; + + /** + * Creates a plain object from a ServingConfigList message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {google.cloud.retail.v2beta.Model.ServingConfigList} message ServingConfigList + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServingConfigList.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigIds = []; + if (message.servingConfigIds && message.servingConfigIds.length) { + object.servingConfigIds = []; + for (var j = 0; j < message.servingConfigIds.length; ++j) + object.servingConfigIds[j] = message.servingConfigIds[j]; + } + return object; + }; + + /** + * Converts this ServingConfigList to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @instance + * @returns {Object.} JSON object + */ + ServingConfigList.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServingConfigList + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.Model.ServingConfigList + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServingConfigList.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.Model.ServingConfigList"; + }; + + return ServingConfigList; + })(); + + /** + * ServingState enum. + * @name google.cloud.retail.v2beta.Model.ServingState + * @enum {number} + * @property {number} SERVING_STATE_UNSPECIFIED=0 SERVING_STATE_UNSPECIFIED value + * @property {number} INACTIVE=1 INACTIVE value + * @property {number} ACTIVE=2 ACTIVE value + * @property {number} TUNED=3 TUNED value + */ + Model.ServingState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INACTIVE"] = 1; + values[valuesById[2] = "ACTIVE"] = 2; + values[valuesById[3] = "TUNED"] = 3; + return values; + })(); + + /** + * TrainingState enum. + * @name google.cloud.retail.v2beta.Model.TrainingState + * @enum {number} + * @property {number} TRAINING_STATE_UNSPECIFIED=0 TRAINING_STATE_UNSPECIFIED value + * @property {number} PAUSED=1 PAUSED value + * @property {number} TRAINING=2 TRAINING value + */ + Model.TrainingState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TRAINING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PAUSED"] = 1; + values[valuesById[2] = "TRAINING"] = 2; + return values; + })(); + + /** + * PeriodicTuningState enum. + * @name google.cloud.retail.v2beta.Model.PeriodicTuningState + * @enum {number} + * @property {number} PERIODIC_TUNING_STATE_UNSPECIFIED=0 PERIODIC_TUNING_STATE_UNSPECIFIED value + * @property {number} PERIODIC_TUNING_DISABLED=1 PERIODIC_TUNING_DISABLED value + * @property {number} ALL_TUNING_DISABLED=3 ALL_TUNING_DISABLED value + * @property {number} PERIODIC_TUNING_ENABLED=2 PERIODIC_TUNING_ENABLED value + */ + Model.PeriodicTuningState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "PERIODIC_TUNING_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PERIODIC_TUNING_DISABLED"] = 1; + values[valuesById[3] = "ALL_TUNING_DISABLED"] = 3; + values[valuesById[2] = "PERIODIC_TUNING_ENABLED"] = 2; + return values; + })(); + + /** + * DataState enum. + * @name google.cloud.retail.v2beta.Model.DataState + * @enum {number} + * @property {number} DATA_STATE_UNSPECIFIED=0 DATA_STATE_UNSPECIFIED value + * @property {number} DATA_OK=1 DATA_OK value + * @property {number} DATA_ERROR=2 DATA_ERROR value + */ + Model.DataState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DATA_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DATA_OK"] = 1; + values[valuesById[2] = "DATA_ERROR"] = 2; + return values; + })(); + + return Model; + })(); + + v2beta.ModelService = (function() { + + /** + * Constructs a new ModelService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ModelService + * @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 ModelService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ModelService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ModelService; + + /** + * Creates new ModelService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.ModelService + * @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 {ModelService} RPC service. Useful where requests and/or responses are streamed. + */ + ModelService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|createModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef CreateModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateModel. + * @function createModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.ICreateModelRequest} request CreateModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.CreateModelCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.createModel = function createModel(request, callback) { + return this.rpcCall(createModel, $root.google.cloud.retail.v2beta.CreateModelRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateModel" }); + + /** + * Calls CreateModel. + * @function createModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.ICreateModelRequest} request CreateModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|pauseModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef PauseModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Model} [response] Model + */ + + /** + * Calls PauseModel. + * @function pauseModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IPauseModelRequest} request PauseModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.PauseModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.pauseModel = function pauseModel(request, callback) { + return this.rpcCall(pauseModel, $root.google.cloud.retail.v2beta.PauseModelRequest, $root.google.cloud.retail.v2beta.Model, request, callback); + }, "name", { value: "PauseModel" }); + + /** + * Calls PauseModel. + * @function pauseModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IPauseModelRequest} request PauseModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|resumeModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef ResumeModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Model} [response] Model + */ + + /** + * Calls ResumeModel. + * @function resumeModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IResumeModelRequest} request ResumeModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.ResumeModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.resumeModel = function resumeModel(request, callback) { + return this.rpcCall(resumeModel, $root.google.cloud.retail.v2beta.ResumeModelRequest, $root.google.cloud.retail.v2beta.Model, request, callback); + }, "name", { value: "ResumeModel" }); + + /** + * Calls ResumeModel. + * @function resumeModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IResumeModelRequest} request ResumeModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|deleteModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef DeleteModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteModel. + * @function deleteModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteModelRequest} request DeleteModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.DeleteModelCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.deleteModel = function deleteModel(request, callback) { + return this.rpcCall(deleteModel, $root.google.cloud.retail.v2beta.DeleteModelRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteModel" }); + + /** + * Calls DeleteModel. + * @function deleteModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteModelRequest} request DeleteModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|listModels}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef ListModelsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ListModelsResponse} [response] ListModelsResponse + */ + + /** + * Calls ListModels. + * @function listModels + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IListModelsRequest} request ListModelsRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.ListModelsCallback} callback Node-style callback called with the error, if any, and ListModelsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.listModels = function listModels(request, callback) { + return this.rpcCall(listModels, $root.google.cloud.retail.v2beta.ListModelsRequest, $root.google.cloud.retail.v2beta.ListModelsResponse, request, callback); + }, "name", { value: "ListModels" }); + + /** + * Calls ListModels. + * @function listModels + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IListModelsRequest} request ListModelsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|updateModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef UpdateModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Model} [response] Model + */ + + /** + * Calls UpdateModel. + * @function updateModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateModelRequest} request UpdateModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.UpdateModelCallback} callback Node-style callback called with the error, if any, and Model + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.updateModel = function updateModel(request, callback) { + return this.rpcCall(updateModel, $root.google.cloud.retail.v2beta.UpdateModelRequest, $root.google.cloud.retail.v2beta.Model, request, callback); + }, "name", { value: "UpdateModel" }); + + /** + * Calls UpdateModel. + * @function updateModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateModelRequest} request UpdateModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ModelService|tuneModel}. + * @memberof google.cloud.retail.v2beta.ModelService + * @typedef TuneModelCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls TuneModel. + * @function tuneModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.ITuneModelRequest} request TuneModelRequest message or plain object + * @param {google.cloud.retail.v2beta.ModelService.TuneModelCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ModelService.prototype.tuneModel = function tuneModel(request, callback) { + return this.rpcCall(tuneModel, $root.google.cloud.retail.v2beta.TuneModelRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "TuneModel" }); + + /** + * Calls TuneModel. + * @function tuneModel + * @memberof google.cloud.retail.v2beta.ModelService + * @instance + * @param {google.cloud.retail.v2beta.ITuneModelRequest} request TuneModelRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ModelService; + })(); + + v2beta.CreateModelRequest = (function() { + + /** + * Properties of a CreateModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICreateModelRequest + * @property {string|null} [parent] CreateModelRequest parent + * @property {google.cloud.retail.v2beta.IModel|null} [model] CreateModelRequest model + * @property {boolean|null} [dryRun] CreateModelRequest dryRun + */ + + /** + * Constructs a new CreateModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CreateModelRequest. + * @implements ICreateModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICreateModelRequest=} [properties] Properties to set + */ + function CreateModelRequest(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]]; + } + + /** + * CreateModelRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.parent = ""; + + /** + * CreateModelRequest model. + * @member {google.cloud.retail.v2beta.IModel|null|undefined} model + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.model = null; + + /** + * CreateModelRequest dryRun. + * @member {boolean} dryRun + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @instance + */ + CreateModelRequest.prototype.dryRun = false; + + /** + * Creates a new CreateModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CreateModelRequest} CreateModelRequest instance + */ + CreateModelRequest.create = function create(properties) { + return new CreateModelRequest(properties); + }; + + /** + * Encodes the specified CreateModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateModelRequest} message CreateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + $root.google.cloud.retail.v2beta.Model.encode(message.model, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.dryRun != null && Object.hasOwnProperty.call(message, "dryRun")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.dryRun); + return writer; + }; + + /** + * Encodes the specified CreateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateModelRequest} message CreateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CreateModelRequest} CreateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelRequest.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.cloud.retail.v2beta.CreateModelRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.model = $root.google.cloud.retail.v2beta.Model.decode(reader, reader.uint32()); + break; + } + case 3: { + message.dryRun = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CreateModelRequest} CreateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateModelRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.model != null && message.hasOwnProperty("model")) { + var error = $root.google.cloud.retail.v2beta.Model.verify(message.model); + if (error) + return "model." + error; + } + if (message.dryRun != null && message.hasOwnProperty("dryRun")) + if (typeof message.dryRun !== "boolean") + return "dryRun: boolean expected"; + return null; + }; + + /** + * Creates a CreateModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CreateModelRequest} CreateModelRequest + */ + CreateModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CreateModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CreateModelRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.model != null) { + if (typeof object.model !== "object") + throw TypeError(".google.cloud.retail.v2beta.CreateModelRequest.model: object expected"); + message.model = $root.google.cloud.retail.v2beta.Model.fromObject(object.model); + } + if (object.dryRun != null) + message.dryRun = Boolean(object.dryRun); + return message; + }; + + /** + * Creates a plain object from a CreateModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {google.cloud.retail.v2beta.CreateModelRequest} message CreateModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateModelRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.model = null; + object.dryRun = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.model != null && message.hasOwnProperty("model")) + object.model = $root.google.cloud.retail.v2beta.Model.toObject(message.model, options); + if (message.dryRun != null && message.hasOwnProperty("dryRun")) + object.dryRun = message.dryRun; + return object; + }; + + /** + * Converts this CreateModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @instance + * @returns {Object.} JSON object + */ + CreateModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CreateModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CreateModelRequest"; + }; + + return CreateModelRequest; + })(); + + v2beta.UpdateModelRequest = (function() { + + /** + * Properties of an UpdateModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateModelRequest + * @property {google.cloud.retail.v2beta.IModel|null} [model] UpdateModelRequest model + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateModelRequest updateMask + */ + + /** + * Constructs a new UpdateModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateModelRequest. + * @implements IUpdateModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateModelRequest=} [properties] Properties to set + */ + function UpdateModelRequest(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]]; + } + + /** + * UpdateModelRequest model. + * @member {google.cloud.retail.v2beta.IModel|null|undefined} model + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @instance + */ + UpdateModelRequest.prototype.model = null; + + /** + * UpdateModelRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @instance + */ + UpdateModelRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateModelRequest} UpdateModelRequest instance + */ + UpdateModelRequest.create = function create(properties) { + return new UpdateModelRequest(properties); + }; + + /** + * Encodes the specified UpdateModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateModelRequest} message UpdateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateModelRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + $root.google.cloud.retail.v2beta.Model.encode(message.model, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateModelRequest} message UpdateModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateModelRequest} UpdateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateModelRequest.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.cloud.retail.v2beta.UpdateModelRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = $root.google.cloud.retail.v2beta.Model.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateModelRequest} UpdateModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateModelRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) { + var error = $root.google.cloud.retail.v2beta.Model.verify(message.model); + if (error) + return "model." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateModelRequest} UpdateModelRequest + */ + UpdateModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateModelRequest(); + if (object.model != null) { + if (typeof object.model !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateModelRequest.model: object expected"); + message.model = $root.google.cloud.retail.v2beta.Model.fromObject(object.model); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateModelRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateModelRequest} message UpdateModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateModelRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.model = null; + object.updateMask = null; + } + if (message.model != null && message.hasOwnProperty("model")) + object.model = $root.google.cloud.retail.v2beta.Model.toObject(message.model, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateModelRequest"; + }; + + return UpdateModelRequest; + })(); + + v2beta.PauseModelRequest = (function() { + + /** + * Properties of a PauseModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface IPauseModelRequest + * @property {string|null} [name] PauseModelRequest name + */ + + /** + * Constructs a new PauseModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PauseModelRequest. + * @implements IPauseModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.IPauseModelRequest=} [properties] Properties to set + */ + function PauseModelRequest(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]]; + } + + /** + * PauseModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @instance + */ + PauseModelRequest.prototype.name = ""; + + /** + * Creates a new PauseModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {google.cloud.retail.v2beta.IPauseModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PauseModelRequest} PauseModelRequest instance + */ + PauseModelRequest.create = function create(properties) { + return new PauseModelRequest(properties); + }; + + /** + * Encodes the specified PauseModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PauseModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {google.cloud.retail.v2beta.IPauseModelRequest} message PauseModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PauseModelRequest.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 PauseModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PauseModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {google.cloud.retail.v2beta.IPauseModelRequest} message PauseModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PauseModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PauseModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PauseModelRequest} PauseModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PauseModelRequest.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.cloud.retail.v2beta.PauseModelRequest(); + 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 PauseModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PauseModelRequest} PauseModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PauseModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PauseModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PauseModelRequest.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 PauseModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PauseModelRequest} PauseModelRequest + */ + PauseModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PauseModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.PauseModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a PauseModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {google.cloud.retail.v2beta.PauseModelRequest} message PauseModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PauseModelRequest.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 PauseModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @instance + * @returns {Object.} JSON object + */ + PauseModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PauseModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PauseModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PauseModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PauseModelRequest"; + }; + + return PauseModelRequest; + })(); + + v2beta.ResumeModelRequest = (function() { + + /** + * Properties of a ResumeModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface IResumeModelRequest + * @property {string|null} [name] ResumeModelRequest name + */ + + /** + * Constructs a new ResumeModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ResumeModelRequest. + * @implements IResumeModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.IResumeModelRequest=} [properties] Properties to set + */ + function ResumeModelRequest(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]]; + } + + /** + * ResumeModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @instance + */ + ResumeModelRequest.prototype.name = ""; + + /** + * Creates a new ResumeModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2beta.IResumeModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ResumeModelRequest} ResumeModelRequest instance + */ + ResumeModelRequest.create = function create(properties) { + return new ResumeModelRequest(properties); + }; + + /** + * Encodes the specified ResumeModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ResumeModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2beta.IResumeModelRequest} message ResumeModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResumeModelRequest.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 ResumeModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ResumeModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2beta.IResumeModelRequest} message ResumeModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResumeModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResumeModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ResumeModelRequest} ResumeModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResumeModelRequest.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.cloud.retail.v2beta.ResumeModelRequest(); + 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 ResumeModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ResumeModelRequest} ResumeModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResumeModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResumeModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResumeModelRequest.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 ResumeModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ResumeModelRequest} ResumeModelRequest + */ + ResumeModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ResumeModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ResumeModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a ResumeModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {google.cloud.retail.v2beta.ResumeModelRequest} message ResumeModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResumeModelRequest.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 ResumeModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @instance + * @returns {Object.} JSON object + */ + ResumeModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResumeModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ResumeModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResumeModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ResumeModelRequest"; + }; + + return ResumeModelRequest; + })(); + + v2beta.ListModelsRequest = (function() { + + /** + * Properties of a ListModelsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IListModelsRequest + * @property {string|null} [parent] ListModelsRequest parent + * @property {number|null} [pageSize] ListModelsRequest pageSize + * @property {string|null} [pageToken] ListModelsRequest pageToken + */ + + /** + * Constructs a new ListModelsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListModelsRequest. + * @implements IListModelsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IListModelsRequest=} [properties] Properties to set + */ + function ListModelsRequest(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]]; + } + + /** + * ListModelsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.parent = ""; + + /** + * ListModelsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.pageSize = 0; + + /** + * ListModelsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @instance + */ + ListModelsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListModelsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {google.cloud.retail.v2beta.IListModelsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListModelsRequest} ListModelsRequest instance + */ + ListModelsRequest.create = function create(properties) { + return new ListModelsRequest(properties); + }; + + /** + * Encodes the specified ListModelsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {google.cloud.retail.v2beta.IListModelsRequest} message ListModelsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListModelsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {google.cloud.retail.v2beta.IListModelsRequest} message ListModelsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListModelsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListModelsRequest} ListModelsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsRequest.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.cloud.retail.v2beta.ListModelsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListModelsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListModelsRequest} ListModelsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListModelsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListModelsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListModelsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListModelsRequest} ListModelsRequest + */ + ListModelsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListModelsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ListModelsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListModelsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {google.cloud.retail.v2beta.ListModelsRequest} message ListModelsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListModelsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListModelsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @instance + * @returns {Object.} JSON object + */ + ListModelsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListModelsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListModelsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListModelsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListModelsRequest"; + }; + + return ListModelsRequest; + })(); + + v2beta.DeleteModelRequest = (function() { + + /** + * Properties of a DeleteModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface IDeleteModelRequest + * @property {string|null} [name] DeleteModelRequest name + */ + + /** + * Constructs a new DeleteModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a DeleteModelRequest. + * @implements IDeleteModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.IDeleteModelRequest=} [properties] Properties to set + */ + function DeleteModelRequest(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]]; + } + + /** + * DeleteModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @instance + */ + DeleteModelRequest.prototype.name = ""; + + /** + * Creates a new DeleteModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.DeleteModelRequest} DeleteModelRequest instance + */ + DeleteModelRequest.create = function create(properties) { + return new DeleteModelRequest(properties); + }; + + /** + * Encodes the specified DeleteModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteModelRequest} message DeleteModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteModelRequest.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 DeleteModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteModelRequest} message DeleteModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.DeleteModelRequest} DeleteModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteModelRequest.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.cloud.retail.v2beta.DeleteModelRequest(); + 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 DeleteModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.DeleteModelRequest} DeleteModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteModelRequest.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 DeleteModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.DeleteModelRequest} DeleteModelRequest + */ + DeleteModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.DeleteModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.DeleteModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {google.cloud.retail.v2beta.DeleteModelRequest} message DeleteModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteModelRequest.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 DeleteModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.DeleteModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.DeleteModelRequest"; + }; + + return DeleteModelRequest; + })(); + + v2beta.ListModelsResponse = (function() { + + /** + * Properties of a ListModelsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IListModelsResponse + * @property {Array.|null} [models] ListModelsResponse models + * @property {string|null} [nextPageToken] ListModelsResponse nextPageToken + */ + + /** + * Constructs a new ListModelsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListModelsResponse. + * @implements IListModelsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IListModelsResponse=} [properties] Properties to set + */ + function ListModelsResponse(properties) { + this.models = []; + 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]]; + } + + /** + * ListModelsResponse models. + * @member {Array.} models + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @instance + */ + ListModelsResponse.prototype.models = $util.emptyArray; + + /** + * ListModelsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @instance + */ + ListModelsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListModelsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {google.cloud.retail.v2beta.IListModelsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListModelsResponse} ListModelsResponse instance + */ + ListModelsResponse.create = function create(properties) { + return new ListModelsResponse(properties); + }; + + /** + * Encodes the specified ListModelsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {google.cloud.retail.v2beta.IListModelsResponse} message ListModelsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.models != null && message.models.length) + for (var i = 0; i < message.models.length; ++i) + $root.google.cloud.retail.v2beta.Model.encode(message.models[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 ListModelsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListModelsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {google.cloud.retail.v2beta.IListModelsResponse} message ListModelsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListModelsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListModelsResponse} ListModelsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsResponse.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.cloud.retail.v2beta.ListModelsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.models && message.models.length)) + message.models = []; + message.models.push($root.google.cloud.retail.v2beta.Model.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListModelsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListModelsResponse} ListModelsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListModelsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListModelsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListModelsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.models != null && message.hasOwnProperty("models")) { + if (!Array.isArray(message.models)) + return "models: array expected"; + for (var i = 0; i < message.models.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Model.verify(message.models[i]); + if (error) + return "models." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListModelsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListModelsResponse} ListModelsResponse + */ + ListModelsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListModelsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ListModelsResponse(); + if (object.models) { + if (!Array.isArray(object.models)) + throw TypeError(".google.cloud.retail.v2beta.ListModelsResponse.models: array expected"); + message.models = []; + for (var i = 0; i < object.models.length; ++i) { + if (typeof object.models[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListModelsResponse.models: object expected"); + message.models[i] = $root.google.cloud.retail.v2beta.Model.fromObject(object.models[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListModelsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {google.cloud.retail.v2beta.ListModelsResponse} message ListModelsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListModelsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.models = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.models && message.models.length) { + object.models = []; + for (var j = 0; j < message.models.length; ++j) + object.models[j] = $root.google.cloud.retail.v2beta.Model.toObject(message.models[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListModelsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @instance + * @returns {Object.} JSON object + */ + ListModelsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListModelsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListModelsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListModelsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListModelsResponse"; + }; + + return ListModelsResponse; + })(); + + v2beta.TuneModelRequest = (function() { + + /** + * Properties of a TuneModelRequest. + * @memberof google.cloud.retail.v2beta + * @interface ITuneModelRequest + * @property {string|null} [name] TuneModelRequest name + */ + + /** + * Constructs a new TuneModelRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a TuneModelRequest. + * @implements ITuneModelRequest + * @constructor + * @param {google.cloud.retail.v2beta.ITuneModelRequest=} [properties] Properties to set + */ + function TuneModelRequest(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]]; + } + + /** + * TuneModelRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @instance + */ + TuneModelRequest.prototype.name = ""; + + /** + * Creates a new TuneModelRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {google.cloud.retail.v2beta.ITuneModelRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.TuneModelRequest} TuneModelRequest instance + */ + TuneModelRequest.create = function create(properties) { + return new TuneModelRequest(properties); + }; + + /** + * Encodes the specified TuneModelRequest message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {google.cloud.retail.v2beta.ITuneModelRequest} message TuneModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelRequest.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 TuneModelRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {google.cloud.retail.v2beta.ITuneModelRequest} message TuneModelRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.TuneModelRequest} TuneModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelRequest.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.cloud.retail.v2beta.TuneModelRequest(); + 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 TuneModelRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.TuneModelRequest} TuneModelRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelRequest.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 TuneModelRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.TuneModelRequest} TuneModelRequest + */ + TuneModelRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.TuneModelRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.TuneModelRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a TuneModelRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {google.cloud.retail.v2beta.TuneModelRequest} message TuneModelRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelRequest.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 TuneModelRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @instance + * @returns {Object.} JSON object + */ + TuneModelRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.TuneModelRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.TuneModelRequest"; + }; + + return TuneModelRequest; + })(); + + v2beta.CreateModelMetadata = (function() { + + /** + * Properties of a CreateModelMetadata. + * @memberof google.cloud.retail.v2beta + * @interface ICreateModelMetadata + * @property {string|null} [model] CreateModelMetadata model + */ + + /** + * Constructs a new CreateModelMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CreateModelMetadata. + * @implements ICreateModelMetadata + * @constructor + * @param {google.cloud.retail.v2beta.ICreateModelMetadata=} [properties] Properties to set + */ + function CreateModelMetadata(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]]; + } + + /** + * CreateModelMetadata model. + * @member {string} model + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @instance + */ + CreateModelMetadata.prototype.model = ""; + + /** + * Creates a new CreateModelMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ICreateModelMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CreateModelMetadata} CreateModelMetadata instance + */ + CreateModelMetadata.create = function create(properties) { + return new CreateModelMetadata(properties); + }; + + /** + * Encodes the specified CreateModelMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ICreateModelMetadata} message CreateModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.model); + return writer; + }; + + /** + * Encodes the specified CreateModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateModelMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ICreateModelMetadata} message CreateModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateModelMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CreateModelMetadata} CreateModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelMetadata.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.cloud.retail.v2beta.CreateModelMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateModelMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CreateModelMetadata} CreateModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateModelMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateModelMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateModelMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + return null; + }; + + /** + * Creates a CreateModelMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CreateModelMetadata} CreateModelMetadata + */ + CreateModelMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CreateModelMetadata) + return object; + var message = new $root.google.cloud.retail.v2beta.CreateModelMetadata(); + if (object.model != null) + message.model = String(object.model); + return message; + }; + + /** + * Creates a plain object from a CreateModelMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {google.cloud.retail.v2beta.CreateModelMetadata} message CreateModelMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateModelMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.model = ""; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + return object; + }; + + /** + * Converts this CreateModelMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @instance + * @returns {Object.} JSON object + */ + CreateModelMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateModelMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CreateModelMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateModelMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CreateModelMetadata"; + }; + + return CreateModelMetadata; + })(); + + v2beta.TuneModelMetadata = (function() { + + /** + * Properties of a TuneModelMetadata. + * @memberof google.cloud.retail.v2beta + * @interface ITuneModelMetadata + * @property {string|null} [model] TuneModelMetadata model + */ + + /** + * Constructs a new TuneModelMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a TuneModelMetadata. + * @implements ITuneModelMetadata + * @constructor + * @param {google.cloud.retail.v2beta.ITuneModelMetadata=} [properties] Properties to set + */ + function TuneModelMetadata(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]]; + } + + /** + * TuneModelMetadata model. + * @member {string} model + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @instance + */ + TuneModelMetadata.prototype.model = ""; + + /** + * Creates a new TuneModelMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ITuneModelMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.TuneModelMetadata} TuneModelMetadata instance + */ + TuneModelMetadata.create = function create(properties) { + return new TuneModelMetadata(properties); + }; + + /** + * Encodes the specified TuneModelMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ITuneModelMetadata} message TuneModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.model); + return writer; + }; + + /** + * Encodes the specified TuneModelMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2beta.ITuneModelMetadata} message TuneModelMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.TuneModelMetadata} TuneModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelMetadata.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.cloud.retail.v2beta.TuneModelMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.model = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TuneModelMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.TuneModelMetadata} TuneModelMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + return null; + }; + + /** + * Creates a TuneModelMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.TuneModelMetadata} TuneModelMetadata + */ + TuneModelMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.TuneModelMetadata) + return object; + var message = new $root.google.cloud.retail.v2beta.TuneModelMetadata(); + if (object.model != null) + message.model = String(object.model); + return message; + }; + + /** + * Creates a plain object from a TuneModelMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {google.cloud.retail.v2beta.TuneModelMetadata} message TuneModelMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.model = ""; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + return object; + }; + + /** + * Converts this TuneModelMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @instance + * @returns {Object.} JSON object + */ + TuneModelMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.TuneModelMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.TuneModelMetadata"; + }; + + return TuneModelMetadata; + })(); + + v2beta.TuneModelResponse = (function() { + + /** + * Properties of a TuneModelResponse. + * @memberof google.cloud.retail.v2beta + * @interface ITuneModelResponse + */ + + /** + * Constructs a new TuneModelResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a TuneModelResponse. + * @implements ITuneModelResponse + * @constructor + * @param {google.cloud.retail.v2beta.ITuneModelResponse=} [properties] Properties to set + */ + function TuneModelResponse(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 TuneModelResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {google.cloud.retail.v2beta.ITuneModelResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.TuneModelResponse} TuneModelResponse instance + */ + TuneModelResponse.create = function create(properties) { + return new TuneModelResponse(properties); + }; + + /** + * Encodes the specified TuneModelResponse message. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {google.cloud.retail.v2beta.ITuneModelResponse} message TuneModelResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified TuneModelResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.TuneModelResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {google.cloud.retail.v2beta.ITuneModelResponse} message TuneModelResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TuneModelResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.TuneModelResponse} TuneModelResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelResponse.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.cloud.retail.v2beta.TuneModelResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TuneModelResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.TuneModelResponse} TuneModelResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TuneModelResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TuneModelResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TuneModelResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a TuneModelResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.TuneModelResponse} TuneModelResponse + */ + TuneModelResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.TuneModelResponse) + return object; + return new $root.google.cloud.retail.v2beta.TuneModelResponse(); + }; + + /** + * Creates a plain object from a TuneModelResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {google.cloud.retail.v2beta.TuneModelResponse} message TuneModelResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TuneModelResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this TuneModelResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @instance + * @returns {Object.} JSON object + */ + TuneModelResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TuneModelResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.TuneModelResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TuneModelResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.TuneModelResponse"; + }; + + return TuneModelResponse; + })(); + + v2beta.PredictionService = (function() { + + /** + * Constructs a new PredictionService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PredictionService + * @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 PredictionService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (PredictionService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = PredictionService; + + /** + * Creates new PredictionService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.PredictionService + * @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 {PredictionService} RPC service. Useful where requests and/or responses are streamed. + */ + PredictionService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.PredictionService|predict}. + * @memberof google.cloud.retail.v2beta.PredictionService + * @typedef PredictCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.PredictResponse} [response] PredictResponse + */ + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2beta.PredictionService + * @instance + * @param {google.cloud.retail.v2beta.IPredictRequest} request PredictRequest message or plain object + * @param {google.cloud.retail.v2beta.PredictionService.PredictCallback} callback Node-style callback called with the error, if any, and PredictResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(PredictionService.prototype.predict = function predict(request, callback) { + return this.rpcCall(predict, $root.google.cloud.retail.v2beta.PredictRequest, $root.google.cloud.retail.v2beta.PredictResponse, request, callback); + }, "name", { value: "Predict" }); + + /** + * Calls Predict. + * @function predict + * @memberof google.cloud.retail.v2beta.PredictionService + * @instance + * @param {google.cloud.retail.v2beta.IPredictRequest} request PredictRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return PredictionService; + })(); + + v2beta.PredictRequest = (function() { + + /** + * Properties of a PredictRequest. + * @memberof google.cloud.retail.v2beta + * @interface IPredictRequest + * @property {string|null} [placement] PredictRequest placement + * @property {google.cloud.retail.v2beta.IUserEvent|null} [userEvent] PredictRequest userEvent + * @property {number|null} [pageSize] PredictRequest pageSize + * @property {string|null} [pageToken] PredictRequest pageToken + * @property {string|null} [filter] PredictRequest filter + * @property {boolean|null} [validateOnly] PredictRequest validateOnly + * @property {Object.|null} [params] PredictRequest params + * @property {Object.|null} [labels] PredictRequest labels + */ + + /** + * Constructs a new PredictRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PredictRequest. + * @implements IPredictRequest + * @constructor + * @param {google.cloud.retail.v2beta.IPredictRequest=} [properties] Properties to set + */ + function PredictRequest(properties) { + this.params = {}; + 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]]; + } + + /** + * PredictRequest placement. + * @member {string} placement + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.placement = ""; + + /** + * PredictRequest userEvent. + * @member {google.cloud.retail.v2beta.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.userEvent = null; + + /** + * PredictRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.pageSize = 0; + + /** + * PredictRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.pageToken = ""; + + /** + * PredictRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.filter = ""; + + /** + * PredictRequest validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.validateOnly = false; + + /** + * PredictRequest params. + * @member {Object.} params + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.params = $util.emptyObject; + + /** + * PredictRequest labels. + * @member {Object.} labels + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + */ + PredictRequest.prototype.labels = $util.emptyObject; + + /** + * Creates a new PredictRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {google.cloud.retail.v2beta.IPredictRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PredictRequest} PredictRequest instance + */ + PredictRequest.create = function create(properties) { + return new PredictRequest(properties); + }; + + /** + * Encodes the specified PredictRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PredictRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {google.cloud.retail.v2beta.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.placement != null && Object.hasOwnProperty.call(message, "placement")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.placement); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2beta.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.pageToken); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.filter); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.validateOnly); + if (message.params != null && Object.hasOwnProperty.call(message, "params")) + for (var keys = Object.keys(message.params), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 7, wireType 2 =*/58).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.Value.encode(message.params[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + 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 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified PredictRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {google.cloud.retail.v2beta.IPredictRequest} message PredictRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.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.cloud.retail.v2beta.PredictRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.placement = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2beta.UserEvent.decode(reader, reader.uint32()); + break; + } + case 3: { + message.pageSize = reader.int32(); + break; + } + case 4: { + message.pageToken = reader.string(); + break; + } + case 5: { + message.filter = reader.string(); + break; + } + case 6: { + message.validateOnly = reader.bool(); + break; + } + case 7: { + if (message.params === $util.emptyObject) + message.params = {}; + 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.params[key] = value; + break; + } + case 8: { + 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; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PredictRequest} PredictRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.placement != null && message.hasOwnProperty("placement")) + if (!$util.isString(message.placement)) + return "placement: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2beta.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + if (message.params != null && message.hasOwnProperty("params")) { + if (!$util.isObject(message.params)) + return "params: object expected"; + var key = Object.keys(message.params); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.params[key[i]]); + if (error) + return "params." + error; + } + } + 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"; + } + return null; + }; + + /** + * Creates a PredictRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PredictRequest} PredictRequest + */ + PredictRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PredictRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.PredictRequest(); + if (object.placement != null) + message.placement = String(object.placement); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2beta.UserEvent.fromObject(object.userEvent); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + if (object.params) { + if (typeof object.params !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictRequest.params: object expected"); + message.params = {}; + for (var keys = Object.keys(object.params), i = 0; i < keys.length; ++i) { + if (typeof object.params[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictRequest.params: object expected"); + message.params[keys[i]] = $root.google.protobuf.Value.fromObject(object.params[keys[i]]); + } + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictRequest.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]]); + } + return message; + }; + + /** + * Creates a plain object from a PredictRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {google.cloud.retail.v2beta.PredictRequest} message PredictRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) { + object.params = {}; + object.labels = {}; + } + if (options.defaults) { + object.placement = ""; + object.userEvent = null; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.validateOnly = false; + } + if (message.placement != null && message.hasOwnProperty("placement")) + object.placement = message.placement; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2beta.UserEvent.toObject(message.userEvent, options); + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + var keys2; + if (message.params && (keys2 = Object.keys(message.params)).length) { + object.params = {}; + for (var j = 0; j < keys2.length; ++j) + object.params[keys2[j]] = $root.google.protobuf.Value.toObject(message.params[keys2[j]], options); + } + 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]]; + } + return object; + }; + + /** + * Converts this PredictRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PredictRequest + * @instance + * @returns {Object.} JSON object + */ + PredictRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PredictRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PredictRequest"; + }; + + return PredictRequest; + })(); + + v2beta.PredictResponse = (function() { + + /** + * Properties of a PredictResponse. + * @memberof google.cloud.retail.v2beta + * @interface IPredictResponse + * @property {Array.|null} [results] PredictResponse results + * @property {string|null} [attributionToken] PredictResponse attributionToken + * @property {Array.|null} [missingIds] PredictResponse missingIds + * @property {boolean|null} [validateOnly] PredictResponse validateOnly + */ + + /** + * Constructs a new PredictResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PredictResponse. + * @implements IPredictResponse + * @constructor + * @param {google.cloud.retail.v2beta.IPredictResponse=} [properties] Properties to set + */ + function PredictResponse(properties) { + this.results = []; + this.missingIds = []; + 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]]; + } + + /** + * PredictResponse results. + * @member {Array.} results + * @memberof google.cloud.retail.v2beta.PredictResponse + * @instance + */ + PredictResponse.prototype.results = $util.emptyArray; + + /** + * PredictResponse attributionToken. + * @member {string} attributionToken + * @memberof google.cloud.retail.v2beta.PredictResponse + * @instance + */ + PredictResponse.prototype.attributionToken = ""; + + /** + * PredictResponse missingIds. + * @member {Array.} missingIds + * @memberof google.cloud.retail.v2beta.PredictResponse + * @instance + */ + PredictResponse.prototype.missingIds = $util.emptyArray; + + /** + * PredictResponse validateOnly. + * @member {boolean} validateOnly + * @memberof google.cloud.retail.v2beta.PredictResponse + * @instance + */ + PredictResponse.prototype.validateOnly = false; + + /** + * Creates a new PredictResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {google.cloud.retail.v2beta.IPredictResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PredictResponse} PredictResponse instance + */ + PredictResponse.create = function create(properties) { + return new PredictResponse(properties); + }; + + /** + * Encodes the specified PredictResponse message. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {google.cloud.retail.v2beta.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.results != null && message.results.length) + for (var i = 0; i < message.results.length; ++i) + $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult.encode(message.results[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.attributionToken != null && Object.hasOwnProperty.call(message, "attributionToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.attributionToken); + if (message.missingIds != null && message.missingIds.length) + for (var i = 0; i < message.missingIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.missingIds[i]); + if (message.validateOnly != null && Object.hasOwnProperty.call(message, "validateOnly")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.validateOnly); + return writer; + }; + + /** + * Encodes the specified PredictResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {google.cloud.retail.v2beta.IPredictResponse} message PredictResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.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.cloud.retail.v2beta.PredictResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.results && message.results.length)) + message.results = []; + message.results.push($root.google.cloud.retail.v2beta.PredictResponse.PredictionResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.attributionToken = reader.string(); + break; + } + case 3: { + if (!(message.missingIds && message.missingIds.length)) + message.missingIds = []; + message.missingIds.push(reader.string()); + break; + } + case 4: { + message.validateOnly = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PredictResponse} PredictResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.results != null && message.hasOwnProperty("results")) { + if (!Array.isArray(message.results)) + return "results: array expected"; + for (var i = 0; i < message.results.length; ++i) { + var error = $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult.verify(message.results[i]); + if (error) + return "results." + error; + } + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + if (!$util.isString(message.attributionToken)) + return "attributionToken: string expected"; + if (message.missingIds != null && message.hasOwnProperty("missingIds")) { + if (!Array.isArray(message.missingIds)) + return "missingIds: array expected"; + for (var i = 0; i < message.missingIds.length; ++i) + if (!$util.isString(message.missingIds[i])) + return "missingIds: string[] expected"; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + if (typeof message.validateOnly !== "boolean") + return "validateOnly: boolean expected"; + return null; + }; + + /** + * Creates a PredictResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PredictResponse} PredictResponse + */ + PredictResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PredictResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.PredictResponse(); + if (object.results) { + if (!Array.isArray(object.results)) + throw TypeError(".google.cloud.retail.v2beta.PredictResponse.results: array expected"); + message.results = []; + for (var i = 0; i < object.results.length; ++i) { + if (typeof object.results[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictResponse.results: object expected"); + message.results[i] = $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult.fromObject(object.results[i]); + } + } + if (object.attributionToken != null) + message.attributionToken = String(object.attributionToken); + if (object.missingIds) { + if (!Array.isArray(object.missingIds)) + throw TypeError(".google.cloud.retail.v2beta.PredictResponse.missingIds: array expected"); + message.missingIds = []; + for (var i = 0; i < object.missingIds.length; ++i) + message.missingIds[i] = String(object.missingIds[i]); + } + if (object.validateOnly != null) + message.validateOnly = Boolean(object.validateOnly); + return message; + }; + + /** + * Creates a plain object from a PredictResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {google.cloud.retail.v2beta.PredictResponse} message PredictResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.results = []; + object.missingIds = []; + } + if (options.defaults) { + object.attributionToken = ""; + object.validateOnly = false; + } + if (message.results && message.results.length) { + object.results = []; + for (var j = 0; j < message.results.length; ++j) + object.results[j] = $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult.toObject(message.results[j], options); + } + if (message.attributionToken != null && message.hasOwnProperty("attributionToken")) + object.attributionToken = message.attributionToken; + if (message.missingIds && message.missingIds.length) { + object.missingIds = []; + for (var j = 0; j < message.missingIds.length; ++j) + object.missingIds[j] = message.missingIds[j]; + } + if (message.validateOnly != null && message.hasOwnProperty("validateOnly")) + object.validateOnly = message.validateOnly; + return object; + }; + + /** + * Converts this PredictResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PredictResponse + * @instance + * @returns {Object.} JSON object + */ + PredictResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PredictResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PredictResponse"; + }; + + PredictResponse.PredictionResult = (function() { + + /** + * Properties of a PredictionResult. + * @memberof google.cloud.retail.v2beta.PredictResponse + * @interface IPredictionResult + * @property {string|null} [id] PredictionResult id + * @property {Object.|null} [metadata] PredictionResult metadata + */ + + /** + * Constructs a new PredictionResult. + * @memberof google.cloud.retail.v2beta.PredictResponse + * @classdesc Represents a PredictionResult. + * @implements IPredictionResult + * @constructor + * @param {google.cloud.retail.v2beta.PredictResponse.IPredictionResult=} [properties] Properties to set + */ + function PredictionResult(properties) { + this.metadata = {}; + 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]]; + } + + /** + * PredictionResult id. + * @member {string} id + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.id = ""; + + /** + * PredictionResult metadata. + * @member {Object.} metadata + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @instance + */ + PredictionResult.prototype.metadata = $util.emptyObject; + + /** + * Creates a new PredictionResult instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2beta.PredictResponse.IPredictionResult=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PredictResponse.PredictionResult} PredictionResult instance + */ + PredictionResult.create = function create(properties) { + return new PredictionResult(properties); + }; + + /** + * Encodes the specified PredictionResult message. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.PredictionResult.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2beta.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + for (var keys = Object.keys(message.metadata), 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.protobuf.Value.encode(message.metadata[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified PredictionResult message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PredictResponse.PredictionResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2beta.PredictResponse.IPredictionResult} message PredictionResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PredictionResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.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.cloud.retail.v2beta.PredictResponse.PredictionResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.string(); + break; + } + case 2: { + if (message.metadata === $util.emptyObject) + message.metadata = {}; + 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.metadata[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PredictionResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PredictResponse.PredictionResult} PredictionResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PredictionResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PredictionResult message. + * @function verify + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PredictionResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.metadata != null && message.hasOwnProperty("metadata")) { + if (!$util.isObject(message.metadata)) + return "metadata: object expected"; + var key = Object.keys(message.metadata); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.metadata[key[i]]); + if (error) + return "metadata." + error; + } + } + return null; + }; + + /** + * Creates a PredictionResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PredictResponse.PredictionResult} PredictionResult + */ + PredictionResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult) + return object; + var message = new $root.google.cloud.retail.v2beta.PredictResponse.PredictionResult(); + if (object.id != null) + message.id = String(object.id); + if (object.metadata) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata = {}; + for (var keys = Object.keys(object.metadata), i = 0; i < keys.length; ++i) { + if (typeof object.metadata[keys[i]] !== "object") + throw TypeError(".google.cloud.retail.v2beta.PredictResponse.PredictionResult.metadata: object expected"); + message.metadata[keys[i]] = $root.google.protobuf.Value.fromObject(object.metadata[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a PredictionResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {google.cloud.retail.v2beta.PredictResponse.PredictionResult} message PredictionResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PredictionResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.metadata = {}; + if (options.defaults) + object.id = ""; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + var keys2; + if (message.metadata && (keys2 = Object.keys(message.metadata)).length) { + object.metadata = {}; + for (var j = 0; j < keys2.length; ++j) + object.metadata[keys2[j]] = $root.google.protobuf.Value.toObject(message.metadata[keys2[j]], options); + } + return object; + }; + + /** + * Converts this PredictionResult to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @instance + * @returns {Object.} JSON object + */ + PredictionResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PredictionResult + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PredictResponse.PredictionResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PredictionResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PredictResponse.PredictionResult"; + }; + + return PredictionResult; + })(); + + return PredictResponse; + })(); + + v2beta.ProductService = (function() { + + /** + * Constructs a new ProductService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ProductService + * @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 ProductService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ProductService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ProductService; + + /** + * Creates new ProductService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.ProductService + * @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 {ProductService} RPC service. Useful where requests and/or responses are streamed. + */ + ProductService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|createProduct}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef CreateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Product} [response] Product + */ + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.ICreateProductRequest} request CreateProductRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.CreateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.createProduct = function createProduct(request, callback) { + return this.rpcCall(createProduct, $root.google.cloud.retail.v2beta.CreateProductRequest, $root.google.cloud.retail.v2beta.Product, request, callback); + }, "name", { value: "CreateProduct" }); + + /** + * Calls CreateProduct. + * @function createProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.ICreateProductRequest} request CreateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|getProduct}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef GetProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Product} [response] Product + */ + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IGetProductRequest} request GetProductRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.GetProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.getProduct = function getProduct(request, callback) { + return this.rpcCall(getProduct, $root.google.cloud.retail.v2beta.GetProductRequest, $root.google.cloud.retail.v2beta.Product, request, callback); + }, "name", { value: "GetProduct" }); + + /** + * Calls GetProduct. + * @function getProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IGetProductRequest} request GetProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|listProducts}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef ListProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ListProductsResponse} [response] ListProductsResponse + */ + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IListProductsRequest} request ListProductsRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.ListProductsCallback} callback Node-style callback called with the error, if any, and ListProductsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.listProducts = function listProducts(request, callback) { + return this.rpcCall(listProducts, $root.google.cloud.retail.v2beta.ListProductsRequest, $root.google.cloud.retail.v2beta.ListProductsResponse, request, callback); + }, "name", { value: "ListProducts" }); + + /** + * Calls ListProducts. + * @function listProducts + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IListProductsRequest} request ListProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|updateProduct}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef UpdateProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.Product} [response] Product + */ + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.UpdateProductCallback} callback Node-style callback called with the error, if any, and Product + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.updateProduct = function updateProduct(request, callback) { + return this.rpcCall(updateProduct, $root.google.cloud.retail.v2beta.UpdateProductRequest, $root.google.cloud.retail.v2beta.Product, request, callback); + }, "name", { value: "UpdateProduct" }); + + /** + * Calls UpdateProduct. + * @function updateProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateProductRequest} request UpdateProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|deleteProduct}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef DeleteProductCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.DeleteProductCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.deleteProduct = function deleteProduct(request, callback) { + return this.rpcCall(deleteProduct, $root.google.cloud.retail.v2beta.DeleteProductRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteProduct" }); + + /** + * Calls DeleteProduct. + * @function deleteProduct + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteProductRequest} request DeleteProductRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|importProducts}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef ImportProductsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IImportProductsRequest} request ImportProductsRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.ImportProductsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.importProducts = function importProducts(request, callback) { + return this.rpcCall(importProducts, $root.google.cloud.retail.v2beta.ImportProductsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportProducts" }); + + /** + * Calls ImportProducts. + * @function importProducts + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IImportProductsRequest} request ImportProductsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|setInventory}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef SetInventoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.SetInventoryCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.setInventory = function setInventory(request, callback) { + return this.rpcCall(setInventory, $root.google.cloud.retail.v2beta.SetInventoryRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "SetInventory" }); + + /** + * Calls SetInventory. + * @function setInventory + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.ISetInventoryRequest} request SetInventoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|addFulfillmentPlaces}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef AddFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.AddFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addFulfillmentPlaces = function addFulfillmentPlaces(request, callback) { + return this.rpcCall(addFulfillmentPlaces, $root.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddFulfillmentPlaces" }); + + /** + * Calls AddFulfillmentPlaces. + * @function addFulfillmentPlaces + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest} request AddFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|removeFulfillmentPlaces}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef RemoveFulfillmentPlacesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlacesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeFulfillmentPlaces = function removeFulfillmentPlaces(request, callback) { + return this.rpcCall(removeFulfillmentPlaces, $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveFulfillmentPlaces" }); + + /** + * Calls RemoveFulfillmentPlaces. + * @function removeFulfillmentPlaces + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest} request RemoveFulfillmentPlacesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|addLocalInventories}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef AddLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.AddLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.addLocalInventories = function addLocalInventories(request, callback) { + return this.rpcCall(addLocalInventories, $root.google.cloud.retail.v2beta.AddLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "AddLocalInventories" }); + + /** + * Calls AddLocalInventories. + * @function addLocalInventories + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest} request AddLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ProductService|removeLocalInventories}. + * @memberof google.cloud.retail.v2beta.ProductService + * @typedef RemoveLocalInventoriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @param {google.cloud.retail.v2beta.ProductService.RemoveLocalInventoriesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ProductService.prototype.removeLocalInventories = function removeLocalInventories(request, callback) { + return this.rpcCall(removeLocalInventories, $root.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RemoveLocalInventories" }); + + /** + * Calls RemoveLocalInventories. + * @function removeLocalInventories + * @memberof google.cloud.retail.v2beta.ProductService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest} request RemoveLocalInventoriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ProductService; + })(); + + v2beta.CreateProductRequest = (function() { + + /** + * Properties of a CreateProductRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICreateProductRequest + * @property {string|null} [parent] CreateProductRequest parent + * @property {google.cloud.retail.v2beta.IProduct|null} [product] CreateProductRequest product + * @property {string|null} [productId] CreateProductRequest productId + */ + + /** + * Constructs a new CreateProductRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CreateProductRequest. + * @implements ICreateProductRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICreateProductRequest=} [properties] Properties to set + */ + function CreateProductRequest(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]]; + } + + /** + * CreateProductRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.parent = ""; + + /** + * CreateProductRequest product. + * @member {google.cloud.retail.v2beta.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.product = null; + + /** + * CreateProductRequest productId. + * @member {string} productId + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @instance + */ + CreateProductRequest.prototype.productId = ""; + + /** + * Creates a new CreateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CreateProductRequest} CreateProductRequest instance + */ + CreateProductRequest.create = function create(properties) { + return new CreateProductRequest(properties); + }; + + /** + * Encodes the specified CreateProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2beta.Product.encode(message.product, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.productId != null && Object.hasOwnProperty.call(message, "productId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.productId); + return writer; + }; + + /** + * Encodes the specified CreateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateProductRequest} message CreateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.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.cloud.retail.v2beta.CreateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.product = $root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32()); + break; + } + case 3: { + message.productId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CreateProductRequest} CreateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.productId != null && message.hasOwnProperty("productId")) + if (!$util.isString(message.productId)) + return "productId: string expected"; + return null; + }; + + /** + * Creates a CreateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CreateProductRequest} CreateProductRequest + */ + CreateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CreateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CreateProductRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2beta.CreateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2beta.Product.fromObject(object.product); + } + if (object.productId != null) + message.productId = String(object.productId); + return message; + }; + + /** + * Creates a plain object from a CreateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {google.cloud.retail.v2beta.CreateProductRequest} message CreateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.product = null; + object.productId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2beta.Product.toObject(message.product, options); + if (message.productId != null && message.hasOwnProperty("productId")) + object.productId = message.productId; + return object; + }; + + /** + * Converts this CreateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @instance + * @returns {Object.} JSON object + */ + CreateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CreateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CreateProductRequest"; + }; + + return CreateProductRequest; + })(); + + v2beta.GetProductRequest = (function() { + + /** + * Properties of a GetProductRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetProductRequest + * @property {string|null} [name] GetProductRequest name + */ + + /** + * Constructs a new GetProductRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetProductRequest. + * @implements IGetProductRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetProductRequest=} [properties] Properties to set + */ + function GetProductRequest(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]]; + } + + /** + * GetProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @instance + */ + GetProductRequest.prototype.name = ""; + + /** + * Creates a new GetProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {google.cloud.retail.v2beta.IGetProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetProductRequest} GetProductRequest instance + */ + GetProductRequest.create = function create(properties) { + return new GetProductRequest(properties); + }; + + /** + * Encodes the specified GetProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {google.cloud.retail.v2beta.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.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 GetProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {google.cloud.retail.v2beta.IGetProductRequest} message GetProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.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.cloud.retail.v2beta.GetProductRequest(); + 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 GetProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetProductRequest} GetProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetProductRequest.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 GetProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetProductRequest} GetProductRequest + */ + GetProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetProductRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {google.cloud.retail.v2beta.GetProductRequest} message GetProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetProductRequest.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 GetProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @instance + * @returns {Object.} JSON object + */ + GetProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetProductRequest"; + }; + + return GetProductRequest; + })(); + + v2beta.UpdateProductRequest = (function() { + + /** + * Properties of an UpdateProductRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateProductRequest + * @property {google.cloud.retail.v2beta.IProduct|null} [product] UpdateProductRequest product + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateProductRequest updateMask + * @property {boolean|null} [allowMissing] UpdateProductRequest allowMissing + */ + + /** + * Constructs a new UpdateProductRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateProductRequest. + * @implements IUpdateProductRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateProductRequest=} [properties] Properties to set + */ + function UpdateProductRequest(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]]; + } + + /** + * UpdateProductRequest product. + * @member {google.cloud.retail.v2beta.IProduct|null|undefined} product + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.product = null; + + /** + * UpdateProductRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.updateMask = null; + + /** + * UpdateProductRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @instance + */ + UpdateProductRequest.prototype.allowMissing = false; + + /** + * Creates a new UpdateProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateProductRequest} UpdateProductRequest instance + */ + UpdateProductRequest.create = function create(properties) { + return new UpdateProductRequest(properties); + }; + + /** + * Encodes the specified UpdateProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + $root.google.cloud.retail.v2beta.Product.encode(message.product, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified UpdateProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateProductRequest} message UpdateProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.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.cloud.retail.v2beta.UpdateProductRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = $root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateProductRequest} UpdateProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateProductRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.product); + if (error) + return "product." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an UpdateProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateProductRequest} UpdateProductRequest + */ + UpdateProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateProductRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateProductRequest(); + if (object.product != null) { + if (typeof object.product !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateProductRequest.product: object expected"); + message.product = $root.google.cloud.retail.v2beta.Product.fromObject(object.product); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateProductRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an UpdateProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateProductRequest} message UpdateProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateProductRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.product = null; + object.updateMask = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = $root.google.cloud.retail.v2beta.Product.toObject(message.product, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this UpdateProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateProductRequest"; + }; + + return UpdateProductRequest; + })(); + + v2beta.DeleteProductRequest = (function() { + + /** + * Properties of a DeleteProductRequest. + * @memberof google.cloud.retail.v2beta + * @interface IDeleteProductRequest + * @property {string|null} [name] DeleteProductRequest name + */ + + /** + * Constructs a new DeleteProductRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a DeleteProductRequest. + * @implements IDeleteProductRequest + * @constructor + * @param {google.cloud.retail.v2beta.IDeleteProductRequest=} [properties] Properties to set + */ + function DeleteProductRequest(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]]; + } + + /** + * DeleteProductRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @instance + */ + DeleteProductRequest.prototype.name = ""; + + /** + * Creates a new DeleteProductRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteProductRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.DeleteProductRequest} DeleteProductRequest instance + */ + DeleteProductRequest.create = function create(properties) { + return new DeleteProductRequest(properties); + }; + + /** + * Encodes the specified DeleteProductRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteProductRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.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 DeleteProductRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteProductRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteProductRequest} message DeleteProductRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteProductRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteProductRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.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.cloud.retail.v2beta.DeleteProductRequest(); + 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 DeleteProductRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.DeleteProductRequest} DeleteProductRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteProductRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteProductRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteProductRequest.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 DeleteProductRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.DeleteProductRequest} DeleteProductRequest + */ + DeleteProductRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.DeleteProductRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.DeleteProductRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteProductRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {google.cloud.retail.v2beta.DeleteProductRequest} message DeleteProductRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteProductRequest.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 DeleteProductRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteProductRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteProductRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.DeleteProductRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteProductRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.DeleteProductRequest"; + }; + + return DeleteProductRequest; + })(); + + v2beta.ListProductsRequest = (function() { + + /** + * Properties of a ListProductsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IListProductsRequest + * @property {string|null} [parent] ListProductsRequest parent + * @property {number|null} [pageSize] ListProductsRequest pageSize + * @property {string|null} [pageToken] ListProductsRequest pageToken + * @property {string|null} [filter] ListProductsRequest filter + * @property {google.protobuf.IFieldMask|null} [readMask] ListProductsRequest readMask + */ + + /** + * Constructs a new ListProductsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListProductsRequest. + * @implements IListProductsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IListProductsRequest=} [properties] Properties to set + */ + function ListProductsRequest(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]]; + } + + /** + * ListProductsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.parent = ""; + + /** + * ListProductsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageSize = 0; + + /** + * ListProductsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.pageToken = ""; + + /** + * ListProductsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.filter = ""; + + /** + * ListProductsRequest readMask. + * @member {google.protobuf.IFieldMask|null|undefined} readMask + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + */ + ListProductsRequest.prototype.readMask = null; + + /** + * Creates a new ListProductsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IListProductsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListProductsRequest} ListProductsRequest instance + */ + ListProductsRequest.create = function create(properties) { + return new ListProductsRequest(properties); + }; + + /** + * Encodes the specified ListProductsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + if (message.readMask != null && Object.hasOwnProperty.call(message, "readMask")) + $root.google.protobuf.FieldMask.encode(message.readMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListProductsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {google.cloud.retail.v2beta.IListProductsRequest} message ListProductsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.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.cloud.retail.v2beta.ListProductsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + case 5: { + message.readMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListProductsRequest} ListProductsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.readMask != null && message.hasOwnProperty("readMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.readMask); + if (error) + return "readMask." + error; + } + return null; + }; + + /** + * Creates a ListProductsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListProductsRequest} ListProductsRequest + */ + ListProductsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListProductsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ListProductsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + if (object.readMask != null) { + if (typeof object.readMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListProductsRequest.readMask: object expected"); + message.readMask = $root.google.protobuf.FieldMask.fromObject(object.readMask); + } + return message; + }; + + /** + * Creates a plain object from a ListProductsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {google.cloud.retail.v2beta.ListProductsRequest} message ListProductsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + object.readMask = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.readMask != null && message.hasOwnProperty("readMask")) + object.readMask = $root.google.protobuf.FieldMask.toObject(message.readMask, options); + return object; + }; + + /** + * Converts this ListProductsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @instance + * @returns {Object.} JSON object + */ + ListProductsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListProductsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListProductsRequest"; + }; + + return ListProductsRequest; + })(); + + v2beta.ListProductsResponse = (function() { + + /** + * Properties of a ListProductsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IListProductsResponse + * @property {Array.|null} [products] ListProductsResponse products + * @property {string|null} [nextPageToken] ListProductsResponse nextPageToken + */ + + /** + * Constructs a new ListProductsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListProductsResponse. + * @implements IListProductsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IListProductsResponse=} [properties] Properties to set + */ + function ListProductsResponse(properties) { + this.products = []; + 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]]; + } + + /** + * ListProductsResponse products. + * @member {Array.} products + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.products = $util.emptyArray; + + /** + * ListProductsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @instance + */ + ListProductsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListProductsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IListProductsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListProductsResponse} ListProductsResponse instance + */ + ListProductsResponse.create = function create(properties) { + return new ListProductsResponse(properties); + }; + + /** + * Encodes the specified ListProductsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.products != null && message.products.length) + for (var i = 0; i < message.products.length; ++i) + $root.google.cloud.retail.v2beta.Product.encode(message.products[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 ListProductsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListProductsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {google.cloud.retail.v2beta.IListProductsResponse} message ListProductsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListProductsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.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.cloud.retail.v2beta.ListProductsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.products && message.products.length)) + message.products = []; + message.products.push($root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListProductsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListProductsResponse} ListProductsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListProductsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListProductsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListProductsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.products != null && message.hasOwnProperty("products")) { + if (!Array.isArray(message.products)) + return "products: array expected"; + for (var i = 0; i < message.products.length; ++i) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.products[i]); + if (error) + return "products." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListProductsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListProductsResponse} ListProductsResponse + */ + ListProductsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListProductsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ListProductsResponse(); + if (object.products) { + if (!Array.isArray(object.products)) + throw TypeError(".google.cloud.retail.v2beta.ListProductsResponse.products: array expected"); + message.products = []; + for (var i = 0; i < object.products.length; ++i) { + if (typeof object.products[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListProductsResponse.products: object expected"); + message.products[i] = $root.google.cloud.retail.v2beta.Product.fromObject(object.products[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListProductsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {google.cloud.retail.v2beta.ListProductsResponse} message ListProductsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListProductsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.products = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.products && message.products.length) { + object.products = []; + for (var j = 0; j < message.products.length; ++j) + object.products[j] = $root.google.cloud.retail.v2beta.Product.toObject(message.products[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListProductsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @instance + * @returns {Object.} JSON object + */ + ListProductsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListProductsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListProductsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListProductsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListProductsResponse"; + }; + + return ListProductsResponse; + })(); + + v2beta.SetInventoryRequest = (function() { + + /** + * Properties of a SetInventoryRequest. + * @memberof google.cloud.retail.v2beta + * @interface ISetInventoryRequest + * @property {google.cloud.retail.v2beta.IProduct|null} [inventory] SetInventoryRequest inventory + * @property {google.protobuf.IFieldMask|null} [setMask] SetInventoryRequest setMask + * @property {google.protobuf.ITimestamp|null} [setTime] SetInventoryRequest setTime + * @property {boolean|null} [allowMissing] SetInventoryRequest allowMissing + */ + + /** + * Constructs a new SetInventoryRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SetInventoryRequest. + * @implements ISetInventoryRequest + * @constructor + * @param {google.cloud.retail.v2beta.ISetInventoryRequest=} [properties] Properties to set + */ + function SetInventoryRequest(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]]; + } + + /** + * SetInventoryRequest inventory. + * @member {google.cloud.retail.v2beta.IProduct|null|undefined} inventory + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.inventory = null; + + /** + * SetInventoryRequest setMask. + * @member {google.protobuf.IFieldMask|null|undefined} setMask + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setMask = null; + + /** + * SetInventoryRequest setTime. + * @member {google.protobuf.ITimestamp|null|undefined} setTime + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.setTime = null; + + /** + * SetInventoryRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @instance + */ + SetInventoryRequest.prototype.allowMissing = false; + + /** + * Creates a new SetInventoryRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SetInventoryRequest} SetInventoryRequest instance + */ + SetInventoryRequest.create = function create(properties) { + return new SetInventoryRequest(properties); + }; + + /** + * Encodes the specified SetInventoryRequest message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inventory != null && Object.hasOwnProperty.call(message, "inventory")) + $root.google.cloud.retail.v2beta.Product.encode(message.inventory, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.setMask != null && Object.hasOwnProperty.call(message, "setMask")) + $root.google.protobuf.FieldMask.encode(message.setMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.setTime != null && Object.hasOwnProperty.call(message, "setTime")) + $root.google.protobuf.Timestamp.encode(message.setTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified SetInventoryRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryRequest} message SetInventoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.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.cloud.retail.v2beta.SetInventoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inventory = $root.google.cloud.retail.v2beta.Product.decode(reader, reader.uint32()); + break; + } + case 2: { + message.setMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 3: { + message.setTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SetInventoryRequest} SetInventoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inventory != null && message.hasOwnProperty("inventory")) { + var error = $root.google.cloud.retail.v2beta.Product.verify(message.inventory); + if (error) + return "inventory." + error; + } + if (message.setMask != null && message.hasOwnProperty("setMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.setMask); + if (error) + return "setMask." + error; + } + if (message.setTime != null && message.hasOwnProperty("setTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.setTime); + if (error) + return "setTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a SetInventoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SetInventoryRequest} SetInventoryRequest + */ + SetInventoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SetInventoryRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.SetInventoryRequest(); + if (object.inventory != null) { + if (typeof object.inventory !== "object") + throw TypeError(".google.cloud.retail.v2beta.SetInventoryRequest.inventory: object expected"); + message.inventory = $root.google.cloud.retail.v2beta.Product.fromObject(object.inventory); + } + if (object.setMask != null) { + if (typeof object.setMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.SetInventoryRequest.setMask: object expected"); + message.setMask = $root.google.protobuf.FieldMask.fromObject(object.setMask); + } + if (object.setTime != null) { + if (typeof object.setTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.SetInventoryRequest.setTime: object expected"); + message.setTime = $root.google.protobuf.Timestamp.fromObject(object.setTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a SetInventoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {google.cloud.retail.v2beta.SetInventoryRequest} message SetInventoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.inventory = null; + object.setMask = null; + object.setTime = null; + object.allowMissing = false; + } + if (message.inventory != null && message.hasOwnProperty("inventory")) + object.inventory = $root.google.cloud.retail.v2beta.Product.toObject(message.inventory, options); + if (message.setMask != null && message.hasOwnProperty("setMask")) + object.setMask = $root.google.protobuf.FieldMask.toObject(message.setMask, options); + if (message.setTime != null && message.hasOwnProperty("setTime")) + object.setTime = $root.google.protobuf.Timestamp.toObject(message.setTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this SetInventoryRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @instance + * @returns {Object.} JSON object + */ + SetInventoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SetInventoryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SetInventoryRequest"; + }; + + return SetInventoryRequest; + })(); + + v2beta.SetInventoryMetadata = (function() { + + /** + * Properties of a SetInventoryMetadata. + * @memberof google.cloud.retail.v2beta + * @interface ISetInventoryMetadata + */ + + /** + * Constructs a new SetInventoryMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SetInventoryMetadata. + * @implements ISetInventoryMetadata + * @constructor + * @param {google.cloud.retail.v2beta.ISetInventoryMetadata=} [properties] Properties to set + */ + function SetInventoryMetadata(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 SetInventoryMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SetInventoryMetadata} SetInventoryMetadata instance + */ + SetInventoryMetadata.create = function create(properties) { + return new SetInventoryMetadata(properties); + }; + + /** + * Encodes the specified SetInventoryMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryMetadata} message SetInventoryMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.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.cloud.retail.v2beta.SetInventoryMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SetInventoryMetadata} SetInventoryMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SetInventoryMetadata} SetInventoryMetadata + */ + SetInventoryMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SetInventoryMetadata) + return object; + return new $root.google.cloud.retail.v2beta.SetInventoryMetadata(); + }; + + /** + * Creates a plain object from a SetInventoryMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {google.cloud.retail.v2beta.SetInventoryMetadata} message SetInventoryMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @instance + * @returns {Object.} JSON object + */ + SetInventoryMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SetInventoryMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SetInventoryMetadata"; + }; + + return SetInventoryMetadata; + })(); + + v2beta.SetInventoryResponse = (function() { + + /** + * Properties of a SetInventoryResponse. + * @memberof google.cloud.retail.v2beta + * @interface ISetInventoryResponse + */ + + /** + * Constructs a new SetInventoryResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a SetInventoryResponse. + * @implements ISetInventoryResponse + * @constructor + * @param {google.cloud.retail.v2beta.ISetInventoryResponse=} [properties] Properties to set + */ + function SetInventoryResponse(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 SetInventoryResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.SetInventoryResponse} SetInventoryResponse instance + */ + SetInventoryResponse.create = function create(properties) { + return new SetInventoryResponse(properties); + }; + + /** + * Encodes the specified SetInventoryResponse message. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified SetInventoryResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.SetInventoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2beta.ISetInventoryResponse} message SetInventoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetInventoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.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.cloud.retail.v2beta.SetInventoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SetInventoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.SetInventoryResponse} SetInventoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetInventoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SetInventoryResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetInventoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a SetInventoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.SetInventoryResponse} SetInventoryResponse + */ + SetInventoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.SetInventoryResponse) + return object; + return new $root.google.cloud.retail.v2beta.SetInventoryResponse(); + }; + + /** + * Creates a plain object from a SetInventoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {google.cloud.retail.v2beta.SetInventoryResponse} message SetInventoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetInventoryResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this SetInventoryResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @instance + * @returns {Object.} JSON object + */ + SetInventoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SetInventoryResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.SetInventoryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SetInventoryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.SetInventoryResponse"; + }; + + return SetInventoryResponse; + })(); + + v2beta.AddFulfillmentPlacesRequest = (function() { + + /** + * Properties of an AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2beta + * @interface IAddFulfillmentPlacesRequest + * @property {string|null} [product] AddFulfillmentPlacesRequest product + * @property {string|null} [type] AddFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] AddFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [addTime] AddFulfillmentPlacesRequest addTime + * @property {boolean|null} [allowMissing] AddFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new AddFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddFulfillmentPlacesRequest. + * @implements IAddFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest=} [properties] Properties to set + */ + function AddFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * AddFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.product = ""; + + /** + * AddFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.type = ""; + + /** + * AddFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * AddFulfillmentPlacesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.addTime = null; + + /** + * AddFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + */ + AddFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest instance + */ + AddFulfillmentPlacesRequest.create = function create(properties) { + return new AddFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.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.cloud.retail.v2beta.AddFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesRequest} AddFulfillmentPlacesRequest + */ + AddFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.AddFulfillmentPlacesRequest} message AddFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddFulfillmentPlacesRequest"; + }; + + return AddFulfillmentPlacesRequest; + })(); + + v2beta.AddFulfillmentPlacesMetadata = (function() { + + /** + * Properties of an AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IAddFulfillmentPlacesMetadata + */ + + /** + * Constructs a new AddFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddFulfillmentPlacesMetadata. + * @implements IAddFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function AddFulfillmentPlacesMetadata(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 AddFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata instance + */ + AddFulfillmentPlacesMetadata.create = function create(properties) { + return new AddFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.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.cloud.retail.v2beta.AddFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata} AddFulfillmentPlacesMetadata + */ + AddFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata} message AddFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata"; + }; + + return AddFulfillmentPlacesMetadata; + })(); + + v2beta.AddFulfillmentPlacesResponse = (function() { + + /** + * Properties of an AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2beta + * @interface IAddFulfillmentPlacesResponse + */ + + /** + * Constructs a new AddFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddFulfillmentPlacesResponse. + * @implements IAddFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse=} [properties] Properties to set + */ + function AddFulfillmentPlacesResponse(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 AddFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse instance + */ + AddFulfillmentPlacesResponse.create = function create(properties) { + return new AddFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.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.cloud.retail.v2beta.AddFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddFulfillmentPlacesResponse} AddFulfillmentPlacesResponse + */ + AddFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from an AddFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.AddFulfillmentPlacesResponse} message AddFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + AddFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddFulfillmentPlacesResponse"; + }; + + return AddFulfillmentPlacesResponse; + })(); + + v2beta.AddLocalInventoriesRequest = (function() { + + /** + * Properties of an AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2beta + * @interface IAddLocalInventoriesRequest + * @property {string|null} [product] AddLocalInventoriesRequest product + * @property {Array.|null} [localInventories] AddLocalInventoriesRequest localInventories + * @property {google.protobuf.IFieldMask|null} [addMask] AddLocalInventoriesRequest addMask + * @property {google.protobuf.ITimestamp|null} [addTime] AddLocalInventoriesRequest addTime + * @property {boolean|null} [allowMissing] AddLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new AddLocalInventoriesRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddLocalInventoriesRequest. + * @implements IAddLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest=} [properties] Properties to set + */ + function AddLocalInventoriesRequest(properties) { + this.localInventories = []; + 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]]; + } + + /** + * AddLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.product = ""; + + /** + * AddLocalInventoriesRequest localInventories. + * @member {Array.} localInventories + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.localInventories = $util.emptyArray; + + /** + * AddLocalInventoriesRequest addMask. + * @member {google.protobuf.IFieldMask|null|undefined} addMask + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addMask = null; + + /** + * AddLocalInventoriesRequest addTime. + * @member {google.protobuf.ITimestamp|null|undefined} addTime + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.addTime = null; + + /** + * AddLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + */ + AddLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new AddLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesRequest} AddLocalInventoriesRequest instance + */ + AddLocalInventoriesRequest.create = function create(properties) { + return new AddLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.localInventories != null && message.localInventories.length) + for (var i = 0; i < message.localInventories.length; ++i) + $root.google.cloud.retail.v2beta.LocalInventory.encode(message.localInventories[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.addMask != null && Object.hasOwnProperty.call(message, "addMask")) + $root.google.protobuf.FieldMask.encode(message.addMask, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.addTime != null && Object.hasOwnProperty.call(message, "addTime")) + $root.google.protobuf.Timestamp.encode(message.addTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesRequest} message AddLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.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.cloud.retail.v2beta.AddLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.localInventories && message.localInventories.length)) + message.localInventories = []; + message.localInventories.push($root.google.cloud.retail.v2beta.LocalInventory.decode(reader, reader.uint32())); + break; + } + case 4: { + message.addMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + case 5: { + message.addTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesRequest} AddLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.localInventories != null && message.hasOwnProperty("localInventories")) { + if (!Array.isArray(message.localInventories)) + return "localInventories: array expected"; + for (var i = 0; i < message.localInventories.length; ++i) { + var error = $root.google.cloud.retail.v2beta.LocalInventory.verify(message.localInventories[i]); + if (error) + return "localInventories." + error; + } + } + if (message.addMask != null && message.hasOwnProperty("addMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.addMask); + if (error) + return "addMask." + error; + } + if (message.addTime != null && message.hasOwnProperty("addTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.addTime); + if (error) + return "addTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesRequest} AddLocalInventoriesRequest + */ + AddLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.AddLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.localInventories) { + if (!Array.isArray(object.localInventories)) + throw TypeError(".google.cloud.retail.v2beta.AddLocalInventoriesRequest.localInventories: array expected"); + message.localInventories = []; + for (var i = 0; i < object.localInventories.length; ++i) { + if (typeof object.localInventories[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.AddLocalInventoriesRequest.localInventories: object expected"); + message.localInventories[i] = $root.google.cloud.retail.v2beta.LocalInventory.fromObject(object.localInventories[i]); + } + } + if (object.addMask != null) { + if (typeof object.addMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.AddLocalInventoriesRequest.addMask: object expected"); + message.addMask = $root.google.protobuf.FieldMask.fromObject(object.addMask); + } + if (object.addTime != null) { + if (typeof object.addTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.AddLocalInventoriesRequest.addTime: object expected"); + message.addTime = $root.google.protobuf.Timestamp.fromObject(object.addTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from an AddLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.AddLocalInventoriesRequest} message AddLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.localInventories = []; + if (options.defaults) { + object.product = ""; + object.addMask = null; + object.addTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.localInventories && message.localInventories.length) { + object.localInventories = []; + for (var j = 0; j < message.localInventories.length; ++j) + object.localInventories[j] = $root.google.cloud.retail.v2beta.LocalInventory.toObject(message.localInventories[j], options); + } + if (message.addMask != null && message.hasOwnProperty("addMask")) + object.addMask = $root.google.protobuf.FieldMask.toObject(message.addMask, options); + if (message.addTime != null && message.hasOwnProperty("addTime")) + object.addTime = $root.google.protobuf.Timestamp.toObject(message.addTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this AddLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddLocalInventoriesRequest"; + }; + + return AddLocalInventoriesRequest; + })(); + + v2beta.AddLocalInventoriesMetadata = (function() { + + /** + * Properties of an AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IAddLocalInventoriesMetadata + */ + + /** + * Constructs a new AddLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddLocalInventoriesMetadata. + * @implements IAddLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesMetadata=} [properties] Properties to set + */ + function AddLocalInventoriesMetadata(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 AddLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata instance + */ + AddLocalInventoriesMetadata.create = function create(properties) { + return new AddLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesMetadata} message AddLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.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.cloud.retail.v2beta.AddLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesMetadata} AddLocalInventoriesMetadata + */ + AddLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2beta.AddLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.AddLocalInventoriesMetadata} message AddLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddLocalInventoriesMetadata"; + }; + + return AddLocalInventoriesMetadata; + })(); + + v2beta.AddLocalInventoriesResponse = (function() { + + /** + * Properties of an AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2beta + * @interface IAddLocalInventoriesResponse + */ + + /** + * Constructs a new AddLocalInventoriesResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddLocalInventoriesResponse. + * @implements IAddLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesResponse=} [properties] Properties to set + */ + function AddLocalInventoriesResponse(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 AddLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesResponse} AddLocalInventoriesResponse instance + */ + AddLocalInventoriesResponse.create = function create(properties) { + return new AddLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified AddLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IAddLocalInventoriesResponse} message AddLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.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.cloud.retail.v2beta.AddLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesResponse} AddLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an AddLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddLocalInventoriesResponse} AddLocalInventoriesResponse + */ + AddLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2beta.AddLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from an AddLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.AddLocalInventoriesResponse} message AddLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this AddLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + AddLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddLocalInventoriesResponse"; + }; + + return AddLocalInventoriesResponse; + })(); + + v2beta.RemoveLocalInventoriesRequest = (function() { + + /** + * Properties of a RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveLocalInventoriesRequest + * @property {string|null} [product] RemoveLocalInventoriesRequest product + * @property {Array.|null} [placeIds] RemoveLocalInventoriesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveLocalInventoriesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveLocalInventoriesRequest allowMissing + */ + + /** + * Constructs a new RemoveLocalInventoriesRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveLocalInventoriesRequest. + * @implements IRemoveLocalInventoriesRequest + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest=} [properties] Properties to set + */ + function RemoveLocalInventoriesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveLocalInventoriesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.product = ""; + + /** + * RemoveLocalInventoriesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveLocalInventoriesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.removeTime = null; + + /** + * RemoveLocalInventoriesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @instance + */ + RemoveLocalInventoriesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveLocalInventoriesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest instance + */ + RemoveLocalInventoriesRequest.create = function create(properties) { + return new RemoveLocalInventoriesRequest(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.placeIds[i]); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowMissing); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.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.cloud.retail.v2beta.RemoveLocalInventoriesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 5: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesRequest} RemoveLocalInventoriesRequest + */ + RemoveLocalInventoriesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.RemoveLocalInventoriesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {google.cloud.retail.v2beta.RemoveLocalInventoriesRequest} message RemoveLocalInventoriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.allowMissing = false; + object.removeTime = null; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + return object; + }; + + /** + * Converts this RemoveLocalInventoriesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveLocalInventoriesRequest"; + }; + + return RemoveLocalInventoriesRequest; + })(); + + v2beta.RemoveLocalInventoriesMetadata = (function() { + + /** + * Properties of a RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveLocalInventoriesMetadata + */ + + /** + * Constructs a new RemoveLocalInventoriesMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveLocalInventoriesMetadata. + * @implements IRemoveLocalInventoriesMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + */ + function RemoveLocalInventoriesMetadata(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 RemoveLocalInventoriesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata instance + */ + RemoveLocalInventoriesMetadata.create = function create(properties) { + return new RemoveLocalInventoriesMetadata(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.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.cloud.retail.v2beta.RemoveLocalInventoriesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata} RemoveLocalInventoriesMetadata + */ + RemoveLocalInventoriesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata) + return object; + return new $root.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata} message RemoveLocalInventoriesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata"; + }; + + return RemoveLocalInventoriesMetadata; + })(); + + v2beta.RemoveLocalInventoriesResponse = (function() { + + /** + * Properties of a RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveLocalInventoriesResponse + */ + + /** + * Constructs a new RemoveLocalInventoriesResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveLocalInventoriesResponse. + * @implements IRemoveLocalInventoriesResponse + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse=} [properties] Properties to set + */ + function RemoveLocalInventoriesResponse(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 RemoveLocalInventoriesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse instance + */ + RemoveLocalInventoriesResponse.create = function create(properties) { + return new RemoveLocalInventoriesResponse(properties); + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveLocalInventoriesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveLocalInventoriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveLocalInventoriesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.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.cloud.retail.v2beta.RemoveLocalInventoriesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveLocalInventoriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveLocalInventoriesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveLocalInventoriesResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveLocalInventoriesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveLocalInventoriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveLocalInventoriesResponse} RemoveLocalInventoriesResponse + */ + RemoveLocalInventoriesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse) + return object; + return new $root.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse(); + }; + + /** + * Creates a plain object from a RemoveLocalInventoriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {google.cloud.retail.v2beta.RemoveLocalInventoriesResponse} message RemoveLocalInventoriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveLocalInventoriesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveLocalInventoriesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveLocalInventoriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveLocalInventoriesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveLocalInventoriesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveLocalInventoriesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveLocalInventoriesResponse"; + }; + + return RemoveLocalInventoriesResponse; + })(); + + v2beta.RemoveFulfillmentPlacesRequest = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveFulfillmentPlacesRequest + * @property {string|null} [product] RemoveFulfillmentPlacesRequest product + * @property {string|null} [type] RemoveFulfillmentPlacesRequest type + * @property {Array.|null} [placeIds] RemoveFulfillmentPlacesRequest placeIds + * @property {google.protobuf.ITimestamp|null} [removeTime] RemoveFulfillmentPlacesRequest removeTime + * @property {boolean|null} [allowMissing] RemoveFulfillmentPlacesRequest allowMissing + */ + + /** + * Constructs a new RemoveFulfillmentPlacesRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveFulfillmentPlacesRequest. + * @implements IRemoveFulfillmentPlacesRequest + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesRequest(properties) { + this.placeIds = []; + 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]]; + } + + /** + * RemoveFulfillmentPlacesRequest product. + * @member {string} product + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.product = ""; + + /** + * RemoveFulfillmentPlacesRequest type. + * @member {string} type + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.type = ""; + + /** + * RemoveFulfillmentPlacesRequest placeIds. + * @member {Array.} placeIds + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.placeIds = $util.emptyArray; + + /** + * RemoveFulfillmentPlacesRequest removeTime. + * @member {google.protobuf.ITimestamp|null|undefined} removeTime + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.removeTime = null; + + /** + * RemoveFulfillmentPlacesRequest allowMissing. + * @member {boolean} allowMissing + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + */ + RemoveFulfillmentPlacesRequest.prototype.allowMissing = false; + + /** + * Creates a new RemoveFulfillmentPlacesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest instance + */ + RemoveFulfillmentPlacesRequest.create = function create(properties) { + return new RemoveFulfillmentPlacesRequest(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.product); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.placeIds != null && message.placeIds.length) + for (var i = 0; i < message.placeIds.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.placeIds[i]); + if (message.removeTime != null && Object.hasOwnProperty.call(message, "removeTime")) + $root.google.protobuf.Timestamp.encode(message.removeTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.allowMissing != null && Object.hasOwnProperty.call(message, "allowMissing")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.allowMissing); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.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.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.product = reader.string(); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + if (!(message.placeIds && message.placeIds.length)) + message.placeIds = []; + message.placeIds.push(reader.string()); + break; + } + case 4: { + message.removeTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.allowMissing = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.product != null && message.hasOwnProperty("product")) + if (!$util.isString(message.product)) + return "product: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.placeIds != null && message.hasOwnProperty("placeIds")) { + if (!Array.isArray(message.placeIds)) + return "placeIds: array expected"; + for (var i = 0; i < message.placeIds.length; ++i) + if (!$util.isString(message.placeIds[i])) + return "placeIds: string[] expected"; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.removeTime); + if (error) + return "removeTime." + error; + } + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + if (typeof message.allowMissing !== "boolean") + return "allowMissing: boolean expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest} RemoveFulfillmentPlacesRequest + */ + RemoveFulfillmentPlacesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest(); + if (object.product != null) + message.product = String(object.product); + if (object.type != null) + message.type = String(object.type); + if (object.placeIds) { + if (!Array.isArray(object.placeIds)) + throw TypeError(".google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.placeIds: array expected"); + message.placeIds = []; + for (var i = 0; i < object.placeIds.length; ++i) + message.placeIds[i] = String(object.placeIds[i]); + } + if (object.removeTime != null) { + if (typeof object.removeTime !== "object") + throw TypeError(".google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.removeTime: object expected"); + message.removeTime = $root.google.protobuf.Timestamp.fromObject(object.removeTime); + } + if (object.allowMissing != null) + message.allowMissing = Boolean(object.allowMissing); + return message; + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest} message RemoveFulfillmentPlacesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.placeIds = []; + if (options.defaults) { + object.product = ""; + object.type = ""; + object.removeTime = null; + object.allowMissing = false; + } + if (message.product != null && message.hasOwnProperty("product")) + object.product = message.product; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.placeIds && message.placeIds.length) { + object.placeIds = []; + for (var j = 0; j < message.placeIds.length; ++j) + object.placeIds[j] = message.placeIds[j]; + } + if (message.removeTime != null && message.hasOwnProperty("removeTime")) + object.removeTime = $root.google.protobuf.Timestamp.toObject(message.removeTime, options); + if (message.allowMissing != null && message.hasOwnProperty("allowMissing")) + object.allowMissing = message.allowMissing; + return object; + }; + + /** + * Converts this RemoveFulfillmentPlacesRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest"; + }; + + return RemoveFulfillmentPlacesRequest; + })(); + + v2beta.RemoveFulfillmentPlacesMetadata = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveFulfillmentPlacesMetadata + */ + + /** + * Constructs a new RemoveFulfillmentPlacesMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveFulfillmentPlacesMetadata. + * @implements IRemoveFulfillmentPlacesMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesMetadata(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 RemoveFulfillmentPlacesMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata instance + */ + RemoveFulfillmentPlacesMetadata.create = function create(properties) { + return new RemoveFulfillmentPlacesMetadata(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.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.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata} RemoveFulfillmentPlacesMetadata + */ + RemoveFulfillmentPlacesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata) + return object; + return new $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata} message RemoveFulfillmentPlacesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata"; + }; + + return RemoveFulfillmentPlacesMetadata; + })(); + + v2beta.RemoveFulfillmentPlacesResponse = (function() { + + /** + * Properties of a RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveFulfillmentPlacesResponse + */ + + /** + * Constructs a new RemoveFulfillmentPlacesResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveFulfillmentPlacesResponse. + * @implements IRemoveFulfillmentPlacesResponse + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + */ + function RemoveFulfillmentPlacesResponse(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 RemoveFulfillmentPlacesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse instance + */ + RemoveFulfillmentPlacesResponse.create = function create(properties) { + return new RemoveFulfillmentPlacesResponse(properties); + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RemoveFulfillmentPlacesResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveFulfillmentPlacesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.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.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveFulfillmentPlacesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveFulfillmentPlacesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveFulfillmentPlacesResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveFulfillmentPlacesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RemoveFulfillmentPlacesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse} RemoveFulfillmentPlacesResponse + */ + RemoveFulfillmentPlacesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse) + return object; + return new $root.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse(); + }; + + /** + * Creates a plain object from a RemoveFulfillmentPlacesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse} message RemoveFulfillmentPlacesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveFulfillmentPlacesResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RemoveFulfillmentPlacesResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @instance + * @returns {Object.} JSON object + */ + RemoveFulfillmentPlacesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveFulfillmentPlacesResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveFulfillmentPlacesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse"; + }; + + return RemoveFulfillmentPlacesResponse; + })(); + + v2beta.PurgeMetadata = (function() { + + /** + * Properties of a PurgeMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IPurgeMetadata + */ + + /** + * Constructs a new PurgeMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PurgeMetadata. + * @implements IPurgeMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IPurgeMetadata=} [properties] Properties to set + */ + function PurgeMetadata(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 PurgeMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {google.cloud.retail.v2beta.IPurgeMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PurgeMetadata} PurgeMetadata instance + */ + PurgeMetadata.create = function create(properties) { + return new PurgeMetadata(properties); + }; + + /** + * Encodes the specified PurgeMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {google.cloud.retail.v2beta.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified PurgeMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {google.cloud.retail.v2beta.IPurgeMetadata} message PurgeMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.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.cloud.retail.v2beta.PurgeMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PurgeMetadata} PurgeMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a PurgeMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PurgeMetadata} PurgeMetadata + */ + PurgeMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PurgeMetadata) + return object; + return new $root.google.cloud.retail.v2beta.PurgeMetadata(); + }; + + /** + * Creates a plain object from a PurgeMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {google.cloud.retail.v2beta.PurgeMetadata} message PurgeMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this PurgeMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @instance + * @returns {Object.} JSON object + */ + PurgeMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PurgeMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PurgeMetadata"; + }; + + return PurgeMetadata; + })(); + + v2beta.PurgeUserEventsRequest = (function() { + + /** + * Properties of a PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IPurgeUserEventsRequest + * @property {string|null} [parent] PurgeUserEventsRequest parent + * @property {string|null} [filter] PurgeUserEventsRequest filter + * @property {boolean|null} [force] PurgeUserEventsRequest force + */ + + /** + * Constructs a new PurgeUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PurgeUserEventsRequest. + * @implements IPurgeUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest=} [properties] Properties to set + */ + function PurgeUserEventsRequest(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]]; + } + + /** + * PurgeUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.parent = ""; + + /** + * PurgeUserEventsRequest filter. + * @member {string} filter + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.filter = ""; + + /** + * PurgeUserEventsRequest force. + * @member {boolean} force + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @instance + */ + PurgeUserEventsRequest.prototype.force = false; + + /** + * Creates a new PurgeUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PurgeUserEventsRequest} PurgeUserEventsRequest instance + */ + PurgeUserEventsRequest.create = function create(properties) { + return new PurgeUserEventsRequest(properties); + }; + + /** + * Encodes the specified PurgeUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.filter); + if (message.force != null && Object.hasOwnProperty.call(message, "force")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.force); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest} message PurgeUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.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.cloud.retail.v2beta.PurgeUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.filter = reader.string(); + break; + } + case 3: { + message.force = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PurgeUserEventsRequest} PurgeUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.force != null && message.hasOwnProperty("force")) + if (typeof message.force !== "boolean") + return "force: boolean expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PurgeUserEventsRequest} PurgeUserEventsRequest + */ + PurgeUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PurgeUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.PurgeUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.filter != null) + message.filter = String(object.filter); + if (object.force != null) + message.force = Boolean(object.force); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.PurgeUserEventsRequest} message PurgeUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.filter = ""; + object.force = false; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.force != null && message.hasOwnProperty("force")) + object.force = message.force; + return object; + }; + + /** + * Converts this PurgeUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PurgeUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PurgeUserEventsRequest"; + }; + + return PurgeUserEventsRequest; + })(); + + v2beta.PurgeUserEventsResponse = (function() { + + /** + * Properties of a PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IPurgeUserEventsResponse + * @property {number|Long|null} [purgedEventsCount] PurgeUserEventsResponse purgedEventsCount + */ + + /** + * Constructs a new PurgeUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a PurgeUserEventsResponse. + * @implements IPurgeUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IPurgeUserEventsResponse=} [properties] Properties to set + */ + function PurgeUserEventsResponse(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]]; + } + + /** + * PurgeUserEventsResponse purgedEventsCount. + * @member {number|Long} purgedEventsCount + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @instance + */ + PurgeUserEventsResponse.prototype.purgedEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new PurgeUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.PurgeUserEventsResponse} PurgeUserEventsResponse instance + */ + PurgeUserEventsResponse.create = function create(properties) { + return new PurgeUserEventsResponse(properties); + }; + + /** + * Encodes the specified PurgeUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.purgedEventsCount != null && Object.hasOwnProperty.call(message, "purgedEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.purgedEventsCount); + return writer; + }; + + /** + * Encodes the specified PurgeUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.PurgeUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IPurgeUserEventsResponse} message PurgeUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PurgeUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.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.cloud.retail.v2beta.PurgeUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.purgedEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PurgeUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.PurgeUserEventsResponse} PurgeUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PurgeUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PurgeUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PurgeUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (!$util.isInteger(message.purgedEventsCount) && !(message.purgedEventsCount && $util.isInteger(message.purgedEventsCount.low) && $util.isInteger(message.purgedEventsCount.high))) + return "purgedEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a PurgeUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.PurgeUserEventsResponse} PurgeUserEventsResponse + */ + PurgeUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.PurgeUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.PurgeUserEventsResponse(); + if (object.purgedEventsCount != null) + if ($util.Long) + (message.purgedEventsCount = $util.Long.fromValue(object.purgedEventsCount)).unsigned = false; + else if (typeof object.purgedEventsCount === "string") + message.purgedEventsCount = parseInt(object.purgedEventsCount, 10); + else if (typeof object.purgedEventsCount === "number") + message.purgedEventsCount = object.purgedEventsCount; + else if (typeof object.purgedEventsCount === "object") + message.purgedEventsCount = new $util.LongBits(object.purgedEventsCount.low >>> 0, object.purgedEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a PurgeUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.PurgeUserEventsResponse} message PurgeUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PurgeUserEventsResponse.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.purgedEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.purgedEventsCount = options.longs === String ? "0" : 0; + if (message.purgedEventsCount != null && message.hasOwnProperty("purgedEventsCount")) + if (typeof message.purgedEventsCount === "number") + object.purgedEventsCount = options.longs === String ? String(message.purgedEventsCount) : message.purgedEventsCount; + else + object.purgedEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.purgedEventsCount) : options.longs === Number ? new $util.LongBits(message.purgedEventsCount.low >>> 0, message.purgedEventsCount.high >>> 0).toNumber() : message.purgedEventsCount; + return object; + }; + + /** + * Converts this PurgeUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + PurgeUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PurgeUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.PurgeUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PurgeUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.PurgeUserEventsResponse"; + }; + + return PurgeUserEventsResponse; + })(); + + v2beta.ServingConfig = (function() { + + /** + * Properties of a ServingConfig. + * @memberof google.cloud.retail.v2beta + * @interface IServingConfig + * @property {string|null} [name] ServingConfig name + * @property {string|null} [displayName] ServingConfig displayName + * @property {string|null} [modelId] ServingConfig modelId + * @property {string|null} [priceRerankingLevel] ServingConfig priceRerankingLevel + * @property {Array.|null} [facetControlIds] ServingConfig facetControlIds + * @property {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null} [dynamicFacetSpec] ServingConfig dynamicFacetSpec + * @property {Array.|null} [boostControlIds] ServingConfig boostControlIds + * @property {Array.|null} [filterControlIds] ServingConfig filterControlIds + * @property {Array.|null} [redirectControlIds] ServingConfig redirectControlIds + * @property {Array.|null} [twowaySynonymsControlIds] ServingConfig twowaySynonymsControlIds + * @property {Array.|null} [onewaySynonymsControlIds] ServingConfig onewaySynonymsControlIds + * @property {Array.|null} [doNotAssociateControlIds] ServingConfig doNotAssociateControlIds + * @property {Array.|null} [replacementControlIds] ServingConfig replacementControlIds + * @property {Array.|null} [ignoreControlIds] ServingConfig ignoreControlIds + * @property {string|null} [diversityLevel] ServingConfig diversityLevel + * @property {google.cloud.retail.v2beta.ServingConfig.DiversityType|null} [diversityType] ServingConfig diversityType + * @property {string|null} [enableCategoryFilterLevel] ServingConfig enableCategoryFilterLevel + * @property {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null} [personalizationSpec] ServingConfig personalizationSpec + * @property {Array.|null} [solutionTypes] ServingConfig solutionTypes + */ + + /** + * Constructs a new ServingConfig. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ServingConfig. + * @implements IServingConfig + * @constructor + * @param {google.cloud.retail.v2beta.IServingConfig=} [properties] Properties to set + */ + function ServingConfig(properties) { + this.facetControlIds = []; + this.boostControlIds = []; + this.filterControlIds = []; + this.redirectControlIds = []; + this.twowaySynonymsControlIds = []; + this.onewaySynonymsControlIds = []; + this.doNotAssociateControlIds = []; + this.replacementControlIds = []; + this.ignoreControlIds = []; + this.solutionTypes = []; + 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]]; + } + + /** + * ServingConfig name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.name = ""; + + /** + * ServingConfig displayName. + * @member {string} displayName + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.displayName = ""; + + /** + * ServingConfig modelId. + * @member {string} modelId + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.modelId = ""; + + /** + * ServingConfig priceRerankingLevel. + * @member {string} priceRerankingLevel + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.priceRerankingLevel = ""; + + /** + * ServingConfig facetControlIds. + * @member {Array.} facetControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.facetControlIds = $util.emptyArray; + + /** + * ServingConfig dynamicFacetSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IDynamicFacetSpec|null|undefined} dynamicFacetSpec + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.dynamicFacetSpec = null; + + /** + * ServingConfig boostControlIds. + * @member {Array.} boostControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.boostControlIds = $util.emptyArray; + + /** + * ServingConfig filterControlIds. + * @member {Array.} filterControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.filterControlIds = $util.emptyArray; + + /** + * ServingConfig redirectControlIds. + * @member {Array.} redirectControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.redirectControlIds = $util.emptyArray; + + /** + * ServingConfig twowaySynonymsControlIds. + * @member {Array.} twowaySynonymsControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.twowaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig onewaySynonymsControlIds. + * @member {Array.} onewaySynonymsControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.onewaySynonymsControlIds = $util.emptyArray; + + /** + * ServingConfig doNotAssociateControlIds. + * @member {Array.} doNotAssociateControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.doNotAssociateControlIds = $util.emptyArray; + + /** + * ServingConfig replacementControlIds. + * @member {Array.} replacementControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.replacementControlIds = $util.emptyArray; + + /** + * ServingConfig ignoreControlIds. + * @member {Array.} ignoreControlIds + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.ignoreControlIds = $util.emptyArray; + + /** + * ServingConfig diversityLevel. + * @member {string} diversityLevel + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.diversityLevel = ""; + + /** + * ServingConfig diversityType. + * @member {google.cloud.retail.v2beta.ServingConfig.DiversityType} diversityType + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.diversityType = 0; + + /** + * ServingConfig enableCategoryFilterLevel. + * @member {string} enableCategoryFilterLevel + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.enableCategoryFilterLevel = ""; + + /** + * ServingConfig personalizationSpec. + * @member {google.cloud.retail.v2beta.SearchRequest.IPersonalizationSpec|null|undefined} personalizationSpec + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.personalizationSpec = null; + + /** + * ServingConfig solutionTypes. + * @member {Array.} solutionTypes + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + */ + ServingConfig.prototype.solutionTypes = $util.emptyArray; + + /** + * Creates a new ServingConfig instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {google.cloud.retail.v2beta.IServingConfig=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ServingConfig} ServingConfig instance + */ + ServingConfig.create = function create(properties) { + return new ServingConfig(properties); + }; + + /** + * Encodes the specified ServingConfig message. Does not implicitly {@link google.cloud.retail.v2beta.ServingConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {google.cloud.retail.v2beta.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.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.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.displayName); + if (message.modelId != null && Object.hasOwnProperty.call(message, "modelId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.modelId); + if (message.priceRerankingLevel != null && Object.hasOwnProperty.call(message, "priceRerankingLevel")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.priceRerankingLevel); + if (message.facetControlIds != null && message.facetControlIds.length) + for (var i = 0; i < message.facetControlIds.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.facetControlIds[i]); + if (message.dynamicFacetSpec != null && Object.hasOwnProperty.call(message, "dynamicFacetSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.encode(message.dynamicFacetSpec, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.boostControlIds != null && message.boostControlIds.length) + for (var i = 0; i < message.boostControlIds.length; ++i) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.boostControlIds[i]); + if (message.diversityLevel != null && Object.hasOwnProperty.call(message, "diversityLevel")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.diversityLevel); + if (message.filterControlIds != null && message.filterControlIds.length) + for (var i = 0; i < message.filterControlIds.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.filterControlIds[i]); + if (message.redirectControlIds != null && message.redirectControlIds.length) + for (var i = 0; i < message.redirectControlIds.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.redirectControlIds[i]); + if (message.onewaySynonymsControlIds != null && message.onewaySynonymsControlIds.length) + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.onewaySynonymsControlIds[i]); + if (message.doNotAssociateControlIds != null && message.doNotAssociateControlIds.length) + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.doNotAssociateControlIds[i]); + if (message.replacementControlIds != null && message.replacementControlIds.length) + for (var i = 0; i < message.replacementControlIds.length; ++i) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.replacementControlIds[i]); + if (message.ignoreControlIds != null && message.ignoreControlIds.length) + for (var i = 0; i < message.ignoreControlIds.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.ignoreControlIds[i]); + if (message.enableCategoryFilterLevel != null && Object.hasOwnProperty.call(message, "enableCategoryFilterLevel")) + writer.uint32(/* id 16, wireType 2 =*/130).string(message.enableCategoryFilterLevel); + if (message.twowaySynonymsControlIds != null && message.twowaySynonymsControlIds.length) + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + writer.uint32(/* id 18, wireType 2 =*/146).string(message.twowaySynonymsControlIds[i]); + if (message.solutionTypes != null && message.solutionTypes.length) { + writer.uint32(/* id 19, wireType 2 =*/154).fork(); + for (var i = 0; i < message.solutionTypes.length; ++i) + writer.int32(message.solutionTypes[i]); + writer.ldelim(); + } + if (message.diversityType != null && Object.hasOwnProperty.call(message, "diversityType")) + writer.uint32(/* id 20, wireType 0 =*/160).int32(message.diversityType); + if (message.personalizationSpec != null && Object.hasOwnProperty.call(message, "personalizationSpec")) + $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.encode(message.personalizationSpec, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ServingConfig message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ServingConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {google.cloud.retail.v2beta.IServingConfig} message ServingConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServingConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.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.cloud.retail.v2beta.ServingConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.displayName = reader.string(); + break; + } + case 3: { + message.modelId = reader.string(); + break; + } + case 4: { + message.priceRerankingLevel = reader.string(); + break; + } + case 5: { + if (!(message.facetControlIds && message.facetControlIds.length)) + message.facetControlIds = []; + message.facetControlIds.push(reader.string()); + break; + } + case 6: { + message.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.decode(reader, reader.uint32()); + break; + } + case 7: { + if (!(message.boostControlIds && message.boostControlIds.length)) + message.boostControlIds = []; + message.boostControlIds.push(reader.string()); + break; + } + case 9: { + if (!(message.filterControlIds && message.filterControlIds.length)) + message.filterControlIds = []; + message.filterControlIds.push(reader.string()); + break; + } + case 10: { + if (!(message.redirectControlIds && message.redirectControlIds.length)) + message.redirectControlIds = []; + message.redirectControlIds.push(reader.string()); + break; + } + case 18: { + if (!(message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length)) + message.twowaySynonymsControlIds = []; + message.twowaySynonymsControlIds.push(reader.string()); + break; + } + case 12: { + if (!(message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length)) + message.onewaySynonymsControlIds = []; + message.onewaySynonymsControlIds.push(reader.string()); + break; + } + case 13: { + if (!(message.doNotAssociateControlIds && message.doNotAssociateControlIds.length)) + message.doNotAssociateControlIds = []; + message.doNotAssociateControlIds.push(reader.string()); + break; + } + case 14: { + if (!(message.replacementControlIds && message.replacementControlIds.length)) + message.replacementControlIds = []; + message.replacementControlIds.push(reader.string()); + break; + } + case 15: { + if (!(message.ignoreControlIds && message.ignoreControlIds.length)) + message.ignoreControlIds = []; + message.ignoreControlIds.push(reader.string()); + break; + } + case 8: { + message.diversityLevel = reader.string(); + break; + } + case 20: { + message.diversityType = reader.int32(); + break; + } + case 16: { + message.enableCategoryFilterLevel = reader.string(); + break; + } + case 21: { + message.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.decode(reader, reader.uint32()); + break; + } + case 19: { + if (!(message.solutionTypes && message.solutionTypes.length)) + message.solutionTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.solutionTypes.push(reader.int32()); + } else + message.solutionTypes.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServingConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ServingConfig} ServingConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServingConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServingConfig message. + * @function verify + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServingConfig.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.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.modelId != null && message.hasOwnProperty("modelId")) + if (!$util.isString(message.modelId)) + return "modelId: string expected"; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + if (!$util.isString(message.priceRerankingLevel)) + return "priceRerankingLevel: string expected"; + if (message.facetControlIds != null && message.hasOwnProperty("facetControlIds")) { + if (!Array.isArray(message.facetControlIds)) + return "facetControlIds: array expected"; + for (var i = 0; i < message.facetControlIds.length; ++i) + if (!$util.isString(message.facetControlIds[i])) + return "facetControlIds: string[] expected"; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.verify(message.dynamicFacetSpec); + if (error) + return "dynamicFacetSpec." + error; + } + if (message.boostControlIds != null && message.hasOwnProperty("boostControlIds")) { + if (!Array.isArray(message.boostControlIds)) + return "boostControlIds: array expected"; + for (var i = 0; i < message.boostControlIds.length; ++i) + if (!$util.isString(message.boostControlIds[i])) + return "boostControlIds: string[] expected"; + } + if (message.filterControlIds != null && message.hasOwnProperty("filterControlIds")) { + if (!Array.isArray(message.filterControlIds)) + return "filterControlIds: array expected"; + for (var i = 0; i < message.filterControlIds.length; ++i) + if (!$util.isString(message.filterControlIds[i])) + return "filterControlIds: string[] expected"; + } + if (message.redirectControlIds != null && message.hasOwnProperty("redirectControlIds")) { + if (!Array.isArray(message.redirectControlIds)) + return "redirectControlIds: array expected"; + for (var i = 0; i < message.redirectControlIds.length; ++i) + if (!$util.isString(message.redirectControlIds[i])) + return "redirectControlIds: string[] expected"; + } + if (message.twowaySynonymsControlIds != null && message.hasOwnProperty("twowaySynonymsControlIds")) { + if (!Array.isArray(message.twowaySynonymsControlIds)) + return "twowaySynonymsControlIds: array expected"; + for (var i = 0; i < message.twowaySynonymsControlIds.length; ++i) + if (!$util.isString(message.twowaySynonymsControlIds[i])) + return "twowaySynonymsControlIds: string[] expected"; + } + if (message.onewaySynonymsControlIds != null && message.hasOwnProperty("onewaySynonymsControlIds")) { + if (!Array.isArray(message.onewaySynonymsControlIds)) + return "onewaySynonymsControlIds: array expected"; + for (var i = 0; i < message.onewaySynonymsControlIds.length; ++i) + if (!$util.isString(message.onewaySynonymsControlIds[i])) + return "onewaySynonymsControlIds: string[] expected"; + } + if (message.doNotAssociateControlIds != null && message.hasOwnProperty("doNotAssociateControlIds")) { + if (!Array.isArray(message.doNotAssociateControlIds)) + return "doNotAssociateControlIds: array expected"; + for (var i = 0; i < message.doNotAssociateControlIds.length; ++i) + if (!$util.isString(message.doNotAssociateControlIds[i])) + return "doNotAssociateControlIds: string[] expected"; + } + if (message.replacementControlIds != null && message.hasOwnProperty("replacementControlIds")) { + if (!Array.isArray(message.replacementControlIds)) + return "replacementControlIds: array expected"; + for (var i = 0; i < message.replacementControlIds.length; ++i) + if (!$util.isString(message.replacementControlIds[i])) + return "replacementControlIds: string[] expected"; + } + if (message.ignoreControlIds != null && message.hasOwnProperty("ignoreControlIds")) { + if (!Array.isArray(message.ignoreControlIds)) + return "ignoreControlIds: array expected"; + for (var i = 0; i < message.ignoreControlIds.length; ++i) + if (!$util.isString(message.ignoreControlIds[i])) + return "ignoreControlIds: string[] expected"; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + if (!$util.isString(message.diversityLevel)) + return "diversityLevel: string expected"; + if (message.diversityType != null && message.hasOwnProperty("diversityType")) + switch (message.diversityType) { + default: + return "diversityType: enum value expected"; + case 0: + case 2: + case 3: + break; + } + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + if (!$util.isString(message.enableCategoryFilterLevel)) + return "enableCategoryFilterLevel: string expected"; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) { + var error = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.verify(message.personalizationSpec); + if (error) + return "personalizationSpec." + error; + } + if (message.solutionTypes != null && message.hasOwnProperty("solutionTypes")) { + if (!Array.isArray(message.solutionTypes)) + return "solutionTypes: array expected"; + for (var i = 0; i < message.solutionTypes.length; ++i) + switch (message.solutionTypes[i]) { + default: + return "solutionTypes: enum value[] expected"; + case 0: + case 1: + case 2: + break; + } + } + return null; + }; + + /** + * Creates a ServingConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ServingConfig} ServingConfig + */ + ServingConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ServingConfig) + return object; + var message = new $root.google.cloud.retail.v2beta.ServingConfig(); + if (object.name != null) + message.name = String(object.name); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.modelId != null) + message.modelId = String(object.modelId); + if (object.priceRerankingLevel != null) + message.priceRerankingLevel = String(object.priceRerankingLevel); + if (object.facetControlIds) { + if (!Array.isArray(object.facetControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.facetControlIds: array expected"); + message.facetControlIds = []; + for (var i = 0; i < object.facetControlIds.length; ++i) + message.facetControlIds[i] = String(object.facetControlIds[i]); + } + if (object.dynamicFacetSpec != null) { + if (typeof object.dynamicFacetSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.dynamicFacetSpec: object expected"); + message.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.fromObject(object.dynamicFacetSpec); + } + if (object.boostControlIds) { + if (!Array.isArray(object.boostControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.boostControlIds: array expected"); + message.boostControlIds = []; + for (var i = 0; i < object.boostControlIds.length; ++i) + message.boostControlIds[i] = String(object.boostControlIds[i]); + } + if (object.filterControlIds) { + if (!Array.isArray(object.filterControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.filterControlIds: array expected"); + message.filterControlIds = []; + for (var i = 0; i < object.filterControlIds.length; ++i) + message.filterControlIds[i] = String(object.filterControlIds[i]); + } + if (object.redirectControlIds) { + if (!Array.isArray(object.redirectControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.redirectControlIds: array expected"); + message.redirectControlIds = []; + for (var i = 0; i < object.redirectControlIds.length; ++i) + message.redirectControlIds[i] = String(object.redirectControlIds[i]); + } + if (object.twowaySynonymsControlIds) { + if (!Array.isArray(object.twowaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.twowaySynonymsControlIds: array expected"); + message.twowaySynonymsControlIds = []; + for (var i = 0; i < object.twowaySynonymsControlIds.length; ++i) + message.twowaySynonymsControlIds[i] = String(object.twowaySynonymsControlIds[i]); + } + if (object.onewaySynonymsControlIds) { + if (!Array.isArray(object.onewaySynonymsControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.onewaySynonymsControlIds: array expected"); + message.onewaySynonymsControlIds = []; + for (var i = 0; i < object.onewaySynonymsControlIds.length; ++i) + message.onewaySynonymsControlIds[i] = String(object.onewaySynonymsControlIds[i]); + } + if (object.doNotAssociateControlIds) { + if (!Array.isArray(object.doNotAssociateControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.doNotAssociateControlIds: array expected"); + message.doNotAssociateControlIds = []; + for (var i = 0; i < object.doNotAssociateControlIds.length; ++i) + message.doNotAssociateControlIds[i] = String(object.doNotAssociateControlIds[i]); + } + if (object.replacementControlIds) { + if (!Array.isArray(object.replacementControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.replacementControlIds: array expected"); + message.replacementControlIds = []; + for (var i = 0; i < object.replacementControlIds.length; ++i) + message.replacementControlIds[i] = String(object.replacementControlIds[i]); + } + if (object.ignoreControlIds) { + if (!Array.isArray(object.ignoreControlIds)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.ignoreControlIds: array expected"); + message.ignoreControlIds = []; + for (var i = 0; i < object.ignoreControlIds.length; ++i) + message.ignoreControlIds[i] = String(object.ignoreControlIds[i]); + } + if (object.diversityLevel != null) + message.diversityLevel = String(object.diversityLevel); + switch (object.diversityType) { + default: + if (typeof object.diversityType === "number") { + message.diversityType = object.diversityType; + break; + } + break; + case "DIVERSITY_TYPE_UNSPECIFIED": + case 0: + message.diversityType = 0; + break; + case "RULE_BASED_DIVERSITY": + case 2: + message.diversityType = 2; + break; + case "DATA_DRIVEN_DIVERSITY": + case 3: + message.diversityType = 3; + break; + } + if (object.enableCategoryFilterLevel != null) + message.enableCategoryFilterLevel = String(object.enableCategoryFilterLevel); + if (object.personalizationSpec != null) { + if (typeof object.personalizationSpec !== "object") + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.personalizationSpec: object expected"); + message.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.fromObject(object.personalizationSpec); + } + if (object.solutionTypes) { + if (!Array.isArray(object.solutionTypes)) + throw TypeError(".google.cloud.retail.v2beta.ServingConfig.solutionTypes: array expected"); + message.solutionTypes = []; + for (var i = 0; i < object.solutionTypes.length; ++i) + switch (object.solutionTypes[i]) { + default: + if (typeof object.solutionTypes[i] === "number") { + message.solutionTypes[i] = object.solutionTypes[i]; + break; + } + case "SOLUTION_TYPE_UNSPECIFIED": + case 0: + message.solutionTypes[i] = 0; + break; + case "SOLUTION_TYPE_RECOMMENDATION": + case 1: + message.solutionTypes[i] = 1; + break; + case "SOLUTION_TYPE_SEARCH": + case 2: + message.solutionTypes[i] = 2; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a ServingConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {google.cloud.retail.v2beta.ServingConfig} message ServingConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServingConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.facetControlIds = []; + object.boostControlIds = []; + object.filterControlIds = []; + object.redirectControlIds = []; + object.onewaySynonymsControlIds = []; + object.doNotAssociateControlIds = []; + object.replacementControlIds = []; + object.ignoreControlIds = []; + object.twowaySynonymsControlIds = []; + object.solutionTypes = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + object.modelId = ""; + object.priceRerankingLevel = ""; + object.dynamicFacetSpec = null; + object.diversityLevel = ""; + object.enableCategoryFilterLevel = ""; + object.diversityType = options.enums === String ? "DIVERSITY_TYPE_UNSPECIFIED" : 0; + object.personalizationSpec = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.modelId != null && message.hasOwnProperty("modelId")) + object.modelId = message.modelId; + if (message.priceRerankingLevel != null && message.hasOwnProperty("priceRerankingLevel")) + object.priceRerankingLevel = message.priceRerankingLevel; + if (message.facetControlIds && message.facetControlIds.length) { + object.facetControlIds = []; + for (var j = 0; j < message.facetControlIds.length; ++j) + object.facetControlIds[j] = message.facetControlIds[j]; + } + if (message.dynamicFacetSpec != null && message.hasOwnProperty("dynamicFacetSpec")) + object.dynamicFacetSpec = $root.google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec.toObject(message.dynamicFacetSpec, options); + if (message.boostControlIds && message.boostControlIds.length) { + object.boostControlIds = []; + for (var j = 0; j < message.boostControlIds.length; ++j) + object.boostControlIds[j] = message.boostControlIds[j]; + } + if (message.diversityLevel != null && message.hasOwnProperty("diversityLevel")) + object.diversityLevel = message.diversityLevel; + if (message.filterControlIds && message.filterControlIds.length) { + object.filterControlIds = []; + for (var j = 0; j < message.filterControlIds.length; ++j) + object.filterControlIds[j] = message.filterControlIds[j]; + } + if (message.redirectControlIds && message.redirectControlIds.length) { + object.redirectControlIds = []; + for (var j = 0; j < message.redirectControlIds.length; ++j) + object.redirectControlIds[j] = message.redirectControlIds[j]; + } + if (message.onewaySynonymsControlIds && message.onewaySynonymsControlIds.length) { + object.onewaySynonymsControlIds = []; + for (var j = 0; j < message.onewaySynonymsControlIds.length; ++j) + object.onewaySynonymsControlIds[j] = message.onewaySynonymsControlIds[j]; + } + if (message.doNotAssociateControlIds && message.doNotAssociateControlIds.length) { + object.doNotAssociateControlIds = []; + for (var j = 0; j < message.doNotAssociateControlIds.length; ++j) + object.doNotAssociateControlIds[j] = message.doNotAssociateControlIds[j]; + } + if (message.replacementControlIds && message.replacementControlIds.length) { + object.replacementControlIds = []; + for (var j = 0; j < message.replacementControlIds.length; ++j) + object.replacementControlIds[j] = message.replacementControlIds[j]; + } + if (message.ignoreControlIds && message.ignoreControlIds.length) { + object.ignoreControlIds = []; + for (var j = 0; j < message.ignoreControlIds.length; ++j) + object.ignoreControlIds[j] = message.ignoreControlIds[j]; + } + if (message.enableCategoryFilterLevel != null && message.hasOwnProperty("enableCategoryFilterLevel")) + object.enableCategoryFilterLevel = message.enableCategoryFilterLevel; + if (message.twowaySynonymsControlIds && message.twowaySynonymsControlIds.length) { + object.twowaySynonymsControlIds = []; + for (var j = 0; j < message.twowaySynonymsControlIds.length; ++j) + object.twowaySynonymsControlIds[j] = message.twowaySynonymsControlIds[j]; + } + if (message.solutionTypes && message.solutionTypes.length) { + object.solutionTypes = []; + for (var j = 0; j < message.solutionTypes.length; ++j) + object.solutionTypes[j] = options.enums === String ? $root.google.cloud.retail.v2beta.SolutionType[message.solutionTypes[j]] === undefined ? message.solutionTypes[j] : $root.google.cloud.retail.v2beta.SolutionType[message.solutionTypes[j]] : message.solutionTypes[j]; + } + if (message.diversityType != null && message.hasOwnProperty("diversityType")) + object.diversityType = options.enums === String ? $root.google.cloud.retail.v2beta.ServingConfig.DiversityType[message.diversityType] === undefined ? message.diversityType : $root.google.cloud.retail.v2beta.ServingConfig.DiversityType[message.diversityType] : message.diversityType; + if (message.personalizationSpec != null && message.hasOwnProperty("personalizationSpec")) + object.personalizationSpec = $root.google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.toObject(message.personalizationSpec, options); + return object; + }; + + /** + * Converts this ServingConfig to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ServingConfig + * @instance + * @returns {Object.} JSON object + */ + ServingConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServingConfig + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ServingConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServingConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ServingConfig"; + }; + + /** + * DiversityType enum. + * @name google.cloud.retail.v2beta.ServingConfig.DiversityType + * @enum {number} + * @property {number} DIVERSITY_TYPE_UNSPECIFIED=0 DIVERSITY_TYPE_UNSPECIFIED value + * @property {number} RULE_BASED_DIVERSITY=2 RULE_BASED_DIVERSITY value + * @property {number} DATA_DRIVEN_DIVERSITY=3 DATA_DRIVEN_DIVERSITY value + */ + ServingConfig.DiversityType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIVERSITY_TYPE_UNSPECIFIED"] = 0; + values[valuesById[2] = "RULE_BASED_DIVERSITY"] = 2; + values[valuesById[3] = "DATA_DRIVEN_DIVERSITY"] = 3; + return values; + })(); + + return ServingConfig; + })(); + + v2beta.ServingConfigService = (function() { + + /** + * Constructs a new ServingConfigService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ServingConfigService + * @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 ServingConfigService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ServingConfigService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ServingConfigService; + + /** + * Creates new ServingConfigService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @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 {ServingConfigService} RPC service. Useful where requests and/or responses are streamed. + */ + ServingConfigService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|createServingConfig}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef CreateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ServingConfig} [response] ServingConfig + */ + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.CreateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.createServingConfig = function createServingConfig(request, callback) { + return this.rpcCall(createServingConfig, $root.google.cloud.retail.v2beta.CreateServingConfigRequest, $root.google.cloud.retail.v2beta.ServingConfig, request, callback); + }, "name", { value: "CreateServingConfig" }); + + /** + * Calls CreateServingConfig. + * @function createServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest} request CreateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|deleteServingConfig}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef DeleteServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfigCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.deleteServingConfig = function deleteServingConfig(request, callback) { + return this.rpcCall(deleteServingConfig, $root.google.cloud.retail.v2beta.DeleteServingConfigRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteServingConfig" }); + + /** + * Calls DeleteServingConfig. + * @function deleteServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest} request DeleteServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|updateServingConfig}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef UpdateServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ServingConfig} [response] ServingConfig + */ + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.updateServingConfig = function updateServingConfig(request, callback) { + return this.rpcCall(updateServingConfig, $root.google.cloud.retail.v2beta.UpdateServingConfigRequest, $root.google.cloud.retail.v2beta.ServingConfig, request, callback); + }, "name", { value: "UpdateServingConfig" }); + + /** + * Calls UpdateServingConfig. + * @function updateServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest} request UpdateServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|getServingConfig}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef GetServingConfigCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ServingConfig} [response] ServingConfig + */ + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.GetServingConfigCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.getServingConfig = function getServingConfig(request, callback) { + return this.rpcCall(getServingConfig, $root.google.cloud.retail.v2beta.GetServingConfigRequest, $root.google.cloud.retail.v2beta.ServingConfig, request, callback); + }, "name", { value: "GetServingConfig" }); + + /** + * Calls GetServingConfig. + * @function getServingConfig + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest} request GetServingConfigRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|listServingConfigs}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef ListServingConfigsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ListServingConfigsResponse} [response] ListServingConfigsResponse + */ + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.ListServingConfigsCallback} callback Node-style callback called with the error, if any, and ListServingConfigsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.listServingConfigs = function listServingConfigs(request, callback) { + return this.rpcCall(listServingConfigs, $root.google.cloud.retail.v2beta.ListServingConfigsRequest, $root.google.cloud.retail.v2beta.ListServingConfigsResponse, request, callback); + }, "name", { value: "ListServingConfigs" }); + + /** + * Calls ListServingConfigs. + * @function listServingConfigs + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest} request ListServingConfigsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|addControl}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef AddControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ServingConfig} [response] ServingConfig + */ + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IAddControlRequest} request AddControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.AddControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.addControl = function addControl(request, callback) { + return this.rpcCall(addControl, $root.google.cloud.retail.v2beta.AddControlRequest, $root.google.cloud.retail.v2beta.ServingConfig, request, callback); + }, "name", { value: "AddControl" }); + + /** + * Calls AddControl. + * @function addControl + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IAddControlRequest} request AddControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.ServingConfigService|removeControl}. + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @typedef RemoveControlCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.ServingConfig} [response] ServingConfig + */ + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @param {google.cloud.retail.v2beta.ServingConfigService.RemoveControlCallback} callback Node-style callback called with the error, if any, and ServingConfig + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ServingConfigService.prototype.removeControl = function removeControl(request, callback) { + return this.rpcCall(removeControl, $root.google.cloud.retail.v2beta.RemoveControlRequest, $root.google.cloud.retail.v2beta.ServingConfig, request, callback); + }, "name", { value: "RemoveControl" }); + + /** + * Calls RemoveControl. + * @function removeControl + * @memberof google.cloud.retail.v2beta.ServingConfigService + * @instance + * @param {google.cloud.retail.v2beta.IRemoveControlRequest} request RemoveControlRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ServingConfigService; + })(); + + v2beta.CreateServingConfigRequest = (function() { + + /** + * Properties of a CreateServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICreateServingConfigRequest + * @property {string|null} [parent] CreateServingConfigRequest parent + * @property {google.cloud.retail.v2beta.IServingConfig|null} [servingConfig] CreateServingConfigRequest servingConfig + * @property {string|null} [servingConfigId] CreateServingConfigRequest servingConfigId + */ + + /** + * Constructs a new CreateServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CreateServingConfigRequest. + * @implements ICreateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest=} [properties] Properties to set + */ + function CreateServingConfigRequest(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]]; + } + + /** + * CreateServingConfigRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.parent = ""; + + /** + * CreateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2beta.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfig = null; + + /** + * CreateServingConfigRequest servingConfigId. + * @member {string} servingConfigId + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @instance + */ + CreateServingConfigRequest.prototype.servingConfigId = ""; + + /** + * Creates a new CreateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CreateServingConfigRequest} CreateServingConfigRequest instance + */ + CreateServingConfigRequest.create = function create(properties) { + return new CreateServingConfigRequest(properties); + }; + + /** + * Encodes the specified CreateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CreateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2beta.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.servingConfigId != null && Object.hasOwnProperty.call(message, "servingConfigId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.servingConfigId); + return writer; + }; + + /** + * Encodes the specified CreateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CreateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.ICreateServingConfigRequest} message CreateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.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.cloud.retail.v2beta.CreateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.servingConfigId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CreateServingConfigRequest} CreateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2beta.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + if (!$util.isString(message.servingConfigId)) + return "servingConfigId: string expected"; + return null; + }; + + /** + * Creates a CreateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CreateServingConfigRequest} CreateServingConfigRequest + */ + CreateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CreateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CreateServingConfigRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.CreateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.fromObject(object.servingConfig); + } + if (object.servingConfigId != null) + message.servingConfigId = String(object.servingConfigId); + return message; + }; + + /** + * Creates a plain object from a CreateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.CreateServingConfigRequest} message CreateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.servingConfig = null; + object.servingConfigId = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.toObject(message.servingConfig, options); + if (message.servingConfigId != null && message.hasOwnProperty("servingConfigId")) + object.servingConfigId = message.servingConfigId; + return object; + }; + + /** + * Converts this CreateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + CreateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CreateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CreateServingConfigRequest"; + }; + + return CreateServingConfigRequest; + })(); + + v2beta.UpdateServingConfigRequest = (function() { + + /** + * Properties of an UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IUpdateServingConfigRequest + * @property {google.cloud.retail.v2beta.IServingConfig|null} [servingConfig] UpdateServingConfigRequest servingConfig + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateServingConfigRequest updateMask + */ + + /** + * Constructs a new UpdateServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an UpdateServingConfigRequest. + * @implements IUpdateServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest=} [properties] Properties to set + */ + function UpdateServingConfigRequest(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]]; + } + + /** + * UpdateServingConfigRequest servingConfig. + * @member {google.cloud.retail.v2beta.IServingConfig|null|undefined} servingConfig + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.servingConfig = null; + + /** + * UpdateServingConfigRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @instance + */ + UpdateServingConfigRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.UpdateServingConfigRequest} UpdateServingConfigRequest instance + */ + UpdateServingConfigRequest.create = function create(properties) { + return new UpdateServingConfigRequest(properties); + }; + + /** + * Encodes the specified UpdateServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.UpdateServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + $root.google.cloud.retail.v2beta.ServingConfig.encode(message.servingConfig, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.UpdateServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IUpdateServingConfigRequest} message UpdateServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.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.cloud.retail.v2beta.UpdateServingConfigRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.UpdateServingConfigRequest} UpdateServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateServingConfigRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) { + var error = $root.google.cloud.retail.v2beta.ServingConfig.verify(message.servingConfig); + if (error) + return "servingConfig." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.UpdateServingConfigRequest} UpdateServingConfigRequest + */ + UpdateServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.UpdateServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.UpdateServingConfigRequest(); + if (object.servingConfig != null) { + if (typeof object.servingConfig !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateServingConfigRequest.servingConfig: object expected"); + message.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.fromObject(object.servingConfig); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.retail.v2beta.UpdateServingConfigRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.UpdateServingConfigRequest} message UpdateServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateServingConfigRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = null; + object.updateMask = null; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = $root.google.cloud.retail.v2beta.ServingConfig.toObject(message.servingConfig, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.UpdateServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.UpdateServingConfigRequest"; + }; + + return UpdateServingConfigRequest; + })(); + + v2beta.DeleteServingConfigRequest = (function() { + + /** + * Properties of a DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IDeleteServingConfigRequest + * @property {string|null} [name] DeleteServingConfigRequest name + */ + + /** + * Constructs a new DeleteServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a DeleteServingConfigRequest. + * @implements IDeleteServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest=} [properties] Properties to set + */ + function DeleteServingConfigRequest(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]]; + } + + /** + * DeleteServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @instance + */ + DeleteServingConfigRequest.prototype.name = ""; + + /** + * Creates a new DeleteServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.DeleteServingConfigRequest} DeleteServingConfigRequest instance + */ + DeleteServingConfigRequest.create = function create(properties) { + return new DeleteServingConfigRequest(properties); + }; + + /** + * Encodes the specified DeleteServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.DeleteServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.DeleteServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IDeleteServingConfigRequest} message DeleteServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.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.cloud.retail.v2beta.DeleteServingConfigRequest(); + 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 DeleteServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.DeleteServingConfigRequest} DeleteServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.DeleteServingConfigRequest} DeleteServingConfigRequest + */ + DeleteServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.DeleteServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.DeleteServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.DeleteServingConfigRequest} message DeleteServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteServingConfigRequest.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 DeleteServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.DeleteServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.DeleteServingConfigRequest"; + }; + + return DeleteServingConfigRequest; + })(); + + v2beta.GetServingConfigRequest = (function() { + + /** + * Properties of a GetServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @interface IGetServingConfigRequest + * @property {string|null} [name] GetServingConfigRequest name + */ + + /** + * Constructs a new GetServingConfigRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a GetServingConfigRequest. + * @implements IGetServingConfigRequest + * @constructor + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest=} [properties] Properties to set + */ + function GetServingConfigRequest(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]]; + } + + /** + * GetServingConfigRequest name. + * @member {string} name + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @instance + */ + GetServingConfigRequest.prototype.name = ""; + + /** + * Creates a new GetServingConfigRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.GetServingConfigRequest} GetServingConfigRequest instance + */ + GetServingConfigRequest.create = function create(properties) { + return new GetServingConfigRequest(properties); + }; + + /** + * Encodes the specified GetServingConfigRequest message. Does not implicitly {@link google.cloud.retail.v2beta.GetServingConfigRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.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 GetServingConfigRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.GetServingConfigRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.IGetServingConfigRequest} message GetServingConfigRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetServingConfigRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetServingConfigRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.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.cloud.retail.v2beta.GetServingConfigRequest(); + 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 GetServingConfigRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.GetServingConfigRequest} GetServingConfigRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetServingConfigRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetServingConfigRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetServingConfigRequest.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 GetServingConfigRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.GetServingConfigRequest} GetServingConfigRequest + */ + GetServingConfigRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.GetServingConfigRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.GetServingConfigRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetServingConfigRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {google.cloud.retail.v2beta.GetServingConfigRequest} message GetServingConfigRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetServingConfigRequest.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 GetServingConfigRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @instance + * @returns {Object.} JSON object + */ + GetServingConfigRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetServingConfigRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.GetServingConfigRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetServingConfigRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.GetServingConfigRequest"; + }; + + return GetServingConfigRequest; + })(); + + v2beta.ListServingConfigsRequest = (function() { + + /** + * Properties of a ListServingConfigsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IListServingConfigsRequest + * @property {string|null} [parent] ListServingConfigsRequest parent + * @property {number|null} [pageSize] ListServingConfigsRequest pageSize + * @property {string|null} [pageToken] ListServingConfigsRequest pageToken + */ + + /** + * Constructs a new ListServingConfigsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListServingConfigsRequest. + * @implements IListServingConfigsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest=} [properties] Properties to set + */ + function ListServingConfigsRequest(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]]; + } + + /** + * ListServingConfigsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.parent = ""; + + /** + * ListServingConfigsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageSize = 0; + + /** + * ListServingConfigsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @instance + */ + ListServingConfigsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListServingConfigsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListServingConfigsRequest} ListServingConfigsRequest instance + */ + ListServingConfigsRequest.create = function create(properties) { + return new ListServingConfigsRequest(properties); + }; + + /** + * Encodes the specified ListServingConfigsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + 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); + return writer; + }; + + /** + * Encodes the specified ListServingConfigsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsRequest} message ListServingConfigsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.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.cloud.retail.v2beta.ListServingConfigsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = 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 ListServingConfigsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListServingConfigsRequest} ListServingConfigsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: 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 ListServingConfigsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListServingConfigsRequest} ListServingConfigsRequest + */ + ListServingConfigsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListServingConfigsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.ListServingConfigsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + 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 ListServingConfigsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {google.cloud.retail.v2beta.ListServingConfigsRequest} message ListServingConfigsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + 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 ListServingConfigsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListServingConfigsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListServingConfigsRequest"; + }; + + return ListServingConfigsRequest; + })(); + + v2beta.ListServingConfigsResponse = (function() { + + /** + * Properties of a ListServingConfigsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IListServingConfigsResponse + * @property {Array.|null} [servingConfigs] ListServingConfigsResponse servingConfigs + * @property {string|null} [nextPageToken] ListServingConfigsResponse nextPageToken + */ + + /** + * Constructs a new ListServingConfigsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a ListServingConfigsResponse. + * @implements IListServingConfigsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IListServingConfigsResponse=} [properties] Properties to set + */ + function ListServingConfigsResponse(properties) { + this.servingConfigs = []; + 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]]; + } + + /** + * ListServingConfigsResponse servingConfigs. + * @member {Array.} servingConfigs + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.servingConfigs = $util.emptyArray; + + /** + * ListServingConfigsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @instance + */ + ListServingConfigsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListServingConfigsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.ListServingConfigsResponse} ListServingConfigsResponse instance + */ + ListServingConfigsResponse.create = function create(properties) { + return new ListServingConfigsResponse(properties); + }; + + /** + * Encodes the specified ListServingConfigsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfigs != null && message.servingConfigs.length) + for (var i = 0; i < message.servingConfigs.length; ++i) + $root.google.cloud.retail.v2beta.ServingConfig.encode(message.servingConfigs[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 ListServingConfigsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.ListServingConfigsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2beta.IListServingConfigsResponse} message ListServingConfigsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListServingConfigsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.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.cloud.retail.v2beta.ListServingConfigsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.servingConfigs && message.servingConfigs.length)) + message.servingConfigs = []; + message.servingConfigs.push($root.google.cloud.retail.v2beta.ServingConfig.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListServingConfigsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.ListServingConfigsResponse} ListServingConfigsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListServingConfigsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListServingConfigsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListServingConfigsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfigs != null && message.hasOwnProperty("servingConfigs")) { + if (!Array.isArray(message.servingConfigs)) + return "servingConfigs: array expected"; + for (var i = 0; i < message.servingConfigs.length; ++i) { + var error = $root.google.cloud.retail.v2beta.ServingConfig.verify(message.servingConfigs[i]); + if (error) + return "servingConfigs." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListServingConfigsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.ListServingConfigsResponse} ListServingConfigsResponse + */ + ListServingConfigsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.ListServingConfigsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.ListServingConfigsResponse(); + if (object.servingConfigs) { + if (!Array.isArray(object.servingConfigs)) + throw TypeError(".google.cloud.retail.v2beta.ListServingConfigsResponse.servingConfigs: array expected"); + message.servingConfigs = []; + for (var i = 0; i < object.servingConfigs.length; ++i) { + if (typeof object.servingConfigs[i] !== "object") + throw TypeError(".google.cloud.retail.v2beta.ListServingConfigsResponse.servingConfigs: object expected"); + message.servingConfigs[i] = $root.google.cloud.retail.v2beta.ServingConfig.fromObject(object.servingConfigs[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListServingConfigsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {google.cloud.retail.v2beta.ListServingConfigsResponse} message ListServingConfigsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListServingConfigsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.servingConfigs = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.servingConfigs && message.servingConfigs.length) { + object.servingConfigs = []; + for (var j = 0; j < message.servingConfigs.length; ++j) + object.servingConfigs[j] = $root.google.cloud.retail.v2beta.ServingConfig.toObject(message.servingConfigs[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListServingConfigsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @instance + * @returns {Object.} JSON object + */ + ListServingConfigsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListServingConfigsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.ListServingConfigsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListServingConfigsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.ListServingConfigsResponse"; + }; + + return ListServingConfigsResponse; + })(); + + v2beta.AddControlRequest = (function() { + + /** + * Properties of an AddControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface IAddControlRequest + * @property {string|null} [servingConfig] AddControlRequest servingConfig + * @property {string|null} [controlId] AddControlRequest controlId + */ + + /** + * Constructs a new AddControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents an AddControlRequest. + * @implements IAddControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.IAddControlRequest=} [properties] Properties to set + */ + function AddControlRequest(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]]; + } + + /** + * AddControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @instance + */ + AddControlRequest.prototype.servingConfig = ""; + + /** + * AddControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @instance + */ + AddControlRequest.prototype.controlId = ""; + + /** + * Creates a new AddControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {google.cloud.retail.v2beta.IAddControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.AddControlRequest} AddControlRequest instance + */ + AddControlRequest.create = function create(properties) { + return new AddControlRequest(properties); + }; + + /** + * Encodes the specified AddControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.AddControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {google.cloud.retail.v2beta.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified AddControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.AddControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {google.cloud.retail.v2beta.IAddControlRequest} message AddControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AddControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.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.cloud.retail.v2beta.AddControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AddControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.AddControlRequest} AddControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AddControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AddControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AddControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates an AddControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.AddControlRequest} AddControlRequest + */ + AddControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.AddControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.AddControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from an AddControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {google.cloud.retail.v2beta.AddControlRequest} message AddControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AddControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this AddControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @instance + * @returns {Object.} JSON object + */ + AddControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AddControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.AddControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AddControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.AddControlRequest"; + }; + + return AddControlRequest; + })(); + + v2beta.RemoveControlRequest = (function() { + + /** + * Properties of a RemoveControlRequest. + * @memberof google.cloud.retail.v2beta + * @interface IRemoveControlRequest + * @property {string|null} [servingConfig] RemoveControlRequest servingConfig + * @property {string|null} [controlId] RemoveControlRequest controlId + */ + + /** + * Constructs a new RemoveControlRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RemoveControlRequest. + * @implements IRemoveControlRequest + * @constructor + * @param {google.cloud.retail.v2beta.IRemoveControlRequest=} [properties] Properties to set + */ + function RemoveControlRequest(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]]; + } + + /** + * RemoveControlRequest servingConfig. + * @member {string} servingConfig + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.servingConfig = ""; + + /** + * RemoveControlRequest controlId. + * @member {string} controlId + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @instance + */ + RemoveControlRequest.prototype.controlId = ""; + + /** + * Creates a new RemoveControlRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveControlRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RemoveControlRequest} RemoveControlRequest instance + */ + RemoveControlRequest.create = function create(properties) { + return new RemoveControlRequest(properties); + }; + + /** + * Encodes the specified RemoveControlRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RemoveControlRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.servingConfig != null && Object.hasOwnProperty.call(message, "servingConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.servingConfig); + if (message.controlId != null && Object.hasOwnProperty.call(message, "controlId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.controlId); + return writer; + }; + + /** + * Encodes the specified RemoveControlRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RemoveControlRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2beta.IRemoveControlRequest} message RemoveControlRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RemoveControlRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.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.cloud.retail.v2beta.RemoveControlRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.servingConfig = reader.string(); + break; + } + case 2: { + message.controlId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RemoveControlRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RemoveControlRequest} RemoveControlRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RemoveControlRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RemoveControlRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RemoveControlRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + if (!$util.isString(message.servingConfig)) + return "servingConfig: string expected"; + if (message.controlId != null && message.hasOwnProperty("controlId")) + if (!$util.isString(message.controlId)) + return "controlId: string expected"; + return null; + }; + + /** + * Creates a RemoveControlRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RemoveControlRequest} RemoveControlRequest + */ + RemoveControlRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RemoveControlRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.RemoveControlRequest(); + if (object.servingConfig != null) + message.servingConfig = String(object.servingConfig); + if (object.controlId != null) + message.controlId = String(object.controlId); + return message; + }; + + /** + * Creates a plain object from a RemoveControlRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {google.cloud.retail.v2beta.RemoveControlRequest} message RemoveControlRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RemoveControlRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.servingConfig = ""; + object.controlId = ""; + } + if (message.servingConfig != null && message.hasOwnProperty("servingConfig")) + object.servingConfig = message.servingConfig; + if (message.controlId != null && message.hasOwnProperty("controlId")) + object.controlId = message.controlId; + return object; + }; + + /** + * Converts this RemoveControlRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @instance + * @returns {Object.} JSON object + */ + RemoveControlRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RemoveControlRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RemoveControlRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RemoveControlRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RemoveControlRequest"; + }; + + return RemoveControlRequest; + })(); + + v2beta.UserEventService = (function() { + + /** + * Constructs a new UserEventService service. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a UserEventService + * @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 UserEventService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (UserEventService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = UserEventService; + + /** + * Creates new UserEventService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.retail.v2beta.UserEventService + * @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 {UserEventService} RPC service. Useful where requests and/or responses are streamed. + */ + UserEventService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|writeUserEvent}. + * @memberof google.cloud.retail.v2beta.UserEventService + * @typedef WriteUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.retail.v2beta.UserEvent} [response] UserEvent + */ + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @param {google.cloud.retail.v2beta.UserEventService.WriteUserEventCallback} callback Node-style callback called with the error, if any, and UserEvent + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.writeUserEvent = function writeUserEvent(request, callback) { + return this.rpcCall(writeUserEvent, $root.google.cloud.retail.v2beta.WriteUserEventRequest, $root.google.cloud.retail.v2beta.UserEvent, request, callback); + }, "name", { value: "WriteUserEvent" }); + + /** + * Calls WriteUserEvent. + * @function writeUserEvent + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest} request WriteUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|collectUserEvent}. + * @memberof google.cloud.retail.v2beta.UserEventService + * @typedef CollectUserEventCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.api.HttpBody} [response] HttpBody + */ + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @param {google.cloud.retail.v2beta.UserEventService.CollectUserEventCallback} callback Node-style callback called with the error, if any, and HttpBody + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.collectUserEvent = function collectUserEvent(request, callback) { + return this.rpcCall(collectUserEvent, $root.google.cloud.retail.v2beta.CollectUserEventRequest, $root.google.api.HttpBody, request, callback); + }, "name", { value: "CollectUserEvent" }); + + /** + * Calls CollectUserEvent. + * @function collectUserEvent + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest} request CollectUserEventRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|purgeUserEvents}. + * @memberof google.cloud.retail.v2beta.UserEventService + * @typedef PurgeUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @param {google.cloud.retail.v2beta.UserEventService.PurgeUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.purgeUserEvents = function purgeUserEvents(request, callback) { + return this.rpcCall(purgeUserEvents, $root.google.cloud.retail.v2beta.PurgeUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "PurgeUserEvents" }); + + /** + * Calls PurgeUserEvents. + * @function purgeUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IPurgeUserEventsRequest} request PurgeUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|importUserEvents}. + * @memberof google.cloud.retail.v2beta.UserEventService + * @typedef ImportUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @param {google.cloud.retail.v2beta.UserEventService.ImportUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.importUserEvents = function importUserEvents(request, callback) { + return this.rpcCall(importUserEvents, $root.google.cloud.retail.v2beta.ImportUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportUserEvents" }); + + /** + * Calls ImportUserEvents. + * @function importUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IImportUserEventsRequest} request ImportUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.retail.v2beta.UserEventService|rejoinUserEvents}. + * @memberof google.cloud.retail.v2beta.UserEventService + * @typedef RejoinUserEventsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @param {google.cloud.retail.v2beta.UserEventService.RejoinUserEventsCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(UserEventService.prototype.rejoinUserEvents = function rejoinUserEvents(request, callback) { + return this.rpcCall(rejoinUserEvents, $root.google.cloud.retail.v2beta.RejoinUserEventsRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "RejoinUserEvents" }); + + /** + * Calls RejoinUserEvents. + * @function rejoinUserEvents + * @memberof google.cloud.retail.v2beta.UserEventService + * @instance + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest} request RejoinUserEventsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return UserEventService; + })(); + + v2beta.WriteUserEventRequest = (function() { + + /** + * Properties of a WriteUserEventRequest. + * @memberof google.cloud.retail.v2beta + * @interface IWriteUserEventRequest + * @property {string|null} [parent] WriteUserEventRequest parent + * @property {google.cloud.retail.v2beta.IUserEvent|null} [userEvent] WriteUserEventRequest userEvent + */ + + /** + * Constructs a new WriteUserEventRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a WriteUserEventRequest. + * @implements IWriteUserEventRequest + * @constructor + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest=} [properties] Properties to set + */ + function WriteUserEventRequest(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]]; + } + + /** + * WriteUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.parent = ""; + + /** + * WriteUserEventRequest userEvent. + * @member {google.cloud.retail.v2beta.IUserEvent|null|undefined} userEvent + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @instance + */ + WriteUserEventRequest.prototype.userEvent = null; + + /** + * Creates a new WriteUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.WriteUserEventRequest} WriteUserEventRequest instance + */ + WriteUserEventRequest.create = function create(properties) { + return new WriteUserEventRequest(properties); + }; + + /** + * Encodes the specified WriteUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2beta.WriteUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + $root.google.cloud.retail.v2beta.UserEvent.encode(message.userEvent, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WriteUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.WriteUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.IWriteUserEventRequest} message WriteUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.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.cloud.retail.v2beta.WriteUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = $root.google.cloud.retail.v2beta.UserEvent.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WriteUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.WriteUserEventRequest} WriteUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WriteUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) { + var error = $root.google.cloud.retail.v2beta.UserEvent.verify(message.userEvent); + if (error) + return "userEvent." + error; + } + return null; + }; + + /** + * Creates a WriteUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.WriteUserEventRequest} WriteUserEventRequest + */ + WriteUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.WriteUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.WriteUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) { + if (typeof object.userEvent !== "object") + throw TypeError(".google.cloud.retail.v2beta.WriteUserEventRequest.userEvent: object expected"); + message.userEvent = $root.google.cloud.retail.v2beta.UserEvent.fromObject(object.userEvent); + } + return message; + }; + + /** + * Creates a plain object from a WriteUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.WriteUserEventRequest} message WriteUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = $root.google.cloud.retail.v2beta.UserEvent.toObject(message.userEvent, options); + return object; + }; + + /** + * Converts this WriteUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + WriteUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WriteUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.WriteUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WriteUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.WriteUserEventRequest"; + }; + + return WriteUserEventRequest; + })(); + + v2beta.CollectUserEventRequest = (function() { + + /** + * Properties of a CollectUserEventRequest. + * @memberof google.cloud.retail.v2beta + * @interface ICollectUserEventRequest + * @property {string|null} [parent] CollectUserEventRequest parent + * @property {string|null} [userEvent] CollectUserEventRequest userEvent + * @property {string|null} [uri] CollectUserEventRequest uri + * @property {number|Long|null} [ets] CollectUserEventRequest ets + */ + + /** + * Constructs a new CollectUserEventRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a CollectUserEventRequest. + * @implements ICollectUserEventRequest + * @constructor + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest=} [properties] Properties to set + */ + function CollectUserEventRequest(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]]; + } + + /** + * CollectUserEventRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.parent = ""; + + /** + * CollectUserEventRequest userEvent. + * @member {string} userEvent + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.userEvent = ""; + + /** + * CollectUserEventRequest uri. + * @member {string} uri + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.uri = ""; + + /** + * CollectUserEventRequest ets. + * @member {number|Long} ets + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @instance + */ + CollectUserEventRequest.prototype.ets = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new CollectUserEventRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.CollectUserEventRequest} CollectUserEventRequest instance + */ + CollectUserEventRequest.create = function create(properties) { + return new CollectUserEventRequest(properties); + }; + + /** + * Encodes the specified CollectUserEventRequest message. Does not implicitly {@link google.cloud.retail.v2beta.CollectUserEventRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEvent != null && Object.hasOwnProperty.call(message, "userEvent")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.userEvent); + if (message.uri != null && Object.hasOwnProperty.call(message, "uri")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.uri); + if (message.ets != null && Object.hasOwnProperty.call(message, "ets")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.ets); + return writer; + }; + + /** + * Encodes the specified CollectUserEventRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.CollectUserEventRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.ICollectUserEventRequest} message CollectUserEventRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CollectUserEventRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.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.cloud.retail.v2beta.CollectUserEventRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEvent = reader.string(); + break; + } + case 3: { + message.uri = reader.string(); + break; + } + case 4: { + message.ets = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CollectUserEventRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.CollectUserEventRequest} CollectUserEventRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CollectUserEventRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CollectUserEventRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CollectUserEventRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + if (!$util.isString(message.userEvent)) + return "userEvent: string expected"; + if (message.uri != null && message.hasOwnProperty("uri")) + if (!$util.isString(message.uri)) + return "uri: string expected"; + if (message.ets != null && message.hasOwnProperty("ets")) + if (!$util.isInteger(message.ets) && !(message.ets && $util.isInteger(message.ets.low) && $util.isInteger(message.ets.high))) + return "ets: integer|Long expected"; + return null; + }; + + /** + * Creates a CollectUserEventRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.CollectUserEventRequest} CollectUserEventRequest + */ + CollectUserEventRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.CollectUserEventRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.CollectUserEventRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.userEvent != null) + message.userEvent = String(object.userEvent); + if (object.uri != null) + message.uri = String(object.uri); + if (object.ets != null) + if ($util.Long) + (message.ets = $util.Long.fromValue(object.ets)).unsigned = false; + else if (typeof object.ets === "string") + message.ets = parseInt(object.ets, 10); + else if (typeof object.ets === "number") + message.ets = object.ets; + else if (typeof object.ets === "object") + message.ets = new $util.LongBits(object.ets.low >>> 0, object.ets.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a CollectUserEventRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {google.cloud.retail.v2beta.CollectUserEventRequest} message CollectUserEventRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CollectUserEventRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEvent = ""; + object.uri = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.ets = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.ets = options.longs === String ? "0" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEvent != null && message.hasOwnProperty("userEvent")) + object.userEvent = message.userEvent; + if (message.uri != null && message.hasOwnProperty("uri")) + object.uri = message.uri; + if (message.ets != null && message.hasOwnProperty("ets")) + if (typeof message.ets === "number") + object.ets = options.longs === String ? String(message.ets) : message.ets; + else + object.ets = options.longs === String ? $util.Long.prototype.toString.call(message.ets) : options.longs === Number ? new $util.LongBits(message.ets.low >>> 0, message.ets.high >>> 0).toNumber() : message.ets; + return object; + }; + + /** + * Converts this CollectUserEventRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @instance + * @returns {Object.} JSON object + */ + CollectUserEventRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CollectUserEventRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.CollectUserEventRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CollectUserEventRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.CollectUserEventRequest"; + }; + + return CollectUserEventRequest; + })(); + + v2beta.RejoinUserEventsRequest = (function() { + + /** + * Properties of a RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @interface IRejoinUserEventsRequest + * @property {string|null} [parent] RejoinUserEventsRequest parent + * @property {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope|null} [userEventRejoinScope] RejoinUserEventsRequest userEventRejoinScope + */ + + /** + * Constructs a new RejoinUserEventsRequest. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RejoinUserEventsRequest. + * @implements IRejoinUserEventsRequest + * @constructor + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest=} [properties] Properties to set + */ + function RejoinUserEventsRequest(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]]; + } + + /** + * RejoinUserEventsRequest parent. + * @member {string} parent + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.parent = ""; + + /** + * RejoinUserEventsRequest userEventRejoinScope. + * @member {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} userEventRejoinScope + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @instance + */ + RejoinUserEventsRequest.prototype.userEventRejoinScope = 0; + + /** + * Creates a new RejoinUserEventsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RejoinUserEventsRequest} RejoinUserEventsRequest instance + */ + RejoinUserEventsRequest.create = function create(properties) { + return new RejoinUserEventsRequest(properties); + }; + + /** + * Encodes the specified RejoinUserEventsRequest message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.userEventRejoinScope != null && Object.hasOwnProperty.call(message, "userEventRejoinScope")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.userEventRejoinScope); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsRequest message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsRequest} message RejoinUserEventsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.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.cloud.retail.v2beta.RejoinUserEventsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.userEventRejoinScope = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RejoinUserEventsRequest} RejoinUserEventsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsRequest message. + * @function verify + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + switch (message.userEventRejoinScope) { + default: + return "userEventRejoinScope: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a RejoinUserEventsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RejoinUserEventsRequest} RejoinUserEventsRequest + */ + RejoinUserEventsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RejoinUserEventsRequest) + return object; + var message = new $root.google.cloud.retail.v2beta.RejoinUserEventsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + switch (object.userEventRejoinScope) { + default: + if (typeof object.userEventRejoinScope === "number") { + message.userEventRejoinScope = object.userEventRejoinScope; + break; + } + break; + case "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": + case 0: + message.userEventRejoinScope = 0; + break; + case "JOINED_EVENTS": + case 1: + message.userEventRejoinScope = 1; + break; + case "UNJOINED_EVENTS": + case 2: + message.userEventRejoinScope = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest} message RejoinUserEventsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.userEventRejoinScope = options.enums === String ? "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED" : 0; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.userEventRejoinScope != null && message.hasOwnProperty("userEventRejoinScope")) + object.userEventRejoinScope = options.enums === String ? $root.google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] === undefined ? message.userEventRejoinScope : $root.google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope[message.userEventRejoinScope] : message.userEventRejoinScope; + return object; + }; + + /** + * Converts this RejoinUserEventsRequest to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsRequest + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RejoinUserEventsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RejoinUserEventsRequest"; + }; + + /** + * UserEventRejoinScope enum. + * @name google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope + * @enum {number} + * @property {number} USER_EVENT_REJOIN_SCOPE_UNSPECIFIED=0 USER_EVENT_REJOIN_SCOPE_UNSPECIFIED value + * @property {number} JOINED_EVENTS=1 JOINED_EVENTS value + * @property {number} UNJOINED_EVENTS=2 UNJOINED_EVENTS value + */ + RejoinUserEventsRequest.UserEventRejoinScope = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "JOINED_EVENTS"] = 1; + values[valuesById[2] = "UNJOINED_EVENTS"] = 2; + return values; + })(); + + return RejoinUserEventsRequest; + })(); + + v2beta.RejoinUserEventsResponse = (function() { + + /** + * Properties of a RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @interface IRejoinUserEventsResponse + * @property {number|Long|null} [rejoinedUserEventsCount] RejoinUserEventsResponse rejoinedUserEventsCount + */ + + /** + * Constructs a new RejoinUserEventsResponse. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RejoinUserEventsResponse. + * @implements IRejoinUserEventsResponse + * @constructor + * @param {google.cloud.retail.v2beta.IRejoinUserEventsResponse=} [properties] Properties to set + */ + function RejoinUserEventsResponse(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]]; + } + + /** + * RejoinUserEventsResponse rejoinedUserEventsCount. + * @member {number|Long} rejoinedUserEventsCount + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @instance + */ + RejoinUserEventsResponse.prototype.rejoinedUserEventsCount = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new RejoinUserEventsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsResponse=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RejoinUserEventsResponse} RejoinUserEventsResponse instance + */ + RejoinUserEventsResponse.create = function create(properties) { + return new RejoinUserEventsResponse(properties); + }; + + /** + * Encodes the specified RejoinUserEventsResponse message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rejoinedUserEventsCount != null && Object.hasOwnProperty.call(message, "rejoinedUserEventsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.rejoinedUserEventsCount); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsResponse message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsResponse} message RejoinUserEventsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.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.cloud.retail.v2beta.RejoinUserEventsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.rejoinedUserEventsCount = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RejoinUserEventsResponse} RejoinUserEventsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsResponse message. + * @function verify + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (!$util.isInteger(message.rejoinedUserEventsCount) && !(message.rejoinedUserEventsCount && $util.isInteger(message.rejoinedUserEventsCount.low) && $util.isInteger(message.rejoinedUserEventsCount.high))) + return "rejoinedUserEventsCount: integer|Long expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RejoinUserEventsResponse} RejoinUserEventsResponse + */ + RejoinUserEventsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RejoinUserEventsResponse) + return object; + var message = new $root.google.cloud.retail.v2beta.RejoinUserEventsResponse(); + if (object.rejoinedUserEventsCount != null) + if ($util.Long) + (message.rejoinedUserEventsCount = $util.Long.fromValue(object.rejoinedUserEventsCount)).unsigned = false; + else if (typeof object.rejoinedUserEventsCount === "string") + message.rejoinedUserEventsCount = parseInt(object.rejoinedUserEventsCount, 10); + else if (typeof object.rejoinedUserEventsCount === "number") + message.rejoinedUserEventsCount = object.rejoinedUserEventsCount; + else if (typeof object.rejoinedUserEventsCount === "object") + message.rejoinedUserEventsCount = new $util.LongBits(object.rejoinedUserEventsCount.low >>> 0, object.rejoinedUserEventsCount.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a RejoinUserEventsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {google.cloud.retail.v2beta.RejoinUserEventsResponse} message RejoinUserEventsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsResponse.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.rejoinedUserEventsCount = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.rejoinedUserEventsCount = options.longs === String ? "0" : 0; + if (message.rejoinedUserEventsCount != null && message.hasOwnProperty("rejoinedUserEventsCount")) + if (typeof message.rejoinedUserEventsCount === "number") + object.rejoinedUserEventsCount = options.longs === String ? String(message.rejoinedUserEventsCount) : message.rejoinedUserEventsCount; + else + object.rejoinedUserEventsCount = options.longs === String ? $util.Long.prototype.toString.call(message.rejoinedUserEventsCount) : options.longs === Number ? new $util.LongBits(message.rejoinedUserEventsCount.low >>> 0, message.rejoinedUserEventsCount.high >>> 0).toNumber() : message.rejoinedUserEventsCount; + return object; + }; + + /** + * Converts this RejoinUserEventsResponse to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsResponse + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RejoinUserEventsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RejoinUserEventsResponse"; + }; + + return RejoinUserEventsResponse; + })(); + + v2beta.RejoinUserEventsMetadata = (function() { + + /** + * Properties of a RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2beta + * @interface IRejoinUserEventsMetadata + */ + + /** + * Constructs a new RejoinUserEventsMetadata. + * @memberof google.cloud.retail.v2beta + * @classdesc Represents a RejoinUserEventsMetadata. + * @implements IRejoinUserEventsMetadata + * @constructor + * @param {google.cloud.retail.v2beta.IRejoinUserEventsMetadata=} [properties] Properties to set + */ + function RejoinUserEventsMetadata(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 RejoinUserEventsMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsMetadata=} [properties] Properties to set + * @returns {google.cloud.retail.v2beta.RejoinUserEventsMetadata} RejoinUserEventsMetadata instance + */ + RejoinUserEventsMetadata.create = function create(properties) { + return new RejoinUserEventsMetadata(properties); + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RejoinUserEventsMetadata message, length delimited. Does not implicitly {@link google.cloud.retail.v2beta.RejoinUserEventsMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2beta.IRejoinUserEventsMetadata} message RejoinUserEventsMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RejoinUserEventsMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.retail.v2beta.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.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.cloud.retail.v2beta.RejoinUserEventsMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RejoinUserEventsMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.retail.v2beta.RejoinUserEventsMetadata} RejoinUserEventsMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RejoinUserEventsMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RejoinUserEventsMetadata message. + * @function verify + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RejoinUserEventsMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RejoinUserEventsMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.retail.v2beta.RejoinUserEventsMetadata} RejoinUserEventsMetadata + */ + RejoinUserEventsMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.retail.v2beta.RejoinUserEventsMetadata) + return object; + return new $root.google.cloud.retail.v2beta.RejoinUserEventsMetadata(); + }; + + /** + * Creates a plain object from a RejoinUserEventsMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {google.cloud.retail.v2beta.RejoinUserEventsMetadata} message RejoinUserEventsMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RejoinUserEventsMetadata.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RejoinUserEventsMetadata to JSON. + * @function toJSON + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @instance + * @returns {Object.} JSON object + */ + RejoinUserEventsMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RejoinUserEventsMetadata + * @function getTypeUrl + * @memberof google.cloud.retail.v2beta.RejoinUserEventsMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RejoinUserEventsMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.retail.v2beta.RejoinUserEventsMetadata"; + }; + + return RejoinUserEventsMetadata; + })(); + + return v2beta; + })(); + + return retail; + })(); + + return cloud; + })(); + + google.api = (function() { + + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {}; + + /** + * 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 + */ + 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; + return values; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + this.style = []; + 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]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = ""; + + /** + * ResourceDescriptor style. + * @member {Array.} style + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.style = $util.emptyArray; + + /** + * Creates a new ResourceDescriptor instance using the specified properties. + * @function create + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @returns {google.api.ResourceDescriptor} ResourceDescriptor instance + */ + ResourceDescriptor.create = function create(properties) { + return new ResourceDescriptor(properties); + }; + + /** + * Encodes the specified ResourceDescriptor message. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.pattern != null && message.pattern.length) + for (var i = 0; i < message.pattern.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.pattern[i]); + if (message.nameField != null && Object.hasOwnProperty.call(message, "nameField")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.nameField); + if (message.history != null && Object.hasOwnProperty.call(message, "history")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.history); + if (message.plural != null && Object.hasOwnProperty.call(message, "plural")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.plural); + if (message.singular != null && Object.hasOwnProperty.call(message, "singular")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.singular); + if (message.style != null && message.style.length) { + writer.uint32(/* id 10, wireType 2 =*/82).fork(); + for (var i = 0; i < message.style.length; ++i) + writer.int32(message.style[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified ResourceDescriptor message, length delimited. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.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.ResourceDescriptor(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + if (!(message.pattern && message.pattern.length)) + message.pattern = []; + message.pattern.push(reader.string()); + break; + } + case 3: { + message.nameField = reader.string(); + break; + } + case 4: { + message.history = reader.int32(); + break; + } + case 5: { + message.plural = reader.string(); + break; + } + case 6: { + message.singular = reader.string(); + break; + } + case 10: { + if (!(message.style && message.style.length)) + message.style = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.style.push(reader.int32()); + } else + message.style.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResourceDescriptor message. + * @function verify + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceDescriptor.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.pattern != null && message.hasOwnProperty("pattern")) { + if (!Array.isArray(message.pattern)) + return "pattern: array expected"; + for (var i = 0; i < message.pattern.length; ++i) + if (!$util.isString(message.pattern[i])) + return "pattern: string[] expected"; + } + if (message.nameField != null && message.hasOwnProperty("nameField")) + if (!$util.isString(message.nameField)) + return "nameField: string expected"; + if (message.history != null && message.hasOwnProperty("history")) + switch (message.history) { + default: + return "history: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.plural != null && message.hasOwnProperty("plural")) + if (!$util.isString(message.plural)) + return "plural: string expected"; + if (message.singular != null && message.hasOwnProperty("singular")) + if (!$util.isString(message.singular)) + return "singular: string expected"; + if (message.style != null && message.hasOwnProperty("style")) { + if (!Array.isArray(message.style)) + return "style: array expected"; + for (var i = 0; i < message.style.length; ++i) + switch (message.style[i]) { + default: + return "style: enum value[] expected"; + case 0: + case 1: + break; + } + } + return null; + }; + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object; + var message = new $root.google.api.ResourceDescriptor(); + if (object.type != null) + message.type = String(object.type); + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError(".google.api.ResourceDescriptor.pattern: array expected"); + message.pattern = []; + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]); + } + if (object.nameField != null) + message.nameField = String(object.nameField); + switch (object.history) { + default: + if (typeof object.history === "number") { + message.history = object.history; + break; + } + break; + case "HISTORY_UNSPECIFIED": + case 0: + message.history = 0; + break; + case "ORIGINALLY_SINGLE_PATTERN": + case 1: + message.history = 1; + break; + case "FUTURE_MULTI_PATTERN": + case 2: + message.history = 2; + break; + } + if (object.plural != null) + message.plural = String(object.plural); + if (object.singular != null) + message.singular = String(object.singular); + if (object.style) { + if (!Array.isArray(object.style)) + throw TypeError(".google.api.ResourceDescriptor.style: array expected"); + message.style = []; + for (var i = 0; i < object.style.length; ++i) + switch (object.style[i]) { + default: + if (typeof object.style[i] === "number") { + message.style[i] = object.style[i]; + break; + } + case "STYLE_UNSPECIFIED": + case 0: + message.style[i] = 0; + break; + case "DECLARATIVE_FRIENDLY": + case 1: + message.style[i] = 1; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.pattern = []; + object.style = []; + } + if (options.defaults) { + object.type = ""; + object.nameField = ""; + object.history = options.enums === String ? "HISTORY_UNSPECIFIED" : 0; + object.plural = ""; + object.singular = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.pattern && message.pattern.length) { + object.pattern = []; + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j]; + } + if (message.nameField != null && message.hasOwnProperty("nameField")) + object.nameField = message.nameField; + if (message.history != null && message.hasOwnProperty("history")) + object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] === undefined ? message.history : $root.google.api.ResourceDescriptor.History[message.history] : message.history; + if (message.plural != null && message.hasOwnProperty("plural")) + object.plural = message.plural; + if (message.singular != null && message.hasOwnProperty("singular")) + object.singular = message.singular; + if (message.style && message.style.length) { + object.style = []; + for (var j = 0; j < message.style.length; ++j) + object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] === undefined ? message.style[j] : $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; + } + return object; + }; + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResourceDescriptor + * @function getTypeUrl + * @memberof google.api.ResourceDescriptor + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResourceDescriptor.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.ResourceDescriptor"; + }; + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {number} + * @property {number} HISTORY_UNSPECIFIED=0 HISTORY_UNSPECIFIED value + * @property {number} ORIGINALLY_SINGLE_PATTERN=1 ORIGINALLY_SINGLE_PATTERN value + * @property {number} FUTURE_MULTI_PATTERN=2 FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HISTORY_UNSPECIFIED"] = 0; + values[valuesById[1] = "ORIGINALLY_SINGLE_PATTERN"] = 1; + values[valuesById[2] = "FUTURE_MULTI_PATTERN"] = 2; + return values; + })(); + + /** + * Style enum. + * @name google.api.ResourceDescriptor.Style + * @enum {number} + * @property {number} STYLE_UNSPECIFIED=0 STYLE_UNSPECIFIED value + * @property {number} DECLARATIVE_FRIENDLY=1 DECLARATIVE_FRIENDLY value + */ + ResourceDescriptor.Style = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STYLE_UNSPECIFIED"] = 0; + values[valuesById[1] = "DECLARATIVE_FRIENDLY"] = 1; + return values; + })(); + + return ResourceDescriptor; + })(); + + api.ResourceReference = (function() { + + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(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]]; + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = ""; + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = ""; + + /** + * Creates a new ResourceReference instance using the specified properties. + * @function create + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference=} [properties] Properties to set + * @returns {google.api.ResourceReference} ResourceReference instance + */ + ResourceReference.create = function create(properties) { + return new ResourceReference(properties); + }; + + /** + * Encodes the specified ResourceReference message. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.childType != null && Object.hasOwnProperty.call(message, "childType")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.childType); + return writer; + }; + + /** + * Encodes the specified ResourceReference message, length delimited. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResourceReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.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.ResourceReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + message.childType = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResourceReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResourceReference message. + * @function verify + * @memberof google.api.ResourceReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.childType != null && message.hasOwnProperty("childType")) + if (!$util.isString(message.childType)) + return "childType: string expected"; + return null; + }; + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object; + var message = new $root.google.api.ResourceReference(); + if (object.type != null) + message.type = String(object.type); + if (object.childType != null) + message.childType = String(object.childType); + return message; + }; + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.childType = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.childType != null && message.hasOwnProperty("childType")) + object.childType = message.childType; + return object; + }; + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResourceReference + * @function getTypeUrl + * @memberof google.api.ResourceReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResourceReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.ResourceReference"; + }; + + return ResourceReference; + })(); + + 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.HttpBody = (function() { + + /** + * Properties of a HttpBody. + * @memberof google.api + * @interface IHttpBody + * @property {string|null} [contentType] HttpBody contentType + * @property {Uint8Array|null} [data] HttpBody data + * @property {Array.|null} [extensions] HttpBody extensions + */ + + /** + * Constructs a new HttpBody. + * @memberof google.api + * @classdesc Represents a HttpBody. + * @implements IHttpBody + * @constructor + * @param {google.api.IHttpBody=} [properties] Properties to set + */ + function HttpBody(properties) { + this.extensions = []; + 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]]; + } + + /** + * HttpBody contentType. + * @member {string} contentType + * @memberof google.api.HttpBody + * @instance + */ + HttpBody.prototype.contentType = ""; + + /** + * HttpBody data. + * @member {Uint8Array} data + * @memberof google.api.HttpBody + * @instance + */ + HttpBody.prototype.data = $util.newBuffer([]); + + /** + * HttpBody extensions. + * @member {Array.} extensions + * @memberof google.api.HttpBody + * @instance + */ + HttpBody.prototype.extensions = $util.emptyArray; + + /** + * Creates a new HttpBody instance using the specified properties. + * @function create + * @memberof google.api.HttpBody + * @static + * @param {google.api.IHttpBody=} [properties] Properties to set + * @returns {google.api.HttpBody} HttpBody instance + */ + HttpBody.create = function create(properties) { + return new HttpBody(properties); + }; + + /** + * Encodes the specified HttpBody message. Does not implicitly {@link google.api.HttpBody.verify|verify} messages. + * @function encode + * @memberof google.api.HttpBody + * @static + * @param {google.api.IHttpBody} message HttpBody message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpBody.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.contentType != null && Object.hasOwnProperty.call(message, "contentType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.contentType); + if (message.data != null && Object.hasOwnProperty.call(message, "data")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.data); + if (message.extensions != null && message.extensions.length) + for (var i = 0; i < message.extensions.length; ++i) + $root.google.protobuf.Any.encode(message.extensions[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified HttpBody message, length delimited. Does not implicitly {@link google.api.HttpBody.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpBody + * @static + * @param {google.api.IHttpBody} message HttpBody message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpBody.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HttpBody message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpBody + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpBody} HttpBody + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpBody.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.HttpBody(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.contentType = reader.string(); + break; + } + case 2: { + message.data = reader.bytes(); + break; + } + case 3: { + if (!(message.extensions && message.extensions.length)) + message.extensions = []; + message.extensions.push($root.google.protobuf.Any.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HttpBody message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpBody + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpBody} HttpBody + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpBody.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HttpBody message. + * @function verify + * @memberof google.api.HttpBody + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpBody.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.contentType != null && message.hasOwnProperty("contentType")) + if (!$util.isString(message.contentType)) + return "contentType: string expected"; + if (message.data != null && message.hasOwnProperty("data")) + if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data))) + return "data: buffer expected"; + if (message.extensions != null && message.hasOwnProperty("extensions")) { + if (!Array.isArray(message.extensions)) + return "extensions: array expected"; + for (var i = 0; i < message.extensions.length; ++i) { + var error = $root.google.protobuf.Any.verify(message.extensions[i]); + if (error) + return "extensions." + error; + } + } + return null; + }; + + /** + * Creates a HttpBody message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpBody + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpBody} HttpBody + */ + HttpBody.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpBody) + return object; + var message = new $root.google.api.HttpBody(); + if (object.contentType != null) + message.contentType = String(object.contentType); + if (object.data != null) + if (typeof object.data === "string") + $util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0); + else if (object.data.length >= 0) + message.data = object.data; + if (object.extensions) { + if (!Array.isArray(object.extensions)) + throw TypeError(".google.api.HttpBody.extensions: array expected"); + message.extensions = []; + for (var i = 0; i < object.extensions.length; ++i) { + if (typeof object.extensions[i] !== "object") + throw TypeError(".google.api.HttpBody.extensions: object expected"); + message.extensions[i] = $root.google.protobuf.Any.fromObject(object.extensions[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HttpBody message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpBody + * @static + * @param {google.api.HttpBody} message HttpBody + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpBody.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.extensions = []; + if (options.defaults) { + object.contentType = ""; + if (options.bytes === String) + object.data = ""; + else { + object.data = []; + if (options.bytes !== Array) + object.data = $util.newBuffer(object.data); + } + } + if (message.contentType != null && message.hasOwnProperty("contentType")) + object.contentType = message.contentType; + if (message.data != null && message.hasOwnProperty("data")) + object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data; + if (message.extensions && message.extensions.length) { + object.extensions = []; + for (var j = 0; j < message.extensions.length; ++j) + object.extensions[j] = $root.google.protobuf.Any.toObject(message.extensions[j], options); + } + return object; + }; + + /** + * Converts this HttpBody to JSON. + * @function toJSON + * @memberof google.api.HttpBody + * @instance + * @returns {Object.} JSON object + */ + HttpBody.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for HttpBody + * @function getTypeUrl + * @memberof google.api.HttpBody + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HttpBody.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.HttpBody"; + }; + + return HttpBody; + })(); + + 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; + })(); + + 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} [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 {string|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.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 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 {string} edition + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.edition = ""; + + /** + * 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 13, wireType 2 =*/106).string(message.edition); + 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 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 13: { + message.edition = reader.string(); + 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.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")) + if (!$util.isString(message.edition)) + return "edition: string expected"; + 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.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); + if (object.edition != null) + message.edition = String(object.edition); + 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 = []; + } + if (options.defaults) { + object.name = ""; + object["package"] = ""; + object.options = null; + object.sourceCodeInfo = null; + object.syntax = ""; + object.edition = ""; + } + 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 = message.edition; + 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 + */ + + /** + * 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; + + /** + * 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]); + 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; + } + 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"; + } + 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]); + } + 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; + } + 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]; + } + 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 + */ + + /** + * 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 = []; + 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; + + /** + * 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.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; + } + 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; + } + } + 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]); + } + } + 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.uninterpretedOption = []; + 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"; + }; + + 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 2: + case 3: + 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_REQUIRED": + case 2: + message.label = 2; + break; + case "LABEL_REPEATED": + case 3: + message.label = 3; + 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_REQUIRED=2 LABEL_REQUIRED value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = 1; + values[valuesById[2] = "LABEL_REQUIRED"] = 2; + values[valuesById[3] = "LABEL_REPEATED"] = 3; + 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 + */ + + /** + * 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; + + /** + * 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]); + 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; + } + 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"; + } + 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]); + } + 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; + } + 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]; + } + 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} [phpGenericServices] FileOptions phpGenericServices + * @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 {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * 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 = []; + this[".google.api.resourceDefinition"] = []; + 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 phpGenericServices. + * @member {boolean} phpGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpGenericServices = 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 uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype[".google.api.resourceDefinition"] = $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.phpGenericServices != null && Object.hasOwnProperty.call(message, "phpGenericServices")) + writer.uint32(/* id 42, wireType 0 =*/336).bool(message.phpGenericServices); + 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.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.resourceDefinition"] != null && message[".google.api.resourceDefinition"].length) + for (var i = 0; i < message[".google.api.resourceDefinition"].length; ++i) + $root.google.api.ResourceDescriptor.encode(message[".google.api.resourceDefinition"][i], writer.uint32(/* id 1053, wireType 2 =*/8426).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 42: { + message.phpGenericServices = 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 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1053: { + if (!(message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length)) + message[".google.api.resourceDefinition"] = []; + message[".google.api.resourceDefinition"].push($root.google.api.ResourceDescriptor.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.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) + if (typeof message.phpGenericServices !== "boolean") + return "phpGenericServices: 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.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.resourceDefinition"] != null && message.hasOwnProperty(".google.api.resourceDefinition")) { + if (!Array.isArray(message[".google.api.resourceDefinition"])) + return ".google.api.resourceDefinition: array expected"; + for (var i = 0; i < message[".google.api.resourceDefinition"].length; ++i) { + var error = $root.google.api.ResourceDescriptor.verify(message[".google.api.resourceDefinition"][i]); + if (error) + return ".google.api.resourceDefinition." + 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.phpGenericServices != null) + message.phpGenericServices = Boolean(object.phpGenericServices); + 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.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]); + } + } + if (object[".google.api.resourceDefinition"]) { + if (!Array.isArray(object[".google.api.resourceDefinition"])) + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: array expected"); + message[".google.api.resourceDefinition"] = []; + for (var i = 0; i < object[".google.api.resourceDefinition"].length; ++i) { + if (typeof object[".google.api.resourceDefinition"][i] !== "object") + throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: object expected"); + message[".google.api.resourceDefinition"][i] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resourceDefinition"][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 = []; + object[".google.api.resourceDefinition"] = []; + } + 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.phpGenericServices = false; + object.phpMetadataNamespace = ""; + object.rubyPackage = ""; + } + 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.phpGenericServices != null && message.hasOwnProperty("phpGenericServices")) + object.phpGenericServices = message.phpGenericServices; + if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) + object.phpMetadataNamespace = message.phpMetadataNamespace; + if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) + object.rubyPackage = message.rubyPackage; + 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.resourceDefinition"] && message[".google.api.resourceDefinition"].length) { + object[".google.api.resourceDefinition"] = []; + for (var j = 0; j < message[".google.api.resourceDefinition"].length; ++j) + object[".google.api.resourceDefinition"][j] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resourceDefinition"][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 {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * 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 uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype[".google.api.resource"] = null; + + /** + * 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.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.resource"] != null && Object.hasOwnProperty.call(message, ".google.api.resource")) + $root.google.api.ResourceDescriptor.encode(message[".google.api.resource"], writer.uint32(/* id 1053, wireType 2 =*/8426).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 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1053: { + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.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.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.resource"] != null && message.hasOwnProperty(".google.api.resource")) { + var error = $root.google.api.ResourceDescriptor.verify(message[".google.api.resource"]); + if (error) + return ".google.api.resource." + 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.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]); + } + } + if (object[".google.api.resource"] != null) { + if (typeof object[".google.api.resource"] !== "object") + throw TypeError(".google.protobuf.MessageOptions..google.api.resource: object expected"); + message[".google.api.resource"] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resource"]); + } + 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[".google.api.resource"] = 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.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.resource"] != null && message.hasOwnProperty(".google.api.resource")) + object[".google.api.resource"] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resource"], 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 {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * 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.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 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; + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.resourceReference"] = null; + + /** + * 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.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) { + writer.uint32(/* id 1052, wireType 2 =*/8418).fork(); + for (var i = 0; i < message[".google.api.fieldBehavior"].length; ++i) + writer.int32(message[".google.api.fieldBehavior"][i]); + writer.ldelim(); + } + if (message[".google.api.resourceReference"] != null && Object.hasOwnProperty.call(message, ".google.api.resourceReference")) + $root.google.api.ResourceReference.encode(message[".google.api.resourceReference"], writer.uint32(/* id 1055, wireType 2 =*/8442).fork()).ldelim(); + 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 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; + } + case 1055: { + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.decode(reader, reader.uint32()); + 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.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: + break; + } + } + if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) { + var error = $root.google.api.ResourceReference.verify(message[".google.api.resourceReference"]); + if (error) + return ".google.api.resourceReference." + error; + } + 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.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; + } + } + if (object[".google.api.resourceReference"] != null) { + if (typeof object[".google.api.resourceReference"] !== "object") + throw TypeError(".google.protobuf.FieldOptions..google.api.resourceReference: object expected"); + message[".google.api.resourceReference"] = $root.google.api.ResourceReference.fromObject(object[".google.api.resourceReference"]); + } + 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.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[".google.api.resourceReference"] = 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.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]; + } + if (message[".google.api.resourceReference"] != null && message.hasOwnProperty(".google.api.resourceReference")) + object[".google.api.resourceReference"] = $root.google.api.ResourceReference.toObject(message[".google.api.resourceReference"], options); + 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; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @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 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.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 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.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.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 (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 {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 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.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 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.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.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; + } + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + object.allowAlias = message.allowAlias; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + 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 {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 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.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 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.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.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; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + 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 {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 + */ + + /** + * 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 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"] = ""; + + /** + * 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.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"]); + 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 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; + } + 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.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"; + 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.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"]); + 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[".google.api.defaultHost"] = ""; + object[".google.api.oauthScopes"] = ""; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + 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"]; + 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 {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 + */ + + /** + * 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 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; + + /** + * 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.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(); + 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 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; + } + 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.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; + } + 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.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"]); + } + 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[".google.longrunning.operationInfo"] = null; + object[".google.api.http"] = 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.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); + 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.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; + })(); + + 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.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.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(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]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + /** + * Creates a new FieldMask instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + * @returns {google.protobuf.FieldMask} FieldMask instance + */ + FieldMask.create = function create(properties) { + return new FieldMask(properties); + }; + + /** + * Encodes the specified FieldMask message. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.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 FieldMask message, length delimited. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldMask message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.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.FieldMask(); + 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 FieldMask message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldMask message. + * @function verify + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldMask.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 FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object; + var message = new $root.google.protobuf.FieldMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.protobuf.FieldMask.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 FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.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 FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask + * @instance + * @returns {Object.} JSON object + */ + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FieldMask + * @function getTypeUrl + * @memberof google.protobuf.FieldMask + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FieldMask.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldMask"; + }; + + return FieldMask; + })(); + + 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; + })(); + + 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.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; + })(); + + return protobuf; + })(); + + 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.Date = (function() { + + /** + * Properties of a Date. + * @memberof google.type + * @interface IDate + * @property {number|null} [year] Date year + * @property {number|null} [month] Date month + * @property {number|null} [day] Date day + */ + + /** + * Constructs a new Date. + * @memberof google.type + * @classdesc Represents a Date. + * @implements IDate + * @constructor + * @param {google.type.IDate=} [properties] Properties to set + */ + function Date(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]]; + } + + /** + * Date year. + * @member {number} year + * @memberof google.type.Date + * @instance + */ + Date.prototype.year = 0; + + /** + * Date month. + * @member {number} month + * @memberof google.type.Date + * @instance + */ + Date.prototype.month = 0; + + /** + * Date day. + * @member {number} day + * @memberof google.type.Date + * @instance + */ + Date.prototype.day = 0; + + /** + * Creates a new Date instance using the specified properties. + * @function create + * @memberof google.type.Date + * @static + * @param {google.type.IDate=} [properties] Properties to set + * @returns {google.type.Date} Date instance + */ + Date.create = function create(properties) { + return new Date(properties); + }; + + /** + * Encodes the specified Date message. Does not implicitly {@link google.type.Date.verify|verify} messages. + * @function encode + * @memberof google.type.Date + * @static + * @param {google.type.IDate} message Date message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Date.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.year != null && Object.hasOwnProperty.call(message, "year")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.year); + if (message.month != null && Object.hasOwnProperty.call(message, "month")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.month); + if (message.day != null && Object.hasOwnProperty.call(message, "day")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.day); + return writer; + }; + + /** + * Encodes the specified Date message, length delimited. Does not implicitly {@link google.type.Date.verify|verify} messages. + * @function encodeDelimited + * @memberof google.type.Date + * @static + * @param {google.type.IDate} message Date message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Date.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Date message from the specified reader or buffer. + * @function decode + * @memberof google.type.Date + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.type.Date} Date + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Date.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.Date(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.year = reader.int32(); + break; + } + case 2: { + message.month = reader.int32(); + break; + } + case 3: { + message.day = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Date message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.type.Date + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.type.Date} Date + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Date.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Date message. + * @function verify + * @memberof google.type.Date + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Date.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.year != null && message.hasOwnProperty("year")) + if (!$util.isInteger(message.year)) + return "year: integer expected"; + if (message.month != null && message.hasOwnProperty("month")) + if (!$util.isInteger(message.month)) + return "month: integer expected"; + if (message.day != null && message.hasOwnProperty("day")) + if (!$util.isInteger(message.day)) + return "day: integer expected"; + return null; + }; + + /** + * Creates a Date message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.Date + * @static + * @param {Object.} object Plain object + * @returns {google.type.Date} Date + */ + Date.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.Date) + return object; + var message = new $root.google.type.Date(); + if (object.year != null) + message.year = object.year | 0; + if (object.month != null) + message.month = object.month | 0; + if (object.day != null) + message.day = object.day | 0; + return message; + }; + + /** + * Creates a plain object from a Date message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.Date + * @static + * @param {google.type.Date} message Date + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Date.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.year = 0; + object.month = 0; + object.day = 0; + } + if (message.year != null && message.hasOwnProperty("year")) + object.year = message.year; + if (message.month != null && message.hasOwnProperty("month")) + object.month = message.month; + if (message.day != null && message.hasOwnProperty("day")) + object.day = message.day; + return object; + }; + + /** + * Converts this Date to JSON. + * @function toJSON + * @memberof google.type.Date + * @instance + * @returns {Object.} JSON object + */ + Date.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Date + * @function getTypeUrl + * @memberof google.type.Date + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Date.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.type.Date"; + }; + + return Date; + })(); + + return type; + })(); + + 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; + })(); + + return google; + })(); + + return $root; +}); diff --git a/packages/google-cloud-retail/protos/protos.json b/packages/google-cloud-retail/protos/protos.json new file mode 100644 index 00000000000..24aeb658c11 --- /dev/null +++ b/packages/google-cloud-retail/protos/protos.json @@ -0,0 +1,15069 @@ +{ + "nested": { + "google": { + "nested": { + "cloud": { + "nested": { + "retail": { + "nested": { + "v2": { + "options": { + "csharp_namespace": "Google.Cloud.Retail.V2", + "go_package": "google.golang.org/genproto/googleapis/cloud/retail/v2;retail", + "java_multiple_files": true, + "java_outer_classname": "UserEventServiceProto", + "java_package": "com.google.cloud.retail.v2", + "objc_class_prefix": "RETAIL", + "php_namespace": "Google\\Cloud\\Retail\\V2", + "ruby_package": "Google::Cloud::Retail::V2", + "(google.api.resource_definition).type": "retail.googleapis.com/Branch", + "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" + }, + "nested": { + "ProductLevelConfig": { + "fields": { + "ingestionProductType": { + "type": "string", + "id": 1 + }, + "merchantCenterProductIdField": { + "type": "string", + "id": 2 + } + } + }, + "CatalogAttribute": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "inUse": { + "type": "bool", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "type": { + "type": "AttributeType", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "indexableOption": { + "type": "IndexableOption", + "id": 5 + }, + "dynamicFacetableOption": { + "type": "DynamicFacetableOption", + "id": 6 + }, + "searchableOption": { + "type": "SearchableOption", + "id": 7 + } + }, + "nested": { + "AttributeType": { + "values": { + "UNKNOWN": 0, + "TEXTUAL": 1, + "NUMERICAL": 2 + } + }, + "IndexableOption": { + "values": { + "INDEXABLE_OPTION_UNSPECIFIED": 0, + "INDEXABLE_ENABLED": 1, + "INDEXABLE_DISABLED": 2 + } + }, + "DynamicFacetableOption": { + "values": { + "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": 0, + "DYNAMIC_FACETABLE_ENABLED": 1, + "DYNAMIC_FACETABLE_DISABLED": 2 + } + }, + "SearchableOption": { + "values": { + "SEARCHABLE_OPTION_UNSPECIFIED": 0, + "SEARCHABLE_ENABLED": 1, + "SEARCHABLE_DISABLED": 2 + } + } + } + }, + "AttributesConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/AttributesConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "catalogAttributes": { + "keyType": "string", + "type": "CatalogAttribute", + "id": 2 + }, + "attributeConfigLevel": { + "type": "AttributeConfigLevel", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "CompletionConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/CompletionConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "matchingOrder": { + "type": "string", + "id": 2 + }, + "maxSuggestions": { + "type": "int32", + "id": 3 + }, + "minPrefixLength": { + "type": "int32", + "id": 4 + }, + "autoLearning": { + "type": "bool", + "id": 11 + }, + "suggestionsInputConfig": { + "type": "CompletionDataInputConfig", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastSuggestionsImportOperation": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "denylistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastDenylistImportOperation": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "allowlistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastAllowlistImportOperation": { + "type": "string", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "Catalog": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Catalog", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "productLevelConfig": { + "type": "ProductLevelConfig", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "AttributeConfigLevel": { + "values": { + "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": 0, + "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": 1, + "CATALOG_LEVEL_ATTRIBUTE_CONFIG": 2 + } + }, + "SolutionType": { + "values": { + "SOLUTION_TYPE_UNSPECIFIED": 0, + "SOLUTION_TYPE_RECOMMENDATION": 1, + "SOLUTION_TYPE_SEARCH": 2 + } + }, + "SearchSolutionUseCase": { + "values": { + "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": 0, + "SEARCH_SOLUTION_USE_CASE_SEARCH": 1, + "SEARCH_SOLUTION_USE_CASE_BROWSE": 2 + } + }, + "Condition": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "QueryTerm", + "id": 1 + }, + "activeTimeRange": { + "rule": "repeated", + "type": "TimeRange", + "id": 3 + } + }, + "nested": { + "QueryTerm": { + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "fullMatch": { + "type": "bool", + "id": 2 + } + } + }, + "TimeRange": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + } + } + }, + "Rule": { + "oneofs": { + "action": { + "oneof": [ + "boostAction", + "redirectAction", + "onewaySynonymsAction", + "doNotAssociateAction", + "replacementAction", + "ignoreAction", + "filterAction", + "twowaySynonymsAction" + ] + } + }, + "fields": { + "boostAction": { + "type": "BoostAction", + "id": 2 + }, + "redirectAction": { + "type": "RedirectAction", + "id": 3 + }, + "onewaySynonymsAction": { + "type": "OnewaySynonymsAction", + "id": 6 + }, + "doNotAssociateAction": { + "type": "DoNotAssociateAction", + "id": 7 + }, + "replacementAction": { + "type": "ReplacementAction", + "id": 8 + }, + "ignoreAction": { + "type": "IgnoreAction", + "id": 9 + }, + "filterAction": { + "type": "FilterAction", + "id": 10 + }, + "twowaySynonymsAction": { + "type": "TwowaySynonymsAction", + "id": 11 + }, + "condition": { + "type": "Condition", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + }, + "nested": { + "BoostAction": { + "fields": { + "boost": { + "type": "float", + "id": 1 + }, + "productsFilter": { + "type": "string", + "id": 2 + } + } + }, + "FilterAction": { + "fields": { + "filter": { + "type": "string", + "id": 1 + } + } + }, + "RedirectAction": { + "fields": { + "redirectUri": { + "type": "string", + "id": 1 + } + } + }, + "TwowaySynonymsAction": { + "fields": { + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "OnewaySynonymsAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "onewayTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "DoNotAssociateAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "doNotAssociateTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "terms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "ReplacementAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "replacementTerm": { + "type": "string", + "id": 3 + }, + "term": { + "type": "string", + "id": 1 + } + } + }, + "IgnoreAction": { + "fields": { + "ignoreTerms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + } + } + }, + "Audience": { + "fields": { + "genders": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "ageGroups": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "ColorInfo": { + "fields": { + "colorFamilies": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "colors": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "CustomAttribute": { + "oneofs": { + "_searchable": { + "oneof": [ + "searchable" + ] + }, + "_indexable": { + "oneof": [ + "indexable" + ] + } + }, + "fields": { + "text": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "numbers": { + "rule": "repeated", + "type": "double", + "id": 2 + }, + "searchable": { + "type": "bool", + "id": 3, + "options": { + "deprecated": true, + "proto3_optional": true + } + }, + "indexable": { + "type": "bool", + "id": 4, + "options": { + "deprecated": true, + "proto3_optional": true + } + } + } + }, + "FulfillmentInfo": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "Image": { + "fields": { + "uri": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "height": { + "type": "int32", + "id": 2 + }, + "width": { + "type": "int32", + "id": 3 + } + } + }, + "Interval": { + "oneofs": { + "min": { + "oneof": [ + "minimum", + "exclusiveMinimum" + ] + }, + "max": { + "oneof": [ + "maximum", + "exclusiveMaximum" + ] + } + }, + "fields": { + "minimum": { + "type": "double", + "id": 1 + }, + "exclusiveMinimum": { + "type": "double", + "id": 2 + }, + "maximum": { + "type": "double", + "id": 3 + }, + "exclusiveMaximum": { + "type": "double", + "id": 4 + } + } + }, + "PriceInfo": { + "fields": { + "currencyCode": { + "type": "string", + "id": 1 + }, + "price": { + "type": "float", + "id": 2 + }, + "originalPrice": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "priceEffectiveTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "priceExpireTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + }, + "priceRange": { + "type": "PriceRange", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "PriceRange": { + "fields": { + "price": { + "type": "Interval", + "id": 1 + }, + "originalPrice": { + "type": "Interval", + "id": 2 + } + } + } + } + }, + "Rating": { + "fields": { + "ratingCount": { + "type": "int32", + "id": 1 + }, + "averageRating": { + "type": "float", + "id": 2 + }, + "ratingHistogram": { + "rule": "repeated", + "type": "int32", + "id": 3 + } + } + }, + "UserInfo": { + "fields": { + "userId": { + "type": "string", + "id": 1 + }, + "ipAddress": { + "type": "string", + "id": 2 + }, + "userAgent": { + "type": "string", + "id": 3 + }, + "directUserRequest": { + "type": "bool", + "id": 4 + } + } + }, + "LocalInventory": { + "fields": { + "placeId": { + "type": "string", + "id": 1 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 2 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 3 + }, + "fulfillmentTypes": { + "rule": "repeated", + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + } + } + }, + "GcsSource": { + "fields": { + "inputUris": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "dataSchema": { + "type": "string", + "id": 2 + } + } + }, + "BigQuerySource": { + "oneofs": { + "partition": { + "oneof": [ + "partitionDate" + ] + } + }, + "fields": { + "partitionDate": { + "type": "google.type.Date", + "id": 6 + }, + "projectId": { + "type": "string", + "id": 5 + }, + "datasetId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tableId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsStagingDir": { + "type": "string", + "id": 3 + }, + "dataSchema": { + "type": "string", + "id": 4 + } + } + }, + "ProductInlineSource": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventInlineSource": { + "fields": { + "userEvents": { + "rule": "repeated", + "type": "UserEvent", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportErrorsConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsPrefix" + ] + } + }, + "fields": { + "gcsPrefix": { + "type": "string", + "id": 1 + } + } + }, + "ImportProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "requestId": { + "type": "string", + "id": 6, + "options": { + "deprecated": true + } + }, + "inputConfig": { + "type": "ProductInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "reconciliationMode": { + "type": "ReconciliationMode", + "id": 5 + }, + "notificationPubsubTopic": { + "type": "string", + "id": 7 + } + }, + "nested": { + "ReconciliationMode": { + "values": { + "RECONCILIATION_MODE_UNSPECIFIED": 0, + "INCREMENTAL": 1, + "FULL": 2 + } + } + } + }, + "ImportUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "UserEventInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + } + } + }, + "ImportCompletionDataRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "CompletionDataInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 3 + } + } + }, + "ProductInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "productInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "productInlineSource": { + "type": "ProductInlineSource", + "id": 1 + }, + "gcsSource": { + "type": "GcsSource", + "id": 2 + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3 + } + } + }, + "UserEventInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "userEventInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "userEventInlineSource": { + "type": "UserEventInlineSource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsSource": { + "type": "GcsSource", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CompletionDataInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "bigQuerySource" + ] + } + }, + "fields": { + "bigQuerySource": { + "type": "BigQuerySource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "successCount": { + "type": "int64", + "id": 3 + }, + "failureCount": { + "type": "int64", + "id": 4 + }, + "requestId": { + "type": "string", + "id": 5, + "options": { + "deprecated": true + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 6 + } + } + }, + "ImportProductsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + } + } + }, + "ImportUserEventsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + }, + "importSummary": { + "type": "UserEventImportSummary", + "id": 3 + } + } + }, + "UserEventImportSummary": { + "fields": { + "joinedEventsCount": { + "type": "int64", + "id": 1 + }, + "unjoinedEventsCount": { + "type": "int64", + "id": 2 + } + } + }, + "ImportCompletionDataResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + } + } + }, + "Product": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Product", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }, + "oneofs": { + "expiration": { + "oneof": [ + "expireTime", + "ttl" + ] + } + }, + "fields": { + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 16 + }, + "ttl": { + "type": "google.protobuf.Duration", + "id": 17, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "id": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "type": { + "type": "Type", + "id": 3, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "primaryProductId": { + "type": "string", + "id": 4 + }, + "collectionMemberIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "gtin": { + "type": "string", + "id": 6 + }, + "categories": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "title": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "brands": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "description": { + "type": "string", + "id": 10 + }, + "languageCode": { + "type": "string", + "id": 11 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 12 + }, + "tags": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 14 + }, + "rating": { + "type": "Rating", + "id": 15 + }, + "availableTime": { + "type": "google.protobuf.Timestamp", + "id": 18 + }, + "availability": { + "type": "Availability", + "id": 19 + }, + "availableQuantity": { + "type": "google.protobuf.Int32Value", + "id": 20 + }, + "fulfillmentInfo": { + "rule": "repeated", + "type": "FulfillmentInfo", + "id": 21 + }, + "uri": { + "type": "string", + "id": 22 + }, + "images": { + "rule": "repeated", + "type": "Image", + "id": 23 + }, + "audience": { + "type": "Audience", + "id": 24 + }, + "colorInfo": { + "type": "ColorInfo", + "id": 25 + }, + "sizes": { + "rule": "repeated", + "type": "string", + "id": 26 + }, + "materials": { + "rule": "repeated", + "type": "string", + "id": 27 + }, + "patterns": { + "rule": "repeated", + "type": "string", + "id": 28 + }, + "conditions": { + "rule": "repeated", + "type": "string", + "id": 29 + }, + "promotions": { + "rule": "repeated", + "type": "Promotion", + "id": 34 + }, + "publishTime": { + "type": "google.protobuf.Timestamp", + "id": 33 + }, + "retrievableFields": { + "type": "google.protobuf.FieldMask", + "id": 30 + }, + "variants": { + "rule": "repeated", + "type": "Product", + "id": 31, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "localInventories": { + "rule": "repeated", + "type": "LocalInventory", + "id": 35, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "PRIMARY": 1, + "VARIANT": 2, + "COLLECTION": 3 + } + }, + "Availability": { + "values": { + "AVAILABILITY_UNSPECIFIED": 0, + "IN_STOCK": 1, + "OUT_OF_STOCK": 2, + "PREORDER": 3, + "BACKORDER": 4 + } + } + } + }, + "Promotion": { + "fields": { + "promotionId": { + "type": "string", + "id": 1 + } + } + }, + "UserEvent": { + "fields": { + "eventType": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "sessionId": { + "type": "string", + "id": 21 + }, + "eventTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "experimentIds": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "productDetails": { + "rule": "repeated", + "type": "ProductDetail", + "id": 6 + }, + "completionDetail": { + "type": "CompletionDetail", + "id": 22 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 7 + }, + "cartId": { + "type": "string", + "id": 8 + }, + "purchaseTransaction": { + "type": "PurchaseTransaction", + "id": 9 + }, + "searchQuery": { + "type": "string", + "id": 10 + }, + "filter": { + "type": "string", + "id": 16 + }, + "orderBy": { + "type": "string", + "id": 17 + }, + "offset": { + "type": "int32", + "id": 18 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 11 + }, + "userInfo": { + "type": "UserInfo", + "id": 12 + }, + "uri": { + "type": "string", + "id": 13 + }, + "referrerUri": { + "type": "string", + "id": 14 + }, + "pageViewId": { + "type": "string", + "id": 15 + } + } + }, + "ProductDetail": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "quantity": { + "type": "google.protobuf.Int32Value", + "id": 2 + } + } + }, + "CompletionDetail": { + "fields": { + "completionAttributionToken": { + "type": "string", + "id": 1 + }, + "selectedSuggestion": { + "type": "string", + "id": 2 + }, + "selectedPosition": { + "type": "int32", + "id": 3 + } + } + }, + "PurchaseTransaction": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "revenue": { + "type": "float", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tax": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "currencyCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CatalogService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "ListCatalogs": { + "requestType": "ListCatalogsRequest", + "responseType": "ListCatalogsResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*}/catalogs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*}/catalogs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateCatalog": { + "requestType": "UpdateCatalogRequest", + "responseType": "Catalog", + "options": { + "(google.api.http).patch": "/v2/{catalog.name=projects/*/locations/*/catalogs/*}", + "(google.api.http).body": "catalog", + "(google.api.method_signature)": "catalog,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{catalog.name=projects/*/locations/*/catalogs/*}", + "body": "catalog" + } + }, + { + "(google.api.method_signature)": "catalog,update_mask" + } + ] + }, + "SetDefaultBranch": { + "requestType": "SetDefaultBranchRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "(google.api.http).body": "*", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "body": "*" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetDefaultBranch": { + "requestType": "GetDefaultBranchRequest", + "responseType": "GetDefaultBranchResponse", + "options": { + "(google.api.http).get": "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetCompletionConfig": { + "requestType": "GetCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/catalogs/*/completionConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateCompletionConfig": { + "requestType": "UpdateCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).patch": "/v2/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.http).body": "completion_config", + "(google.api.method_signature)": "completion_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "body": "completion_config" + } + }, + { + "(google.api.method_signature)": "completion_config,update_mask" + } + ] + }, + "GetAttributesConfig": { + "requestType": "GetAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateAttributesConfig": { + "requestType": "UpdateAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).patch": "/v2/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.http).body": "attributes_config", + "(google.api.method_signature)": "attributes_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "body": "attributes_config" + } + }, + { + "(google.api.method_signature)": "attributes_config,update_mask" + } + ] + }, + "AddCatalogAttribute": { + "requestType": "AddCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "body": "*" + } + } + ] + }, + "RemoveCatalogAttribute": { + "requestType": "RemoveCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "body": "*" + } + } + ] + }, + "ReplaceCatalogAttribute": { + "requestType": "ReplaceCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "body": "*" + } + } + ] + } + } + }, + "ListCatalogsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListCatalogsResponse": { + "fields": { + "catalogs": { + "rule": "repeated", + "type": "Catalog", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "UpdateCatalogRequest": { + "fields": { + "catalog": { + "type": "Catalog", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "SetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "branchId": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "note": { + "type": "string", + "id": 3 + }, + "force": { + "type": "bool", + "id": 4 + } + } + }, + "GetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + } + } + }, + "GetDefaultBranchResponse": { + "fields": { + "branch": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "note": { + "type": "string", + "id": 3 + } + } + }, + "GetCompletionConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/CompletionConfig" + } + } + } + }, + "UpdateCompletionConfigRequest": { + "fields": { + "completionConfig": { + "type": "CompletionConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "GetAttributesConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + } + } + }, + "UpdateAttributesConfigRequest": { + "fields": { + "attributesConfig": { + "type": "AttributesConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "AddCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "key": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ReplaceCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 3 + } + } + }, + "CompletionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CompleteQuery": { + "requestType": "CompleteQueryRequest", + "responseType": "CompleteQueryResponse", + "options": { + "(google.api.http).get": "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + } + } + ] + }, + "ImportCompletionData": { + "requestType": "ImportCompletionDataRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.ImportCompletionDataResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.ImportCompletionDataResponse", + "metadata_type": "google.cloud.retail.v2.ImportMetadata" + } + } + ] + } + } + }, + "CompleteQueryRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "query": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 7 + }, + "languageCodes": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "deviceType": { + "type": "string", + "id": 4 + }, + "dataset": { + "type": "string", + "id": 6 + }, + "maxSuggestions": { + "type": "int32", + "id": 5 + } + } + }, + "CompleteQueryResponse": { + "fields": { + "completionResults": { + "rule": "repeated", + "type": "CompletionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "recentSearchResults": { + "rule": "repeated", + "type": "RecentSearchResult", + "id": 3 + } + }, + "nested": { + "CompletionResult": { + "fields": { + "suggestion": { + "type": "string", + "id": 1 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 2 + } + } + }, + "RecentSearchResult": { + "fields": { + "recentSearch": { + "type": "string", + "id": 1 + } + } + } + } + }, + "Control": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Control", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }, + "oneofs": { + "control": { + "oneof": [ + "rule" + ] + } + }, + "fields": { + "rule": { + "type": "Rule", + "id": 4 + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "associatedServingConfigIds": { + "rule": "repeated", + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 6, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "searchSolutionUseCase": { + "rule": "repeated", + "type": "SearchSolutionUseCase", + "id": 7 + } + } + }, + "ControlService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateControl": { + "requestType": "CreateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.http).body": "control", + "(google.api.method_signature)": "parent,control,control_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/controls", + "body": "control" + } + }, + { + "(google.api.method_signature)": "parent,control,control_id" + } + ] + }, + "DeleteControl": { + "requestType": "DeleteControlRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateControl": { + "requestType": "UpdateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).patch": "/v2/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.http).body": "control", + "(google.api.method_signature)": "control,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "body": "control" + } + }, + { + "(google.api.method_signature)": "control,update_mask" + } + ] + }, + "GetControl": { + "requestType": "GetControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListControls": { + "requestType": "ListControlsRequest", + "responseType": "ListControlsResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*/catalogs/*}/controls" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + } + } + }, + "CreateControlRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "control": { + "type": "Control", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "controlId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateControlRequest": { + "fields": { + "control": { + "type": "Control", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "GetControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "ListControlsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "filter": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListControlsResponse": { + "fields": { + "controls": { + "rule": "repeated", + "type": "Control", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "PredictionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Predict": { + "requestType": "PredictRequest", + "responseType": "PredictResponse", + "options": { + "(google.api.http).post": "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "body": "*", + "additional_bindings": { + "post": "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "body": "*" + } + } + } + ] + } + } + }, + "PredictRequest": { + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4, + "options": { + "deprecated": true + } + }, + "filter": { + "type": "string", + "id": 5 + }, + "validateOnly": { + "type": "bool", + "id": 6 + }, + "params": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 7 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 8 + } + } + }, + "PredictResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "PredictionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "missingIds": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "PredictionResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "metadata": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 2 + } + } + } + } + }, + "ProductService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateProduct": { + "requestType": "CreateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.http).body": "product", + "(google.api.method_signature)": "parent,product,product_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "body": "product" + } + }, + { + "(google.api.method_signature)": "parent,product,product_id" + } + ] + }, + "GetProduct": { + "requestType": "GetProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListProducts": { + "requestType": "ListProductsRequest", + "responseType": "ListProductsResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateProduct": { + "requestType": "UpdateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).patch": "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.http).body": "product", + "(google.api.method_signature)": "product,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "body": "product" + } + }, + { + "(google.api.method_signature)": "product,update_mask" + } + ] + }, + "DeleteProduct": { + "requestType": "DeleteProductRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ImportProducts": { + "requestType": "ImportProductsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.ImportProductsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.ImportProductsResponse", + "metadata_type": "google.cloud.retail.v2.ImportMetadata" + } + } + ] + }, + "SetInventory": { + "requestType": "SetInventoryRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "(google.api.http).body": "*", + "(google.api.method_signature)": "inventory,set_mask", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.SetInventoryResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.SetInventoryMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "body": "*" + } + }, + { + "(google.api.method_signature)": "inventory,set_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.SetInventoryResponse", + "metadata_type": "google.cloud.retail.v2.SetInventoryMetadata" + } + } + ] + }, + "AddFulfillmentPlaces": { + "requestType": "AddFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.AddFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.AddFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2.AddFulfillmentPlacesMetadata" + } + } + ] + }, + "RemoveFulfillmentPlaces": { + "requestType": "RemoveFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.RemoveFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata" + } + } + ] + }, + "AddLocalInventories": { + "requestType": "AddLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.AddLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.AddLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.AddLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2.AddLocalInventoriesMetadata" + } + } + ] + }, + "RemoveLocalInventories": { + "requestType": "RemoveLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.RemoveLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.RemoveLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2.RemoveLocalInventoriesMetadata" + } + } + ] + } + } + }, + "CreateProductRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "product": { + "type": "Product", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "productId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "UpdateProductRequest": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "DeleteProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "ListProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "filter": { + "type": "string", + "id": 4 + }, + "readMask": { + "type": "google.protobuf.FieldMask", + "id": 5 + } + } + }, + "ListProductsResponse": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "SetInventoryRequest": { + "fields": { + "inventory": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "setMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "allowMissing": { + "type": "bool", + "id": 4 + } + } + }, + "SetInventoryMetadata": { + "fields": {} + }, + "SetInventoryResponse": { + "fields": {} + }, + "AddFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "AddFulfillmentPlacesMetadata": { + "fields": {} + }, + "AddFulfillmentPlacesResponse": { + "fields": {} + }, + "AddLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "localInventories": { + "rule": "repeated", + "type": "LocalInventory", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 6 + } + } + }, + "AddLocalInventoriesMetadata": { + "fields": {} + }, + "AddLocalInventoriesResponse": { + "fields": {} + }, + "RemoveLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "RemoveLocalInventoriesMetadata": { + "fields": {} + }, + "RemoveLocalInventoriesResponse": { + "fields": {} + }, + "RemoveFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "RemoveFulfillmentPlacesMetadata": { + "fields": {} + }, + "RemoveFulfillmentPlacesResponse": { + "fields": {} + }, + "PurgeMetadata": { + "fields": {} + }, + "PurgeUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "filter": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "force": { + "type": "bool", + "id": 3 + } + } + }, + "PurgeUserEventsResponse": { + "fields": { + "purgedEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "SearchService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Search": { + "requestType": "SearchRequest", + "responseType": "SearchResponse", + "options": { + "(google.api.http).post": "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "body": "*", + "additional_bindings": { + "post": "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "body": "*" + } + } + } + ] + } + } + }, + "SearchRequest": { + "oneofs": { + "_spellCorrectionSpec": { + "oneof": [ + "spellCorrectionSpec" + ] + } + }, + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "branch": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "query": { + "type": "string", + "id": 3 + }, + "visitorId": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userInfo": { + "type": "UserInfo", + "id": 5 + }, + "pageSize": { + "type": "int32", + "id": 7 + }, + "pageToken": { + "type": "string", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 9 + }, + "filter": { + "type": "string", + "id": 10 + }, + "canonicalFilter": { + "type": "string", + "id": 28 + }, + "orderBy": { + "type": "string", + "id": 11 + }, + "facetSpecs": { + "rule": "repeated", + "type": "FacetSpec", + "id": 12 + }, + "dynamicFacetSpec": { + "type": "DynamicFacetSpec", + "id": 21, + "options": { + "deprecated": true + } + }, + "boostSpec": { + "type": "BoostSpec", + "id": 13 + }, + "queryExpansionSpec": { + "type": "QueryExpansionSpec", + "id": 14 + }, + "variantRollupKeys": { + "rule": "repeated", + "type": "string", + "id": 17 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 23 + }, + "searchMode": { + "type": "SearchMode", + "id": 31 + }, + "personalizationSpec": { + "type": "PersonalizationSpec", + "id": 32 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 34 + }, + "spellCorrectionSpec": { + "type": "SpellCorrectionSpec", + "id": 35, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "FacetSpec": { + "fields": { + "facetKey": { + "type": "FacetKey", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "limit": { + "type": "int32", + "id": 2 + }, + "excludedFilterKeys": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "enableDynamicPosition": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "FacetKey": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "intervals": { + "rule": "repeated", + "type": "Interval", + "id": 2 + }, + "restrictedValues": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "prefixes": { + "rule": "repeated", + "type": "string", + "id": 8 + }, + "contains": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "caseInsensitive": { + "type": "bool", + "id": 10 + }, + "orderBy": { + "type": "string", + "id": 4 + }, + "query": { + "type": "string", + "id": 5 + }, + "returnMinMax": { + "type": "bool", + "id": 11 + } + } + } + } + }, + "DynamicFacetSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "DISABLED": 1, + "ENABLED": 2 + } + } + } + }, + "BoostSpec": { + "oneofs": { + "_skipBoostSpecValidation": { + "oneof": [ + "skipBoostSpecValidation" + ] + } + }, + "fields": { + "conditionBoostSpecs": { + "rule": "repeated", + "type": "ConditionBoostSpec", + "id": 1 + }, + "skipBoostSpecValidation": { + "type": "bool", + "id": 2, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "ConditionBoostSpec": { + "fields": { + "condition": { + "type": "string", + "id": 1 + }, + "boost": { + "type": "float", + "id": 2 + } + } + } + } + }, + "QueryExpansionSpec": { + "fields": { + "condition": { + "type": "Condition", + "id": 1 + }, + "pinUnexpandedResults": { + "type": "bool", + "id": 2 + } + }, + "nested": { + "Condition": { + "values": { + "CONDITION_UNSPECIFIED": 0, + "DISABLED": 1, + "AUTO": 3 + } + } + } + }, + "PersonalizationSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "AUTO": 1, + "DISABLED": 2 + } + } + } + }, + "SpellCorrectionSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "SUGGESTION_ONLY": 1, + "AUTO": 2 + } + } + } + }, + "SearchMode": { + "values": { + "SEARCH_MODE_UNSPECIFIED": 0, + "PRODUCT_SEARCH_ONLY": 1, + "FACETED_SEARCH_ONLY": 2 + } + } + } + }, + "SearchResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "SearchResult", + "id": 1 + }, + "facets": { + "rule": "repeated", + "type": "Facet", + "id": 2 + }, + "totalSize": { + "type": "int32", + "id": 3 + }, + "correctedQuery": { + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "nextPageToken": { + "type": "string", + "id": 6 + }, + "queryExpansionInfo": { + "type": "QueryExpansionInfo", + "id": 7 + }, + "redirectUri": { + "type": "string", + "id": 10 + }, + "appliedControls": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "invalidConditionBoostSpecs": { + "rule": "repeated", + "type": "SearchRequest.BoostSpec.ConditionBoostSpec", + "id": 14 + } + }, + "nested": { + "SearchResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "product": { + "type": "Product", + "id": 2 + }, + "matchingVariantCount": { + "type": "int32", + "id": 3 + }, + "matchingVariantFields": { + "keyType": "string", + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "variantRollupValues": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 5 + }, + "personalLabels": { + "rule": "repeated", + "type": "string", + "id": 7 + } + } + }, + "Facet": { + "fields": { + "key": { + "type": "string", + "id": 1 + }, + "values": { + "rule": "repeated", + "type": "FacetValue", + "id": 2 + }, + "dynamicFacet": { + "type": "bool", + "id": 3 + } + }, + "nested": { + "FacetValue": { + "oneofs": { + "facetValue": { + "oneof": [ + "value", + "interval" + ] + } + }, + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "interval": { + "type": "Interval", + "id": 2 + }, + "count": { + "type": "int64", + "id": 3 + }, + "minValue": { + "type": "double", + "id": 5 + }, + "maxValue": { + "type": "double", + "id": 6 + } + } + } + } + }, + "QueryExpansionInfo": { + "fields": { + "expandedQuery": { + "type": "bool", + "id": 1 + }, + "pinnedResultCount": { + "type": "int64", + "id": 2 + } + } + } + } + }, + "ServingConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/ServingConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "modelId": { + "type": "string", + "id": 3 + }, + "priceRerankingLevel": { + "type": "string", + "id": 4 + }, + "facetControlIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "dynamicFacetSpec": { + "type": "SearchRequest.DynamicFacetSpec", + "id": 6 + }, + "boostControlIds": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "filterControlIds": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "redirectControlIds": { + "rule": "repeated", + "type": "string", + "id": 10 + }, + "twowaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 18 + }, + "onewaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "doNotAssociateControlIds": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "replacementControlIds": { + "rule": "repeated", + "type": "string", + "id": 14 + }, + "ignoreControlIds": { + "rule": "repeated", + "type": "string", + "id": 15 + }, + "diversityLevel": { + "type": "string", + "id": 8 + }, + "enableCategoryFilterLevel": { + "type": "string", + "id": 16 + }, + "personalizationSpec": { + "type": "SearchRequest.PersonalizationSpec", + "id": 21 + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 19, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + } + } + }, + "ServingConfigService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateServingConfig": { + "requestType": "CreateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + } + ] + }, + "DeleteServingConfig": { + "requestType": "DeleteServingConfigRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateServingConfig": { + "requestType": "UpdateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).patch": "/v2/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "serving_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "serving_config,update_mask" + } + ] + }, + "GetServingConfig": { + "requestType": "GetServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).get": "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListServingConfigs": { + "requestType": "ListServingConfigsRequest", + "responseType": "ListServingConfigsResponse", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "AddControl": { + "requestType": "AddControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + }, + "RemoveControl": { + "requestType": "RemoveControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + } + } + }, + "CreateServingConfigRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "servingConfig": { + "type": "ServingConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "servingConfigId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateServingConfigRequest": { + "fields": { + "servingConfig": { + "type": "ServingConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "GetServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "ListServingConfigsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListServingConfigsResponse": { + "fields": { + "servingConfigs": { + "rule": "repeated", + "type": "ServingConfig", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "AddControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "WriteUserEvent": { + "requestType": "WriteUserEventRequest", + "responseType": "UserEvent", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "(google.api.http).body": "user_event" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "body": "user_event" + } + } + ] + }, + "CollectUserEvent": { + "requestType": "CollectUserEventRequest", + "responseType": "google.api.HttpBody", + "options": { + "(google.api.http).get": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + } + } + ] + }, + "PurgeUserEvents": { + "requestType": "PurgeUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.PurgeUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.PurgeMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.PurgeUserEventsResponse", + "metadata_type": "google.cloud.retail.v2.PurgeMetadata" + } + } + ] + }, + "ImportUserEvents": { + "requestType": "ImportUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2.ImportUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2.ImportUserEventsResponse", + "metadata_type": "google.cloud.retail.v2.ImportMetadata" + } + } + ] + }, + "RejoinUserEvents": { + "requestType": "RejoinUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "RejoinUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "RejoinUserEventsMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "RejoinUserEventsResponse", + "metadata_type": "RejoinUserEventsMetadata" + } + } + ] + } + } + }, + "WriteUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CollectUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "uri": { + "type": "string", + "id": 3 + }, + "ets": { + "type": "int64", + "id": 4 + } + } + }, + "RejoinUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEventRejoinScope": { + "type": "UserEventRejoinScope", + "id": 2 + } + }, + "nested": { + "UserEventRejoinScope": { + "values": { + "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": 0, + "JOINED_EVENTS": 1, + "UNJOINED_EVENTS": 2 + } + } + } + }, + "RejoinUserEventsResponse": { + "fields": { + "rejoinedUserEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "RejoinUserEventsMetadata": { + "fields": {} + } + } + }, + "v2alpha": { + "options": { + "csharp_namespace": "Google.Cloud.Retail.V2Alpha", + "go_package": "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail", + "java_multiple_files": true, + "java_outer_classname": "UserEventServiceProto", + "java_package": "com.google.cloud.retail.v2alpha", + "objc_class_prefix": "RETAIL", + "php_namespace": "Google\\Cloud\\Retail\\V2alpha", + "ruby_package": "Google::Cloud::Retail::V2alpha", + "(google.api.resource_definition).type": "retail.googleapis.com/Branch", + "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" + }, + "nested": { + "ProductLevelConfig": { + "fields": { + "ingestionProductType": { + "type": "string", + "id": 1 + }, + "merchantCenterProductIdField": { + "type": "string", + "id": 2 + } + } + }, + "CatalogAttribute": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "inUse": { + "type": "bool", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "type": { + "type": "AttributeType", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "indexableOption": { + "type": "IndexableOption", + "id": 5 + }, + "dynamicFacetableOption": { + "type": "DynamicFacetableOption", + "id": 6 + }, + "searchableOption": { + "type": "SearchableOption", + "id": 7 + }, + "recommendationsFilteringOption": { + "type": "RecommendationsFilteringOption", + "id": 8 + } + }, + "nested": { + "AttributeType": { + "values": { + "UNKNOWN": 0, + "TEXTUAL": 1, + "NUMERICAL": 2 + } + }, + "IndexableOption": { + "values": { + "INDEXABLE_OPTION_UNSPECIFIED": 0, + "INDEXABLE_ENABLED": 1, + "INDEXABLE_DISABLED": 2 + } + }, + "DynamicFacetableOption": { + "values": { + "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": 0, + "DYNAMIC_FACETABLE_ENABLED": 1, + "DYNAMIC_FACETABLE_DISABLED": 2 + } + }, + "SearchableOption": { + "values": { + "SEARCHABLE_OPTION_UNSPECIFIED": 0, + "SEARCHABLE_ENABLED": 1, + "SEARCHABLE_DISABLED": 2 + } + } + } + }, + "AttributesConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/AttributesConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "catalogAttributes": { + "keyType": "string", + "type": "CatalogAttribute", + "id": 2 + }, + "attributeConfigLevel": { + "type": "AttributeConfigLevel", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "CompletionConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/CompletionConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "matchingOrder": { + "type": "string", + "id": 2 + }, + "maxSuggestions": { + "type": "int32", + "id": 3 + }, + "minPrefixLength": { + "type": "int32", + "id": 4 + }, + "autoLearning": { + "type": "bool", + "id": 11 + }, + "suggestionsInputConfig": { + "type": "CompletionDataInputConfig", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastSuggestionsImportOperation": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "denylistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastDenylistImportOperation": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "allowlistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastAllowlistImportOperation": { + "type": "string", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "MerchantCenterLink": { + "fields": { + "merchantCenterAccountId": { + "type": "int64", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "branchId": { + "type": "string", + "id": 2 + }, + "destinations": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "regionCode": { + "type": "string", + "id": 4 + }, + "languageCode": { + "type": "string", + "id": 5 + } + } + }, + "MerchantCenterLinkingConfig": { + "fields": { + "links": { + "rule": "repeated", + "type": "MerchantCenterLink", + "id": 1 + } + } + }, + "Catalog": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Catalog", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "productLevelConfig": { + "type": "ProductLevelConfig", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "merchantCenterLinkingConfig": { + "type": "MerchantCenterLinkingConfig", + "id": 6 + } + } + }, + "AttributeConfigLevel": { + "values": { + "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": 0, + "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": 1, + "CATALOG_LEVEL_ATTRIBUTE_CONFIG": 2 + } + }, + "SolutionType": { + "values": { + "SOLUTION_TYPE_UNSPECIFIED": 0, + "SOLUTION_TYPE_RECOMMENDATION": 1, + "SOLUTION_TYPE_SEARCH": 2 + } + }, + "RecommendationsFilteringOption": { + "values": { + "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": 0, + "RECOMMENDATIONS_FILTERING_DISABLED": 1, + "RECOMMENDATIONS_FILTERING_ENABLED": 3 + } + }, + "SearchSolutionUseCase": { + "values": { + "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": 0, + "SEARCH_SOLUTION_USE_CASE_SEARCH": 1, + "SEARCH_SOLUTION_USE_CASE_BROWSE": 2 + } + }, + "Condition": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "QueryTerm", + "id": 1 + }, + "activeTimeRange": { + "rule": "repeated", + "type": "TimeRange", + "id": 3 + } + }, + "nested": { + "QueryTerm": { + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "fullMatch": { + "type": "bool", + "id": 2 + } + } + }, + "TimeRange": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + } + } + }, + "Rule": { + "oneofs": { + "action": { + "oneof": [ + "boostAction", + "redirectAction", + "onewaySynonymsAction", + "doNotAssociateAction", + "replacementAction", + "ignoreAction", + "filterAction", + "twowaySynonymsAction" + ] + } + }, + "fields": { + "boostAction": { + "type": "BoostAction", + "id": 2 + }, + "redirectAction": { + "type": "RedirectAction", + "id": 3 + }, + "onewaySynonymsAction": { + "type": "OnewaySynonymsAction", + "id": 6 + }, + "doNotAssociateAction": { + "type": "DoNotAssociateAction", + "id": 7 + }, + "replacementAction": { + "type": "ReplacementAction", + "id": 8 + }, + "ignoreAction": { + "type": "IgnoreAction", + "id": 9 + }, + "filterAction": { + "type": "FilterAction", + "id": 10 + }, + "twowaySynonymsAction": { + "type": "TwowaySynonymsAction", + "id": 11 + }, + "condition": { + "type": "Condition", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + }, + "nested": { + "BoostAction": { + "fields": { + "boost": { + "type": "float", + "id": 1 + }, + "productsFilter": { + "type": "string", + "id": 2 + } + } + }, + "FilterAction": { + "fields": { + "filter": { + "type": "string", + "id": 1 + } + } + }, + "RedirectAction": { + "fields": { + "redirectUri": { + "type": "string", + "id": 1 + } + } + }, + "TwowaySynonymsAction": { + "fields": { + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "OnewaySynonymsAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "onewayTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "DoNotAssociateAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "doNotAssociateTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "terms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "ReplacementAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "replacementTerm": { + "type": "string", + "id": 3 + }, + "term": { + "type": "string", + "id": 1 + } + } + }, + "IgnoreAction": { + "fields": { + "ignoreTerms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + } + } + }, + "Audience": { + "fields": { + "genders": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "ageGroups": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "ColorInfo": { + "fields": { + "colorFamilies": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "colors": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "CustomAttribute": { + "oneofs": { + "_searchable": { + "oneof": [ + "searchable" + ] + }, + "_indexable": { + "oneof": [ + "indexable" + ] + } + }, + "fields": { + "text": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "numbers": { + "rule": "repeated", + "type": "double", + "id": 2 + }, + "searchable": { + "type": "bool", + "id": 3, + "options": { + "deprecated": true, + "proto3_optional": true + } + }, + "indexable": { + "type": "bool", + "id": 4, + "options": { + "deprecated": true, + "proto3_optional": true + } + } + } + }, + "FulfillmentInfo": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "Image": { + "fields": { + "uri": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "height": { + "type": "int32", + "id": 2 + }, + "width": { + "type": "int32", + "id": 3 + } + } + }, + "Interval": { + "oneofs": { + "min": { + "oneof": [ + "minimum", + "exclusiveMinimum" + ] + }, + "max": { + "oneof": [ + "maximum", + "exclusiveMaximum" + ] + } + }, + "fields": { + "minimum": { + "type": "double", + "id": 1 + }, + "exclusiveMinimum": { + "type": "double", + "id": 2 + }, + "maximum": { + "type": "double", + "id": 3 + }, + "exclusiveMaximum": { + "type": "double", + "id": 4 + } + } + }, + "PriceInfo": { + "fields": { + "currencyCode": { + "type": "string", + "id": 1 + }, + "price": { + "type": "float", + "id": 2 + }, + "originalPrice": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "priceEffectiveTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "priceExpireTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + }, + "priceRange": { + "type": "PriceRange", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "PriceRange": { + "fields": { + "price": { + "type": "Interval", + "id": 1 + }, + "originalPrice": { + "type": "Interval", + "id": 2 + } + } + } + } + }, + "Rating": { + "fields": { + "ratingCount": { + "type": "int32", + "id": 1 + }, + "averageRating": { + "type": "float", + "id": 2 + }, + "ratingHistogram": { + "rule": "repeated", + "type": "int32", + "id": 3 + } + } + }, + "UserInfo": { + "fields": { + "userId": { + "type": "string", + "id": 1 + }, + "ipAddress": { + "type": "string", + "id": 2 + }, + "userAgent": { + "type": "string", + "id": 3 + }, + "directUserRequest": { + "type": "bool", + "id": 4 + } + } + }, + "LocalInventory": { + "fields": { + "placeId": { + "type": "string", + "id": 1 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 2 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 3 + }, + "fulfillmentTypes": { + "rule": "repeated", + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + } + } + }, + "GcsSource": { + "fields": { + "inputUris": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "dataSchema": { + "type": "string", + "id": 2 + } + } + }, + "BigQuerySource": { + "oneofs": { + "partition": { + "oneof": [ + "partitionDate" + ] + } + }, + "fields": { + "partitionDate": { + "type": "google.type.Date", + "id": 6 + }, + "projectId": { + "type": "string", + "id": 5 + }, + "datasetId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tableId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsStagingDir": { + "type": "string", + "id": 3 + }, + "dataSchema": { + "type": "string", + "id": 4 + } + } + }, + "ProductInlineSource": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventInlineSource": { + "fields": { + "userEvents": { + "rule": "repeated", + "type": "UserEvent", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportErrorsConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsPrefix" + ] + } + }, + "fields": { + "gcsPrefix": { + "type": "string", + "id": 1 + } + } + }, + "ImportProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "requestId": { + "type": "string", + "id": 6, + "options": { + "deprecated": true + } + }, + "inputConfig": { + "type": "ProductInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "reconciliationMode": { + "type": "ReconciliationMode", + "id": 5 + }, + "notificationPubsubTopic": { + "type": "string", + "id": 7 + }, + "skipDefaultBranchProtection": { + "type": "bool", + "id": 8 + } + }, + "nested": { + "ReconciliationMode": { + "values": { + "RECONCILIATION_MODE_UNSPECIFIED": 0, + "INCREMENTAL": 1, + "FULL": 2 + } + } + } + }, + "ImportUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "UserEventInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + } + } + }, + "ImportCompletionDataRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "CompletionDataInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 3 + } + } + }, + "ProductInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "productInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "productInlineSource": { + "type": "ProductInlineSource", + "id": 1 + }, + "gcsSource": { + "type": "GcsSource", + "id": 2 + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3 + } + } + }, + "UserEventInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "userEventInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "userEventInlineSource": { + "type": "UserEventInlineSource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsSource": { + "type": "GcsSource", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CompletionDataInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "bigQuerySource" + ] + } + }, + "fields": { + "bigQuerySource": { + "type": "BigQuerySource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "successCount": { + "type": "int64", + "id": 3 + }, + "failureCount": { + "type": "int64", + "id": 4 + }, + "requestId": { + "type": "string", + "id": 5, + "options": { + "deprecated": true + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 6 + } + } + }, + "ImportProductsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + } + } + }, + "ImportUserEventsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + }, + "importSummary": { + "type": "UserEventImportSummary", + "id": 3 + } + } + }, + "UserEventImportSummary": { + "fields": { + "joinedEventsCount": { + "type": "int64", + "id": 1 + }, + "unjoinedEventsCount": { + "type": "int64", + "id": 2 + } + } + }, + "ImportCompletionDataResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + } + } + }, + "Product": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Product", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }, + "oneofs": { + "expiration": { + "oneof": [ + "expireTime", + "ttl" + ] + } + }, + "fields": { + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 16 + }, + "ttl": { + "type": "google.protobuf.Duration", + "id": 17, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "id": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "type": { + "type": "Type", + "id": 3, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "primaryProductId": { + "type": "string", + "id": 4 + }, + "collectionMemberIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "gtin": { + "type": "string", + "id": 6 + }, + "categories": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "title": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "brands": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "description": { + "type": "string", + "id": 10 + }, + "languageCode": { + "type": "string", + "id": 11 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 12 + }, + "tags": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 14 + }, + "rating": { + "type": "Rating", + "id": 15 + }, + "availableTime": { + "type": "google.protobuf.Timestamp", + "id": 18 + }, + "availability": { + "type": "Availability", + "id": 19 + }, + "availableQuantity": { + "type": "google.protobuf.Int32Value", + "id": 20 + }, + "fulfillmentInfo": { + "rule": "repeated", + "type": "FulfillmentInfo", + "id": 21 + }, + "uri": { + "type": "string", + "id": 22 + }, + "images": { + "rule": "repeated", + "type": "Image", + "id": 23 + }, + "audience": { + "type": "Audience", + "id": 24 + }, + "colorInfo": { + "type": "ColorInfo", + "id": 25 + }, + "sizes": { + "rule": "repeated", + "type": "string", + "id": 26 + }, + "materials": { + "rule": "repeated", + "type": "string", + "id": 27 + }, + "patterns": { + "rule": "repeated", + "type": "string", + "id": 28 + }, + "conditions": { + "rule": "repeated", + "type": "string", + "id": 29 + }, + "promotions": { + "rule": "repeated", + "type": "Promotion", + "id": 34 + }, + "publishTime": { + "type": "google.protobuf.Timestamp", + "id": 33 + }, + "retrievableFields": { + "type": "google.protobuf.FieldMask", + "id": 30 + }, + "variants": { + "rule": "repeated", + "type": "Product", + "id": 31, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "PRIMARY": 1, + "VARIANT": 2, + "COLLECTION": 3 + } + }, + "Availability": { + "values": { + "AVAILABILITY_UNSPECIFIED": 0, + "IN_STOCK": 1, + "OUT_OF_STOCK": 2, + "PREORDER": 3, + "BACKORDER": 4 + } + } + } + }, + "Promotion": { + "fields": { + "promotionId": { + "type": "string", + "id": 1 + } + } + }, + "UserEvent": { + "fields": { + "eventType": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "sessionId": { + "type": "string", + "id": 21 + }, + "eventTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "experimentIds": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "productDetails": { + "rule": "repeated", + "type": "ProductDetail", + "id": 6 + }, + "completionDetail": { + "type": "CompletionDetail", + "id": 22 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 7 + }, + "cartId": { + "type": "string", + "id": 8 + }, + "purchaseTransaction": { + "type": "PurchaseTransaction", + "id": 9 + }, + "searchQuery": { + "type": "string", + "id": 10 + }, + "filter": { + "type": "string", + "id": 16 + }, + "orderBy": { + "type": "string", + "id": 17 + }, + "offset": { + "type": "int32", + "id": 18 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 11 + }, + "userInfo": { + "type": "UserInfo", + "id": 12 + }, + "uri": { + "type": "string", + "id": 13 + }, + "referrerUri": { + "type": "string", + "id": 14 + }, + "pageViewId": { + "type": "string", + "id": 15 + } + } + }, + "ProductDetail": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "quantity": { + "type": "google.protobuf.Int32Value", + "id": 2 + } + } + }, + "CompletionDetail": { + "fields": { + "completionAttributionToken": { + "type": "string", + "id": 1 + }, + "selectedSuggestion": { + "type": "string", + "id": 2 + }, + "selectedPosition": { + "type": "int32", + "id": 3 + } + } + }, + "PurchaseTransaction": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "revenue": { + "type": "float", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tax": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "currencyCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CatalogService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "ListCatalogs": { + "requestType": "ListCatalogsRequest", + "responseType": "ListCatalogsResponse", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*}/catalogs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*}/catalogs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateCatalog": { + "requestType": "UpdateCatalogRequest", + "responseType": "Catalog", + "options": { + "(google.api.http).patch": "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}", + "(google.api.http).body": "catalog", + "(google.api.method_signature)": "catalog,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}", + "body": "catalog" + } + }, + { + "(google.api.method_signature)": "catalog,update_mask" + } + ] + }, + "SetDefaultBranch": { + "requestType": "SetDefaultBranchRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "(google.api.http).body": "*", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "body": "*" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetDefaultBranch": { + "requestType": "GetDefaultBranchRequest", + "responseType": "GetDefaultBranchResponse", + "options": { + "(google.api.http).get": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetCompletionConfig": { + "requestType": "GetCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/completionConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateCompletionConfig": { + "requestType": "UpdateCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).patch": "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.http).body": "completion_config", + "(google.api.method_signature)": "completion_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "body": "completion_config" + } + }, + { + "(google.api.method_signature)": "completion_config,update_mask" + } + ] + }, + "GetAttributesConfig": { + "requestType": "GetAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateAttributesConfig": { + "requestType": "UpdateAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).patch": "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.http).body": "attributes_config", + "(google.api.method_signature)": "attributes_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "body": "attributes_config" + } + }, + { + "(google.api.method_signature)": "attributes_config,update_mask" + } + ] + }, + "AddCatalogAttribute": { + "requestType": "AddCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "body": "*" + } + } + ] + }, + "RemoveCatalogAttribute": { + "requestType": "RemoveCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "body": "*" + } + } + ] + }, + "ReplaceCatalogAttribute": { + "requestType": "ReplaceCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "body": "*" + } + } + ] + } + } + }, + "ListCatalogsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListCatalogsResponse": { + "fields": { + "catalogs": { + "rule": "repeated", + "type": "Catalog", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "UpdateCatalogRequest": { + "fields": { + "catalog": { + "type": "Catalog", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "SetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "branchId": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "note": { + "type": "string", + "id": 3 + }, + "force": { + "type": "bool", + "id": 4 + } + } + }, + "GetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + } + } + }, + "GetDefaultBranchResponse": { + "fields": { + "branch": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "note": { + "type": "string", + "id": 3 + } + } + }, + "GetCompletionConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/CompletionConfig" + } + } + } + }, + "UpdateCompletionConfigRequest": { + "fields": { + "completionConfig": { + "type": "CompletionConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "GetAttributesConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + } + } + }, + "UpdateAttributesConfigRequest": { + "fields": { + "attributesConfig": { + "type": "AttributesConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "AddCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "key": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ReplaceCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 3 + } + } + }, + "CompletionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CompleteQuery": { + "requestType": "CompleteQueryRequest", + "responseType": "CompleteQueryResponse", + "options": { + "(google.api.http).get": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + } + } + ] + }, + "ImportCompletionData": { + "requestType": "ImportCompletionDataRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.ImportCompletionDataResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.ImportCompletionDataResponse", + "metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + } + } + ] + } + } + }, + "CompleteQueryRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "query": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 7 + }, + "languageCodes": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "deviceType": { + "type": "string", + "id": 4 + }, + "dataset": { + "type": "string", + "id": 6 + }, + "maxSuggestions": { + "type": "int32", + "id": 5 + } + } + }, + "CompleteQueryResponse": { + "fields": { + "completionResults": { + "rule": "repeated", + "type": "CompletionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "recentSearchResults": { + "rule": "repeated", + "type": "RecentSearchResult", + "id": 3 + } + }, + "nested": { + "CompletionResult": { + "fields": { + "suggestion": { + "type": "string", + "id": 1 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 2 + } + } + }, + "RecentSearchResult": { + "fields": { + "recentSearch": { + "type": "string", + "id": 1 + } + } + } + } + }, + "Control": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Control", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }, + "oneofs": { + "control": { + "oneof": [ + "facetSpec", + "rule" + ] + } + }, + "fields": { + "facetSpec": { + "type": "SearchRequest.FacetSpec", + "id": 3 + }, + "rule": { + "type": "Rule", + "id": 4 + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "associatedServingConfigIds": { + "rule": "repeated", + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 6, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "searchSolutionUseCase": { + "rule": "repeated", + "type": "SearchSolutionUseCase", + "id": 7, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "SearchService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Search": { + "requestType": "SearchRequest", + "responseType": "SearchResponse", + "options": { + "(google.api.http).post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "body": "*", + "additional_bindings": { + "post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "body": "*" + } + } + } + ] + } + } + }, + "SearchRequest": { + "oneofs": { + "_spellCorrectionSpec": { + "oneof": [ + "spellCorrectionSpec" + ] + } + }, + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "branch": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "query": { + "type": "string", + "id": 3 + }, + "visitorId": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userInfo": { + "type": "UserInfo", + "id": 5 + }, + "pageSize": { + "type": "int32", + "id": 7 + }, + "pageToken": { + "type": "string", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 9 + }, + "filter": { + "type": "string", + "id": 10 + }, + "canonicalFilter": { + "type": "string", + "id": 28 + }, + "orderBy": { + "type": "string", + "id": 11 + }, + "facetSpecs": { + "rule": "repeated", + "type": "FacetSpec", + "id": 12 + }, + "dynamicFacetSpec": { + "type": "DynamicFacetSpec", + "id": 21, + "options": { + "deprecated": true + } + }, + "boostSpec": { + "type": "BoostSpec", + "id": 13 + }, + "queryExpansionSpec": { + "type": "QueryExpansionSpec", + "id": 14 + }, + "relevanceThreshold": { + "type": "RelevanceThreshold", + "id": 15 + }, + "variantRollupKeys": { + "rule": "repeated", + "type": "string", + "id": 17 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 23 + }, + "searchMode": { + "type": "SearchMode", + "id": 31 + }, + "personalizationSpec": { + "type": "PersonalizationSpec", + "id": 32 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 34 + }, + "spellCorrectionSpec": { + "type": "SpellCorrectionSpec", + "id": 35, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "FacetSpec": { + "fields": { + "facetKey": { + "type": "FacetKey", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "limit": { + "type": "int32", + "id": 2 + }, + "excludedFilterKeys": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "enableDynamicPosition": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "FacetKey": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "intervals": { + "rule": "repeated", + "type": "Interval", + "id": 2 + }, + "restrictedValues": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "prefixes": { + "rule": "repeated", + "type": "string", + "id": 8 + }, + "contains": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "caseInsensitive": { + "type": "bool", + "id": 10 + }, + "orderBy": { + "type": "string", + "id": 4 + }, + "query": { + "type": "string", + "id": 5 + }, + "returnMinMax": { + "type": "bool", + "id": 11 + } + } + } + } + }, + "DynamicFacetSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "DISABLED": 1, + "ENABLED": 2 + } + } + } + }, + "BoostSpec": { + "oneofs": { + "_skipBoostSpecValidation": { + "oneof": [ + "skipBoostSpecValidation" + ] + } + }, + "fields": { + "conditionBoostSpecs": { + "rule": "repeated", + "type": "ConditionBoostSpec", + "id": 1 + }, + "skipBoostSpecValidation": { + "type": "bool", + "id": 2, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "ConditionBoostSpec": { + "fields": { + "condition": { + "type": "string", + "id": 1 + }, + "boost": { + "type": "float", + "id": 2 + } + } + } + } + }, + "QueryExpansionSpec": { + "fields": { + "condition": { + "type": "Condition", + "id": 1 + }, + "pinUnexpandedResults": { + "type": "bool", + "id": 2 + } + }, + "nested": { + "Condition": { + "values": { + "CONDITION_UNSPECIFIED": 0, + "DISABLED": 1, + "AUTO": 3 + } + } + } + }, + "PersonalizationSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "AUTO": 1, + "DISABLED": 2 + } + } + } + }, + "SpellCorrectionSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "SUGGESTION_ONLY": 1, + "AUTO": 2 + } + } + } + }, + "RelevanceThreshold": { + "values": { + "RELEVANCE_THRESHOLD_UNSPECIFIED": 0, + "HIGH": 1, + "MEDIUM": 2, + "LOW": 3, + "LOWEST": 4 + } + }, + "SearchMode": { + "values": { + "SEARCH_MODE_UNSPECIFIED": 0, + "PRODUCT_SEARCH_ONLY": 1, + "FACETED_SEARCH_ONLY": 2 + } + } + } + }, + "SearchResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "SearchResult", + "id": 1 + }, + "facets": { + "rule": "repeated", + "type": "Facet", + "id": 2 + }, + "totalSize": { + "type": "int32", + "id": 3 + }, + "correctedQuery": { + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "nextPageToken": { + "type": "string", + "id": 6 + }, + "queryExpansionInfo": { + "type": "QueryExpansionInfo", + "id": 7 + }, + "redirectUri": { + "type": "string", + "id": 10 + }, + "appliedControls": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "invalidConditionBoostSpecs": { + "rule": "repeated", + "type": "SearchRequest.BoostSpec.ConditionBoostSpec", + "id": 14 + } + }, + "nested": { + "SearchResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "product": { + "type": "Product", + "id": 2 + }, + "matchingVariantCount": { + "type": "int32", + "id": 3 + }, + "matchingVariantFields": { + "keyType": "string", + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "variantRollupValues": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 5 + } + } + }, + "Facet": { + "fields": { + "key": { + "type": "string", + "id": 1 + }, + "values": { + "rule": "repeated", + "type": "FacetValue", + "id": 2 + }, + "dynamicFacet": { + "type": "bool", + "id": 3 + } + }, + "nested": { + "FacetValue": { + "oneofs": { + "facetValue": { + "oneof": [ + "value", + "interval" + ] + } + }, + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "interval": { + "type": "Interval", + "id": 2 + }, + "count": { + "type": "int64", + "id": 3 + }, + "minValue": { + "type": "double", + "id": 5 + }, + "maxValue": { + "type": "double", + "id": 6 + } + } + } + } + }, + "QueryExpansionInfo": { + "fields": { + "expandedQuery": { + "type": "bool", + "id": 1 + }, + "pinnedResultCount": { + "type": "int64", + "id": 2 + } + } + } + } + }, + "ControlService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateControl": { + "requestType": "CreateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.http).body": "control", + "(google.api.method_signature)": "parent,control,control_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + "body": "control" + } + }, + { + "(google.api.method_signature)": "parent,control,control_id" + } + ] + }, + "DeleteControl": { + "requestType": "DeleteControlRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateControl": { + "requestType": "UpdateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).patch": "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.http).body": "control", + "(google.api.method_signature)": "control,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "body": "control" + } + }, + { + "(google.api.method_signature)": "control,update_mask" + } + ] + }, + "GetControl": { + "requestType": "GetControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListControls": { + "requestType": "ListControlsRequest", + "responseType": "ListControlsResponse", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/controls" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + } + } + }, + "CreateControlRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "control": { + "type": "Control", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "controlId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateControlRequest": { + "fields": { + "control": { + "type": "Control", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "GetControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "ListControlsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "filter": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListControlsResponse": { + "fields": { + "controls": { + "rule": "repeated", + "type": "Control", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "ExportErrorsConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsPrefix" + ] + } + }, + "fields": { + "gcsPrefix": { + "type": "string", + "id": 1 + } + } + }, + "ExportMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "ExportProductsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ExportErrorsConfig", + "id": 2 + }, + "outputResult": { + "type": "OutputResult", + "id": 3 + } + } + }, + "ExportUserEventsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ExportErrorsConfig", + "id": 2 + }, + "outputResult": { + "type": "OutputResult", + "id": 3 + } + } + }, + "OutputResult": { + "fields": { + "bigqueryResult": { + "rule": "repeated", + "type": "BigQueryOutputResult", + "id": 1 + } + } + }, + "BigQueryOutputResult": { + "fields": { + "datasetId": { + "type": "string", + "id": 1 + }, + "tableId": { + "type": "string", + "id": 2 + } + } + }, + "Model": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Model", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }, + "oneofs": { + "trainingConfig": { + "oneof": [ + "pageOptimizationConfig" + ] + } + }, + "fields": { + "pageOptimizationConfig": { + "type": "PageOptimizationConfig", + "id": 17, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "trainingState": { + "type": "TrainingState", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "servingState": { + "type": "ServingState", + "id": 4, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "type": { + "type": "string", + "id": 7, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "optimizationObjective": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "periodicTuningState": { + "type": "PeriodicTuningState", + "id": 11, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "lastTuneTime": { + "type": "google.protobuf.Timestamp", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "tuningOperation": { + "type": "string", + "id": 15, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "dataState": { + "type": "DataState", + "id": 16, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "filteringOption": { + "type": "RecommendationsFilteringOption", + "id": 18, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "servingConfigLists": { + "rule": "repeated", + "type": "ServingConfigList", + "id": 19, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "PageOptimizationConfig": { + "fields": { + "pageOptimizationEventType": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "panels": { + "rule": "repeated", + "type": "Panel", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "restriction": { + "type": "Restriction", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "Candidate": { + "oneofs": { + "candidate": { + "oneof": [ + "servingConfigId" + ] + } + }, + "fields": { + "servingConfigId": { + "type": "string", + "id": 1 + } + } + }, + "Panel": { + "fields": { + "displayName": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "candidates": { + "rule": "repeated", + "type": "Candidate", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "defaultCandidate": { + "type": "Candidate", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "Restriction": { + "values": { + "RESTRICTION_UNSPECIFIED": 0, + "NO_RESTRICTION": 1, + "UNIQUE_SERVING_CONFIG_RESTRICTION": 2, + "UNIQUE_MODEL_RESTRICTION": 3, + "UNIQUE_MODEL_TYPE_RESTRICTION": 4 + } + } + } + }, + "ServingConfigList": { + "fields": { + "servingConfigIds": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ServingState": { + "values": { + "SERVING_STATE_UNSPECIFIED": 0, + "INACTIVE": 1, + "ACTIVE": 2, + "TUNED": 3 + } + }, + "TrainingState": { + "values": { + "TRAINING_STATE_UNSPECIFIED": 0, + "PAUSED": 1, + "TRAINING": 2 + } + }, + "PeriodicTuningState": { + "values": { + "PERIODIC_TUNING_STATE_UNSPECIFIED": 0, + "PERIODIC_TUNING_DISABLED": 1, + "ALL_TUNING_DISABLED": 3, + "PERIODIC_TUNING_ENABLED": 2 + } + }, + "DataState": { + "values": { + "DATA_STATE_UNSPECIFIED": 0, + "DATA_OK": 1, + "DATA_ERROR": 2 + } + } + } + }, + "ModelService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateModel": { + "requestType": "CreateModelRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models", + "(google.api.http).body": "model", + "(google.api.method_signature)": "parent,model", + "(google.longrunning.operation_info).response_type": "Model", + "(google.longrunning.operation_info).metadata_type": "CreateModelMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models", + "body": "model" + } + }, + { + "(google.api.method_signature)": "parent,model" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Model", + "metadata_type": "CreateModelMetadata" + } + } + ] + }, + "PauseModel": { + "requestType": "PauseModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:pause", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:pause", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ResumeModel": { + "requestType": "ResumeModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:resume", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:resume", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "DeleteModel": { + "requestType": "DeleteModelRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListModels": { + "requestType": "ListModelsRequest", + "responseType": "ListModelsResponse", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateModel": { + "requestType": "UpdateModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).patch": "/v2alpha/{model.name=projects/*/locations/*/catalogs/*/models/*}", + "(google.api.http).body": "model", + "(google.api.method_signature)": "model,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{model.name=projects/*/locations/*/catalogs/*/models/*}", + "body": "model" + } + }, + { + "(google.api.method_signature)": "model,update_mask" + } + ] + }, + "TuneModel": { + "requestType": "TuneModelRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:tune", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "TuneModelResponse", + "(google.longrunning.operation_info).metadata_type": "TuneModelMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:tune", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "TuneModelResponse", + "metadata_type": "TuneModelMetadata" + } + } + ] + } + } + }, + "CreateModelRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "model": { + "type": "Model", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "dryRun": { + "type": "bool", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "UpdateModelRequest": { + "fields": { + "model": { + "type": "Model", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "PauseModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "ResumeModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ListModelsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "DeleteModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "ListModelsResponse": { + "fields": { + "models": { + "rule": "repeated", + "type": "Model", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "TuneModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "CreateModelMetadata": { + "fields": { + "model": { + "type": "string", + "id": 1 + } + } + }, + "TuneModelMetadata": { + "fields": { + "model": { + "type": "string", + "id": 1 + } + } + }, + "TuneModelResponse": { + "fields": {} + }, + "PredictionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Predict": { + "requestType": "PredictRequest", + "responseType": "PredictResponse", + "options": { + "(google.api.http).post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "body": "*", + "additional_bindings": { + "post": "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "body": "*" + } + } + } + ] + } + } + }, + "PredictRequest": { + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4, + "options": { + "deprecated": true + } + }, + "filter": { + "type": "string", + "id": 5 + }, + "validateOnly": { + "type": "bool", + "id": 6 + }, + "params": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 7 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 8 + } + } + }, + "PredictResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "PredictionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "missingIds": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "PredictionResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "metadata": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 2 + } + } + } + } + }, + "ProductService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateProduct": { + "requestType": "CreateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.http).body": "product", + "(google.api.method_signature)": "parent,product,product_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "body": "product" + } + }, + { + "(google.api.method_signature)": "parent,product,product_id" + } + ] + }, + "GetProduct": { + "requestType": "GetProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListProducts": { + "requestType": "ListProductsRequest", + "responseType": "ListProductsResponse", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateProduct": { + "requestType": "UpdateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).patch": "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.http).body": "product", + "(google.api.method_signature)": "product,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "body": "product" + } + }, + { + "(google.api.method_signature)": "product,update_mask" + } + ] + }, + "DeleteProduct": { + "requestType": "DeleteProductRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "PurgeProducts": { + "requestType": "PurgeProductsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.PurgeProductsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.PurgeProductsMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:purge", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.PurgeProductsResponse", + "metadata_type": "google.cloud.retail.v2alpha.PurgeProductsMetadata" + } + } + ] + }, + "ImportProducts": { + "requestType": "ImportProductsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.ImportProductsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.ImportProductsResponse", + "metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + } + } + ] + }, + "SetInventory": { + "requestType": "SetInventoryRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "(google.api.http).body": "*", + "(google.api.method_signature)": "inventory,set_mask", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.SetInventoryResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.SetInventoryMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "body": "*" + } + }, + { + "(google.api.method_signature)": "inventory,set_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.SetInventoryResponse", + "metadata_type": "google.cloud.retail.v2alpha.SetInventoryMetadata" + } + } + ] + }, + "AddFulfillmentPlaces": { + "requestType": "AddFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata" + } + } + ] + }, + "RemoveFulfillmentPlaces": { + "requestType": "RemoveFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata" + } + } + ] + }, + "AddLocalInventories": { + "requestType": "AddLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.AddLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.AddLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2alpha.AddLocalInventoriesMetadata" + } + } + ] + }, + "RemoveLocalInventories": { + "requestType": "RemoveLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata" + } + } + ] + } + } + }, + "CreateProductRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "product": { + "type": "Product", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "productId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "UpdateProductRequest": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "DeleteProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "ListProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "filter": { + "type": "string", + "id": 4 + }, + "readMask": { + "type": "google.protobuf.FieldMask", + "id": 5 + }, + "requireTotalSize": { + "type": "bool", + "id": 6 + } + } + }, + "ListProductsResponse": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + }, + "totalSize": { + "type": "int32", + "id": 3 + } + } + }, + "SetInventoryRequest": { + "fields": { + "inventory": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "setMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "allowMissing": { + "type": "bool", + "id": 4 + } + } + }, + "SetInventoryMetadata": { + "fields": {} + }, + "SetInventoryResponse": { + "fields": {} + }, + "AddFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "AddFulfillmentPlacesMetadata": { + "fields": {} + }, + "AddFulfillmentPlacesResponse": { + "fields": {} + }, + "AddLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "localInventories": { + "rule": "repeated", + "type": "LocalInventory", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 6 + } + } + }, + "AddLocalInventoriesMetadata": { + "fields": {} + }, + "AddLocalInventoriesResponse": { + "fields": {} + }, + "RemoveLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "RemoveLocalInventoriesMetadata": { + "fields": {} + }, + "RemoveLocalInventoriesResponse": { + "fields": {} + }, + "RemoveFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "RemoveFulfillmentPlacesMetadata": { + "fields": {} + }, + "RemoveFulfillmentPlacesResponse": { + "fields": {} + }, + "PurgeMetadata": { + "fields": {} + }, + "PurgeProductsMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "successCount": { + "type": "int64", + "id": 3 + }, + "failureCount": { + "type": "int64", + "id": 4 + } + } + }, + "PurgeProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "filter": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "force": { + "type": "bool", + "id": 3 + } + } + }, + "PurgeProductsResponse": { + "fields": { + "purgeCount": { + "type": "int64", + "id": 1 + }, + "purgeSample": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "PurgeUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "filter": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "force": { + "type": "bool", + "id": 3 + } + } + }, + "PurgeUserEventsResponse": { + "fields": { + "purgedEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "ServingConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/ServingConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "modelId": { + "type": "string", + "id": 3 + }, + "priceRerankingLevel": { + "type": "string", + "id": 4 + }, + "facetControlIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "dynamicFacetSpec": { + "type": "SearchRequest.DynamicFacetSpec", + "id": 6 + }, + "boostControlIds": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "filterControlIds": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "redirectControlIds": { + "rule": "repeated", + "type": "string", + "id": 10 + }, + "twowaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 18 + }, + "onewaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "doNotAssociateControlIds": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "replacementControlIds": { + "rule": "repeated", + "type": "string", + "id": 14 + }, + "ignoreControlIds": { + "rule": "repeated", + "type": "string", + "id": 15 + }, + "diversityLevel": { + "type": "string", + "id": 8 + }, + "enableCategoryFilterLevel": { + "type": "string", + "id": 16 + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 19, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + } + } + }, + "ServingConfigService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateServingConfig": { + "requestType": "CreateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + } + ] + }, + "DeleteServingConfig": { + "requestType": "DeleteServingConfigRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateServingConfig": { + "requestType": "UpdateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).patch": "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "serving_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2alpha/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "serving_config,update_mask" + } + ] + }, + "GetServingConfig": { + "requestType": "GetServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListServingConfigs": { + "requestType": "ListServingConfigsRequest", + "responseType": "ListServingConfigsResponse", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "AddControl": { + "requestType": "AddControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + }, + "RemoveControl": { + "requestType": "RemoveControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + } + } + }, + "CreateServingConfigRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "servingConfig": { + "type": "ServingConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "servingConfigId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateServingConfigRequest": { + "fields": { + "servingConfig": { + "type": "ServingConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "GetServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "ListServingConfigsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListServingConfigsResponse": { + "fields": { + "servingConfigs": { + "rule": "repeated", + "type": "ServingConfig", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "AddControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "WriteUserEvent": { + "requestType": "WriteUserEventRequest", + "responseType": "UserEvent", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "(google.api.http).body": "user_event" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "body": "user_event" + } + } + ] + }, + "CollectUserEvent": { + "requestType": "CollectUserEventRequest", + "responseType": "google.api.HttpBody", + "options": { + "(google.api.http).get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + } + } + ] + }, + "PurgeUserEvents": { + "requestType": "PurgeUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.PurgeUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.PurgeMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.PurgeUserEventsResponse", + "metadata_type": "google.cloud.retail.v2alpha.PurgeMetadata" + } + } + ] + }, + "ImportUserEvents": { + "requestType": "ImportUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.ImportUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2alpha.ImportUserEventsResponse", + "metadata_type": "google.cloud.retail.v2alpha.ImportMetadata" + } + } + ] + }, + "RejoinUserEvents": { + "requestType": "RejoinUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "RejoinUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "RejoinUserEventsMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "RejoinUserEventsResponse", + "metadata_type": "RejoinUserEventsMetadata" + } + } + ] + } + } + }, + "WriteUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CollectUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "uri": { + "type": "string", + "id": 3 + }, + "ets": { + "type": "int64", + "id": 4 + } + } + }, + "RejoinUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEventRejoinScope": { + "type": "UserEventRejoinScope", + "id": 2 + } + }, + "nested": { + "UserEventRejoinScope": { + "values": { + "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": 0, + "JOINED_EVENTS": 1, + "UNJOINED_EVENTS": 2 + } + } + } + }, + "RejoinUserEventsResponse": { + "fields": { + "rejoinedUserEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "RejoinUserEventsMetadata": { + "fields": {} + } + } + }, + "v2beta": { + "options": { + "csharp_namespace": "Google.Cloud.Retail.V2Beta", + "go_package": "google.golang.org/genproto/googleapis/cloud/retail/v2beta;retail", + "java_multiple_files": true, + "java_outer_classname": "UserEventServiceProto", + "java_package": "com.google.cloud.retail.v2beta", + "objc_class_prefix": "RETAIL", + "php_namespace": "Google\\Cloud\\Retail\\V2beta", + "ruby_package": "Google::Cloud::Retail::V2beta", + "(google.api.resource_definition).type": "retail.googleapis.com/Branch", + "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}" + }, + "nested": { + "ProductLevelConfig": { + "fields": { + "ingestionProductType": { + "type": "string", + "id": 1 + }, + "merchantCenterProductIdField": { + "type": "string", + "id": 2 + } + } + }, + "CatalogAttribute": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "inUse": { + "type": "bool", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "type": { + "type": "AttributeType", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "indexableOption": { + "type": "IndexableOption", + "id": 5 + }, + "dynamicFacetableOption": { + "type": "DynamicFacetableOption", + "id": 6 + }, + "searchableOption": { + "type": "SearchableOption", + "id": 7 + }, + "recommendationsFilteringOption": { + "type": "RecommendationsFilteringOption", + "id": 8 + }, + "exactSearchableOption": { + "type": "ExactSearchableOption", + "id": 11 + } + }, + "nested": { + "AttributeType": { + "values": { + "UNKNOWN": 0, + "TEXTUAL": 1, + "NUMERICAL": 2 + } + }, + "IndexableOption": { + "values": { + "INDEXABLE_OPTION_UNSPECIFIED": 0, + "INDEXABLE_ENABLED": 1, + "INDEXABLE_DISABLED": 2 + } + }, + "DynamicFacetableOption": { + "values": { + "DYNAMIC_FACETABLE_OPTION_UNSPECIFIED": 0, + "DYNAMIC_FACETABLE_ENABLED": 1, + "DYNAMIC_FACETABLE_DISABLED": 2 + } + }, + "SearchableOption": { + "values": { + "SEARCHABLE_OPTION_UNSPECIFIED": 0, + "SEARCHABLE_ENABLED": 1, + "SEARCHABLE_DISABLED": 2 + } + }, + "ExactSearchableOption": { + "values": { + "EXACT_SEARCHABLE_OPTION_UNSPECIFIED": 0, + "EXACT_SEARCHABLE_ENABLED": 1, + "EXACT_SEARCHABLE_DISABLED": 2 + } + } + } + }, + "AttributesConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/AttributesConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "catalogAttributes": { + "keyType": "string", + "type": "CatalogAttribute", + "id": 2 + }, + "attributeConfigLevel": { + "type": "AttributeConfigLevel", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "CompletionConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/CompletionConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "matchingOrder": { + "type": "string", + "id": 2 + }, + "maxSuggestions": { + "type": "int32", + "id": 3 + }, + "minPrefixLength": { + "type": "int32", + "id": 4 + }, + "autoLearning": { + "type": "bool", + "id": 11 + }, + "suggestionsInputConfig": { + "type": "CompletionDataInputConfig", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastSuggestionsImportOperation": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "denylistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastDenylistImportOperation": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "allowlistInputConfig": { + "type": "CompletionDataInputConfig", + "id": 9, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "lastAllowlistImportOperation": { + "type": "string", + "id": 10, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + } + }, + "MerchantCenterLink": { + "fields": { + "merchantCenterAccountId": { + "type": "int64", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "branchId": { + "type": "string", + "id": 2 + }, + "destinations": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "regionCode": { + "type": "string", + "id": 4 + }, + "languageCode": { + "type": "string", + "id": 5 + } + } + }, + "MerchantCenterLinkingConfig": { + "fields": { + "links": { + "rule": "repeated", + "type": "MerchantCenterLink", + "id": 1 + } + } + }, + "Catalog": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Catalog", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "productLevelConfig": { + "type": "ProductLevelConfig", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "merchantCenterLinkingConfig": { + "type": "MerchantCenterLinkingConfig", + "id": 6 + } + } + }, + "AttributeConfigLevel": { + "values": { + "ATTRIBUTE_CONFIG_LEVEL_UNSPECIFIED": 0, + "PRODUCT_LEVEL_ATTRIBUTE_CONFIG": 1, + "CATALOG_LEVEL_ATTRIBUTE_CONFIG": 2 + } + }, + "SolutionType": { + "values": { + "SOLUTION_TYPE_UNSPECIFIED": 0, + "SOLUTION_TYPE_RECOMMENDATION": 1, + "SOLUTION_TYPE_SEARCH": 2 + } + }, + "RecommendationsFilteringOption": { + "values": { + "RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED": 0, + "RECOMMENDATIONS_FILTERING_DISABLED": 1, + "RECOMMENDATIONS_FILTERING_ENABLED": 3 + } + }, + "SearchSolutionUseCase": { + "values": { + "SEARCH_SOLUTION_USE_CASE_UNSPECIFIED": 0, + "SEARCH_SOLUTION_USE_CASE_SEARCH": 1, + "SEARCH_SOLUTION_USE_CASE_BROWSE": 2 + } + }, + "Condition": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "QueryTerm", + "id": 1 + }, + "activeTimeRange": { + "rule": "repeated", + "type": "TimeRange", + "id": 3 + } + }, + "nested": { + "QueryTerm": { + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "fullMatch": { + "type": "bool", + "id": 2 + } + } + }, + "TimeRange": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + } + } + }, + "Rule": { + "oneofs": { + "action": { + "oneof": [ + "boostAction", + "redirectAction", + "onewaySynonymsAction", + "doNotAssociateAction", + "replacementAction", + "ignoreAction", + "filterAction", + "twowaySynonymsAction" + ] + } + }, + "fields": { + "boostAction": { + "type": "BoostAction", + "id": 2 + }, + "redirectAction": { + "type": "RedirectAction", + "id": 3 + }, + "onewaySynonymsAction": { + "type": "OnewaySynonymsAction", + "id": 6 + }, + "doNotAssociateAction": { + "type": "DoNotAssociateAction", + "id": 7 + }, + "replacementAction": { + "type": "ReplacementAction", + "id": 8 + }, + "ignoreAction": { + "type": "IgnoreAction", + "id": 9 + }, + "filterAction": { + "type": "FilterAction", + "id": 10 + }, + "twowaySynonymsAction": { + "type": "TwowaySynonymsAction", + "id": 11 + }, + "condition": { + "type": "Condition", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + }, + "nested": { + "BoostAction": { + "fields": { + "boost": { + "type": "float", + "id": 1 + }, + "productsFilter": { + "type": "string", + "id": 2 + } + } + }, + "FilterAction": { + "fields": { + "filter": { + "type": "string", + "id": 1 + } + } + }, + "RedirectAction": { + "fields": { + "redirectUri": { + "type": "string", + "id": 1 + } + } + }, + "TwowaySynonymsAction": { + "fields": { + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "OnewaySynonymsAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "synonyms": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "onewayTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "DoNotAssociateAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "doNotAssociateTerms": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "terms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "ReplacementAction": { + "fields": { + "queryTerms": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "replacementTerm": { + "type": "string", + "id": 3 + }, + "term": { + "type": "string", + "id": 1 + } + } + }, + "IgnoreAction": { + "fields": { + "ignoreTerms": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + } + } + }, + "Audience": { + "fields": { + "genders": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "ageGroups": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "ColorInfo": { + "fields": { + "colorFamilies": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "colors": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "CustomAttribute": { + "oneofs": { + "_searchable": { + "oneof": [ + "searchable" + ] + }, + "_indexable": { + "oneof": [ + "indexable" + ] + } + }, + "fields": { + "text": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "numbers": { + "rule": "repeated", + "type": "double", + "id": 2 + }, + "searchable": { + "type": "bool", + "id": 3, + "options": { + "deprecated": true, + "proto3_optional": true + } + }, + "indexable": { + "type": "bool", + "id": 4, + "options": { + "deprecated": true, + "proto3_optional": true + } + } + } + }, + "FulfillmentInfo": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "Image": { + "fields": { + "uri": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "height": { + "type": "int32", + "id": 2 + }, + "width": { + "type": "int32", + "id": 3 + } + } + }, + "Interval": { + "oneofs": { + "min": { + "oneof": [ + "minimum", + "exclusiveMinimum" + ] + }, + "max": { + "oneof": [ + "maximum", + "exclusiveMaximum" + ] + } + }, + "fields": { + "minimum": { + "type": "double", + "id": 1 + }, + "exclusiveMinimum": { + "type": "double", + "id": 2 + }, + "maximum": { + "type": "double", + "id": 3 + }, + "exclusiveMaximum": { + "type": "double", + "id": 4 + } + } + }, + "PriceInfo": { + "fields": { + "currencyCode": { + "type": "string", + "id": 1 + }, + "price": { + "type": "float", + "id": 2 + }, + "originalPrice": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "priceEffectiveTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "priceExpireTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + }, + "priceRange": { + "type": "PriceRange", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "PriceRange": { + "fields": { + "price": { + "type": "Interval", + "id": 1 + }, + "originalPrice": { + "type": "Interval", + "id": 2 + } + } + } + } + }, + "Rating": { + "fields": { + "ratingCount": { + "type": "int32", + "id": 1 + }, + "averageRating": { + "type": "float", + "id": 2 + }, + "ratingHistogram": { + "rule": "repeated", + "type": "int32", + "id": 3 + } + } + }, + "UserInfo": { + "fields": { + "userId": { + "type": "string", + "id": 1 + }, + "ipAddress": { + "type": "string", + "id": 2 + }, + "userAgent": { + "type": "string", + "id": 3 + }, + "directUserRequest": { + "type": "bool", + "id": 4 + } + } + }, + "LocalInventory": { + "fields": { + "placeId": { + "type": "string", + "id": 1 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 2 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 3 + }, + "fulfillmentTypes": { + "rule": "repeated", + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + } + } + }, + "GcsSource": { + "fields": { + "inputUris": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "dataSchema": { + "type": "string", + "id": 2 + } + } + }, + "BigQuerySource": { + "oneofs": { + "partition": { + "oneof": [ + "partitionDate" + ] + } + }, + "fields": { + "partitionDate": { + "type": "google.type.Date", + "id": 6 + }, + "projectId": { + "type": "string", + "id": 5 + }, + "datasetId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tableId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsStagingDir": { + "type": "string", + "id": 3 + }, + "dataSchema": { + "type": "string", + "id": 4 + } + } + }, + "ProductInlineSource": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventInlineSource": { + "fields": { + "userEvents": { + "rule": "repeated", + "type": "UserEvent", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportErrorsConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsPrefix" + ] + } + }, + "fields": { + "gcsPrefix": { + "type": "string", + "id": 1 + } + } + }, + "ImportProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "requestId": { + "type": "string", + "id": 6, + "options": { + "deprecated": true + } + }, + "inputConfig": { + "type": "ProductInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "reconciliationMode": { + "type": "ReconciliationMode", + "id": 5 + }, + "notificationPubsubTopic": { + "type": "string", + "id": 7 + } + }, + "nested": { + "ReconciliationMode": { + "values": { + "RECONCILIATION_MODE_UNSPECIFIED": 0, + "INCREMENTAL": 1, + "FULL": 2 + } + } + } + }, + "ImportUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "UserEventInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 3 + } + } + }, + "ImportCompletionDataRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "inputConfig": { + "type": "CompletionDataInputConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 3 + } + } + }, + "ProductInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "productInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "productInlineSource": { + "type": "ProductInlineSource", + "id": 1 + }, + "gcsSource": { + "type": "GcsSource", + "id": 2 + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3 + } + } + }, + "UserEventInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "userEventInlineSource", + "gcsSource", + "bigQuerySource" + ] + } + }, + "fields": { + "userEventInlineSource": { + "type": "UserEventInlineSource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "gcsSource": { + "type": "GcsSource", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "bigQuerySource": { + "type": "BigQuerySource", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CompletionDataInputConfig": { + "oneofs": { + "source": { + "oneof": [ + "bigQuerySource" + ] + } + }, + "fields": { + "bigQuerySource": { + "type": "BigQuerySource", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "successCount": { + "type": "int64", + "id": 3 + }, + "failureCount": { + "type": "int64", + "id": 4 + }, + "requestId": { + "type": "string", + "id": 5, + "options": { + "deprecated": true + } + }, + "notificationPubsubTopic": { + "type": "string", + "id": 6 + } + } + }, + "ImportProductsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + } + } + }, + "ImportUserEventsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ImportErrorsConfig", + "id": 2 + }, + "importSummary": { + "type": "UserEventImportSummary", + "id": 3 + } + } + }, + "UserEventImportSummary": { + "fields": { + "joinedEventsCount": { + "type": "int64", + "id": 1 + }, + "unjoinedEventsCount": { + "type": "int64", + "id": 2 + } + } + }, + "ImportCompletionDataResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + } + } + }, + "Product": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Product", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}" + }, + "oneofs": { + "expiration": { + "oneof": [ + "expireTime", + "ttl" + ] + } + }, + "fields": { + "expireTime": { + "type": "google.protobuf.Timestamp", + "id": 16 + }, + "ttl": { + "type": "google.protobuf.Duration", + "id": 17, + "options": { + "(google.api.field_behavior)": "INPUT_ONLY" + } + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "id": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "type": { + "type": "Type", + "id": 3, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "primaryProductId": { + "type": "string", + "id": 4 + }, + "collectionMemberIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "gtin": { + "type": "string", + "id": 6 + }, + "categories": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "title": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "brands": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "description": { + "type": "string", + "id": 10 + }, + "languageCode": { + "type": "string", + "id": 11 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 12 + }, + "tags": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "priceInfo": { + "type": "PriceInfo", + "id": 14 + }, + "rating": { + "type": "Rating", + "id": 15 + }, + "availableTime": { + "type": "google.protobuf.Timestamp", + "id": 18 + }, + "availability": { + "type": "Availability", + "id": 19 + }, + "availableQuantity": { + "type": "google.protobuf.Int32Value", + "id": 20 + }, + "fulfillmentInfo": { + "rule": "repeated", + "type": "FulfillmentInfo", + "id": 21 + }, + "uri": { + "type": "string", + "id": 22 + }, + "images": { + "rule": "repeated", + "type": "Image", + "id": 23 + }, + "audience": { + "type": "Audience", + "id": 24 + }, + "colorInfo": { + "type": "ColorInfo", + "id": 25 + }, + "sizes": { + "rule": "repeated", + "type": "string", + "id": 26 + }, + "materials": { + "rule": "repeated", + "type": "string", + "id": 27 + }, + "patterns": { + "rule": "repeated", + "type": "string", + "id": 28 + }, + "conditions": { + "rule": "repeated", + "type": "string", + "id": 29 + }, + "promotions": { + "rule": "repeated", + "type": "Promotion", + "id": 34 + }, + "publishTime": { + "type": "google.protobuf.Timestamp", + "id": 33 + }, + "retrievableFields": { + "type": "google.protobuf.FieldMask", + "id": 30 + }, + "variants": { + "rule": "repeated", + "type": "Product", + "id": 31, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "localInventories": { + "rule": "repeated", + "type": "LocalInventory", + "id": 35, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "Type": { + "values": { + "TYPE_UNSPECIFIED": 0, + "PRIMARY": 1, + "VARIANT": 2, + "COLLECTION": 3 + } + }, + "Availability": { + "values": { + "AVAILABILITY_UNSPECIFIED": 0, + "IN_STOCK": 1, + "OUT_OF_STOCK": 2, + "PREORDER": 3, + "BACKORDER": 4 + } + } + } + }, + "Promotion": { + "fields": { + "promotionId": { + "type": "string", + "id": 1 + } + } + }, + "UserEvent": { + "fields": { + "eventType": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "sessionId": { + "type": "string", + "id": 21 + }, + "eventTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "experimentIds": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "productDetails": { + "rule": "repeated", + "type": "ProductDetail", + "id": 6 + }, + "completionDetail": { + "type": "CompletionDetail", + "id": 22 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 7 + }, + "cartId": { + "type": "string", + "id": 8 + }, + "purchaseTransaction": { + "type": "PurchaseTransaction", + "id": 9 + }, + "searchQuery": { + "type": "string", + "id": 10 + }, + "filter": { + "type": "string", + "id": 16 + }, + "orderBy": { + "type": "string", + "id": 17 + }, + "offset": { + "type": "int32", + "id": 18 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 11 + }, + "userInfo": { + "type": "UserInfo", + "id": 12 + }, + "uri": { + "type": "string", + "id": 13 + }, + "referrerUri": { + "type": "string", + "id": 14 + }, + "pageViewId": { + "type": "string", + "id": 15 + } + } + }, + "ProductDetail": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "quantity": { + "type": "google.protobuf.Int32Value", + "id": 2 + } + } + }, + "CompletionDetail": { + "fields": { + "completionAttributionToken": { + "type": "string", + "id": 1 + }, + "selectedSuggestion": { + "type": "string", + "id": 2 + }, + "selectedPosition": { + "type": "int32", + "id": 3 + } + } + }, + "PurchaseTransaction": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "revenue": { + "type": "float", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "tax": { + "type": "float", + "id": 3 + }, + "cost": { + "type": "float", + "id": 4 + }, + "currencyCode": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CatalogService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "ListCatalogs": { + "requestType": "ListCatalogsRequest", + "responseType": "ListCatalogsResponse", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*}/catalogs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*}/catalogs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateCatalog": { + "requestType": "UpdateCatalogRequest", + "responseType": "Catalog", + "options": { + "(google.api.http).patch": "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}", + "(google.api.http).body": "catalog", + "(google.api.method_signature)": "catalog,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{catalog.name=projects/*/locations/*/catalogs/*}", + "body": "catalog" + } + }, + { + "(google.api.method_signature)": "catalog,update_mask" + } + ] + }, + "SetDefaultBranch": { + "requestType": "SetDefaultBranchRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "(google.api.http).body": "*", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:setDefaultBranch", + "body": "*" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetDefaultBranch": { + "requestType": "GetDefaultBranchRequest", + "responseType": "GetDefaultBranchResponse", + "options": { + "(google.api.http).get": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch", + "(google.api.method_signature)": "catalog" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:getDefaultBranch" + } + }, + { + "(google.api.method_signature)": "catalog" + } + ] + }, + "GetCompletionConfig": { + "requestType": "GetCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).get": "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{name=projects/*/locations/*/catalogs/*/completionConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateCompletionConfig": { + "requestType": "UpdateCompletionConfigRequest", + "responseType": "CompletionConfig", + "options": { + "(google.api.http).patch": "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "(google.api.http).body": "completion_config", + "(google.api.method_signature)": "completion_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{completion_config.name=projects/*/locations/*/catalogs/*/completionConfig}", + "body": "completion_config" + } + }, + { + "(google.api.method_signature)": "completion_config,update_mask" + } + ] + }, + "GetAttributesConfig": { + "requestType": "GetAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).get": "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateAttributesConfig": { + "requestType": "UpdateAttributesConfigRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).patch": "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "(google.api.http).body": "attributes_config", + "(google.api.method_signature)": "attributes_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{attributes_config.name=projects/*/locations/*/catalogs/*/attributesConfig}", + "body": "attributes_config" + } + }, + { + "(google.api.method_signature)": "attributes_config,update_mask" + } + ] + }, + "AddCatalogAttribute": { + "requestType": "AddCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute", + "body": "*" + } + } + ] + }, + "RemoveCatalogAttribute": { + "requestType": "RemoveCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute", + "body": "*" + } + } + ] + }, + "BatchRemoveCatalogAttributes": { + "requestType": "BatchRemoveCatalogAttributesRequest", + "responseType": "BatchRemoveCatalogAttributesResponse", + "options": { + "(google.api.http).post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes", + "body": "*" + } + } + ] + }, + "ReplaceCatalogAttribute": { + "requestType": "ReplaceCatalogAttributeRequest", + "responseType": "AttributesConfig", + "options": { + "(google.api.http).post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute", + "body": "*" + } + } + ] + } + } + }, + "ListCatalogsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "locations.googleapis.com/Location" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListCatalogsResponse": { + "fields": { + "catalogs": { + "rule": "repeated", + "type": "Catalog", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "UpdateCatalogRequest": { + "fields": { + "catalog": { + "type": "Catalog", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "SetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "branchId": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "note": { + "type": "string", + "id": 3 + }, + "force": { + "type": "bool", + "id": 4 + } + } + }, + "GetDefaultBranchRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + } + } + }, + "GetDefaultBranchResponse": { + "fields": { + "branch": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "note": { + "type": "string", + "id": 3 + } + } + }, + "GetCompletionConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/CompletionConfig" + } + } + } + }, + "UpdateCompletionConfigRequest": { + "fields": { + "completionConfig": { + "type": "CompletionConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "GetAttributesConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + } + } + }, + "UpdateAttributesConfigRequest": { + "fields": { + "attributesConfig": { + "type": "AttributesConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "AddCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "key": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "BatchRemoveCatalogAttributesRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "attributeKeys": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "BatchRemoveCatalogAttributesResponse": { + "fields": { + "deletedCatalogAttributes": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "resetCatalogAttributes": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "ReplaceCatalogAttributeRequest": { + "fields": { + "attributesConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/AttributesConfig" + } + }, + "catalogAttribute": { + "type": "CatalogAttribute", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 3 + } + } + }, + "CompletionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CompleteQuery": { + "requestType": "CompleteQueryRequest", + "responseType": "CompleteQueryResponse", + "options": { + "(google.api.http).get": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{catalog=projects/*/locations/*/catalogs/*}:completeQuery" + } + } + ] + }, + "ImportCompletionData": { + "requestType": "ImportCompletionDataRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.ImportCompletionDataResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/completionData:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.ImportCompletionDataResponse", + "metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + } + } + ] + } + } + }, + "CompleteQueryRequest": { + "fields": { + "catalog": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "query": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "visitorId": { + "type": "string", + "id": 7 + }, + "languageCodes": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "deviceType": { + "type": "string", + "id": 4 + }, + "dataset": { + "type": "string", + "id": 6 + }, + "maxSuggestions": { + "type": "int32", + "id": 5 + } + } + }, + "CompleteQueryResponse": { + "fields": { + "completionResults": { + "rule": "repeated", + "type": "CompletionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "recentSearchResults": { + "rule": "repeated", + "type": "RecentSearchResult", + "id": 3 + } + }, + "nested": { + "CompletionResult": { + "fields": { + "suggestion": { + "type": "string", + "id": 1 + }, + "attributes": { + "keyType": "string", + "type": "CustomAttribute", + "id": 2 + } + } + }, + "RecentSearchResult": { + "fields": { + "recentSearch": { + "type": "string", + "id": 1 + } + } + } + } + }, + "Control": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Control", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}" + }, + "oneofs": { + "control": { + "oneof": [ + "facetSpec", + "rule" + ] + } + }, + "fields": { + "facetSpec": { + "type": "SearchRequest.FacetSpec", + "id": 3, + "options": { + "deprecated": true + } + }, + "rule": { + "type": "Rule", + "id": 4 + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "associatedServingConfigIds": { + "rule": "repeated", + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 6, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "searchSolutionUseCase": { + "rule": "repeated", + "type": "SearchSolutionUseCase", + "id": 7 + } + } + }, + "SearchService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Search": { + "requestType": "SearchRequest", + "responseType": "SearchResponse", + "options": { + "(google.api.http).post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:search", + "body": "*", + "additional_bindings": { + "post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:search", + "body": "*" + } + } + } + ] + } + } + }, + "SearchRequest": { + "oneofs": { + "_spellCorrectionSpec": { + "oneof": [ + "spellCorrectionSpec" + ] + } + }, + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "branch": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "query": { + "type": "string", + "id": 3 + }, + "visitorId": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userInfo": { + "type": "UserInfo", + "id": 5 + }, + "pageSize": { + "type": "int32", + "id": 7 + }, + "pageToken": { + "type": "string", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 9 + }, + "filter": { + "type": "string", + "id": 10 + }, + "canonicalFilter": { + "type": "string", + "id": 28 + }, + "orderBy": { + "type": "string", + "id": 11 + }, + "facetSpecs": { + "rule": "repeated", + "type": "FacetSpec", + "id": 12 + }, + "dynamicFacetSpec": { + "type": "DynamicFacetSpec", + "id": 21, + "options": { + "deprecated": true + } + }, + "boostSpec": { + "type": "BoostSpec", + "id": 13 + }, + "queryExpansionSpec": { + "type": "QueryExpansionSpec", + "id": 14 + }, + "variantRollupKeys": { + "rule": "repeated", + "type": "string", + "id": 17 + }, + "pageCategories": { + "rule": "repeated", + "type": "string", + "id": 23 + }, + "searchMode": { + "type": "SearchMode", + "id": 31 + }, + "personalizationSpec": { + "type": "PersonalizationSpec", + "id": 32 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 34 + }, + "spellCorrectionSpec": { + "type": "SpellCorrectionSpec", + "id": 35, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "FacetSpec": { + "fields": { + "facetKey": { + "type": "FacetKey", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "limit": { + "type": "int32", + "id": 2 + }, + "excludedFilterKeys": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "enableDynamicPosition": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "FacetKey": { + "fields": { + "key": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "intervals": { + "rule": "repeated", + "type": "Interval", + "id": 2 + }, + "restrictedValues": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "prefixes": { + "rule": "repeated", + "type": "string", + "id": 8 + }, + "contains": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "caseInsensitive": { + "type": "bool", + "id": 10 + }, + "orderBy": { + "type": "string", + "id": 4 + }, + "query": { + "type": "string", + "id": 5 + }, + "returnMinMax": { + "type": "bool", + "id": 11 + } + } + } + } + }, + "DynamicFacetSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "DISABLED": 1, + "ENABLED": 2 + } + } + } + }, + "BoostSpec": { + "oneofs": { + "_skipBoostSpecValidation": { + "oneof": [ + "skipBoostSpecValidation" + ] + } + }, + "fields": { + "conditionBoostSpecs": { + "rule": "repeated", + "type": "ConditionBoostSpec", + "id": 1 + }, + "skipBoostSpecValidation": { + "type": "bool", + "id": 2, + "options": { + "proto3_optional": true + } + } + }, + "nested": { + "ConditionBoostSpec": { + "fields": { + "condition": { + "type": "string", + "id": 1 + }, + "boost": { + "type": "float", + "id": 2 + } + } + } + } + }, + "QueryExpansionSpec": { + "fields": { + "condition": { + "type": "Condition", + "id": 1 + }, + "pinUnexpandedResults": { + "type": "bool", + "id": 2 + } + }, + "nested": { + "Condition": { + "values": { + "CONDITION_UNSPECIFIED": 0, + "DISABLED": 1, + "AUTO": 3 + } + } + } + }, + "PersonalizationSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "AUTO": 1, + "DISABLED": 2 + } + } + } + }, + "SpellCorrectionSpec": { + "fields": { + "mode": { + "type": "Mode", + "id": 1 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "SUGGESTION_ONLY": 1, + "AUTO": 2 + } + } + } + }, + "SearchMode": { + "values": { + "SEARCH_MODE_UNSPECIFIED": 0, + "PRODUCT_SEARCH_ONLY": 1, + "FACETED_SEARCH_ONLY": 2 + } + } + } + }, + "SearchResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "SearchResult", + "id": 1 + }, + "facets": { + "rule": "repeated", + "type": "Facet", + "id": 2 + }, + "totalSize": { + "type": "int32", + "id": 3 + }, + "correctedQuery": { + "type": "string", + "id": 4 + }, + "attributionToken": { + "type": "string", + "id": 5 + }, + "nextPageToken": { + "type": "string", + "id": 6 + }, + "queryExpansionInfo": { + "type": "QueryExpansionInfo", + "id": 7 + }, + "redirectUri": { + "type": "string", + "id": 10 + }, + "appliedControls": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "invalidConditionBoostSpecs": { + "rule": "repeated", + "type": "SearchRequest.BoostSpec.ConditionBoostSpec", + "id": 14 + } + }, + "nested": { + "SearchResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "product": { + "type": "Product", + "id": 2 + }, + "matchingVariantCount": { + "type": "int32", + "id": 3 + }, + "matchingVariantFields": { + "keyType": "string", + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "variantRollupValues": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 5 + }, + "personalLabels": { + "rule": "repeated", + "type": "string", + "id": 7 + } + } + }, + "Facet": { + "fields": { + "key": { + "type": "string", + "id": 1 + }, + "values": { + "rule": "repeated", + "type": "FacetValue", + "id": 2 + }, + "dynamicFacet": { + "type": "bool", + "id": 3 + } + }, + "nested": { + "FacetValue": { + "oneofs": { + "facetValue": { + "oneof": [ + "value", + "interval" + ] + } + }, + "fields": { + "value": { + "type": "string", + "id": 1 + }, + "interval": { + "type": "Interval", + "id": 2 + }, + "count": { + "type": "int64", + "id": 3 + }, + "minValue": { + "type": "double", + "id": 5 + }, + "maxValue": { + "type": "double", + "id": 6 + } + } + } + } + }, + "QueryExpansionInfo": { + "fields": { + "expandedQuery": { + "type": "bool", + "id": 1 + }, + "pinnedResultCount": { + "type": "int64", + "id": 2 + } + } + } + } + }, + "ControlService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateControl": { + "requestType": "CreateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.http).body": "control", + "(google.api.method_signature)": "parent,control,control_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + "body": "control" + } + }, + { + "(google.api.method_signature)": "parent,control,control_id" + } + ] + }, + "DeleteControl": { + "requestType": "DeleteControlRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateControl": { + "requestType": "UpdateControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).patch": "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.http).body": "control", + "(google.api.method_signature)": "control,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{control.name=projects/*/locations/*/catalogs/*/controls/*}", + "body": "control" + } + }, + { + "(google.api.method_signature)": "control,update_mask" + } + ] + }, + "GetControl": { + "requestType": "GetControlRequest", + "responseType": "Control", + "options": { + "(google.api.http).get": "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{name=projects/*/locations/*/catalogs/*/controls/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListControls": { + "requestType": "ListControlsRequest", + "responseType": "ListControlsResponse", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/controls" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + } + } + }, + "CreateControlRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "control": { + "type": "Control", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "controlId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateControlRequest": { + "fields": { + "control": { + "type": "Control", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "GetControlRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Control" + } + } + } + }, + "ListControlsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "filter": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListControlsResponse": { + "fields": { + "controls": { + "rule": "repeated", + "type": "Control", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "ExportErrorsConfig": { + "oneofs": { + "destination": { + "oneof": [ + "gcsPrefix" + ] + } + }, + "fields": { + "gcsPrefix": { + "type": "string", + "id": 1 + } + } + }, + "ExportMetadata": { + "fields": { + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + } + } + }, + "ExportProductsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ExportErrorsConfig", + "id": 2 + }, + "outputResult": { + "type": "OutputResult", + "id": 3 + } + } + }, + "ExportUserEventsResponse": { + "fields": { + "errorSamples": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "errorsConfig": { + "type": "ExportErrorsConfig", + "id": 2 + }, + "outputResult": { + "type": "OutputResult", + "id": 3 + } + } + }, + "OutputResult": { + "fields": { + "bigqueryResult": { + "rule": "repeated", + "type": "BigQueryOutputResult", + "id": 1 + } + } + }, + "BigQueryOutputResult": { + "fields": { + "datasetId": { + "type": "string", + "id": 1 + }, + "tableId": { + "type": "string", + "id": 2 + } + } + }, + "Model": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/Model", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "trainingState": { + "type": "TrainingState", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "servingState": { + "type": "ServingState", + "id": 4, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 5, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 6, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "type": { + "type": "string", + "id": 7, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "optimizationObjective": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "periodicTuningState": { + "type": "PeriodicTuningState", + "id": 11, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "lastTuneTime": { + "type": "google.protobuf.Timestamp", + "id": 12, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "tuningOperation": { + "type": "string", + "id": 15, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "dataState": { + "type": "DataState", + "id": 16, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "filteringOption": { + "type": "RecommendationsFilteringOption", + "id": 18, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "servingConfigLists": { + "rule": "repeated", + "type": "ServingConfigList", + "id": 19, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "ServingConfigList": { + "fields": { + "servingConfigIds": { + "rule": "repeated", + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ServingState": { + "values": { + "SERVING_STATE_UNSPECIFIED": 0, + "INACTIVE": 1, + "ACTIVE": 2, + "TUNED": 3 + } + }, + "TrainingState": { + "values": { + "TRAINING_STATE_UNSPECIFIED": 0, + "PAUSED": 1, + "TRAINING": 2 + } + }, + "PeriodicTuningState": { + "values": { + "PERIODIC_TUNING_STATE_UNSPECIFIED": 0, + "PERIODIC_TUNING_DISABLED": 1, + "ALL_TUNING_DISABLED": 3, + "PERIODIC_TUNING_ENABLED": 2 + } + }, + "DataState": { + "values": { + "DATA_STATE_UNSPECIFIED": 0, + "DATA_OK": 1, + "DATA_ERROR": 2 + } + } + } + }, + "ModelService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateModel": { + "requestType": "CreateModelRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models", + "(google.api.http).body": "model", + "(google.api.method_signature)": "parent,model", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.Model", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.CreateModelMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models", + "body": "model" + } + }, + { + "(google.api.method_signature)": "parent,model" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.Model", + "metadata_type": "google.cloud.retail.v2beta.CreateModelMetadata" + } + } + ] + }, + "PauseModel": { + "requestType": "PauseModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:pause", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:pause", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ResumeModel": { + "requestType": "ResumeModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:resume", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:resume", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "DeleteModel": { + "requestType": "DeleteModelRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListModels": { + "requestType": "ListModelsRequest", + "responseType": "ListModelsResponse", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateModel": { + "requestType": "UpdateModelRequest", + "responseType": "Model", + "options": { + "(google.api.http).patch": "/v2beta/{model.name=projects/*/locations/*/catalogs/*/models/*}", + "(google.api.http).body": "model", + "(google.api.method_signature)": "model,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{model.name=projects/*/locations/*/catalogs/*/models/*}", + "body": "model" + } + }, + { + "(google.api.method_signature)": "model,update_mask" + } + ] + }, + "TuneModel": { + "requestType": "TuneModelRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:tune", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.TuneModelResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.TuneModelMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:tune", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.TuneModelResponse", + "metadata_type": "google.cloud.retail.v2beta.TuneModelMetadata" + } + } + ] + } + } + }, + "CreateModelRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "model": { + "type": "Model", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "dryRun": { + "type": "bool", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "UpdateModelRequest": { + "fields": { + "model": { + "type": "Model", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "PauseModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "ResumeModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ListModelsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "DeleteModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "ListModelsResponse": { + "fields": { + "models": { + "rule": "repeated", + "type": "Model", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "TuneModelRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Model" + } + } + } + }, + "CreateModelMetadata": { + "fields": { + "model": { + "type": "string", + "id": 1 + } + } + }, + "TuneModelMetadata": { + "fields": { + "model": { + "type": "string", + "id": 1 + } + } + }, + "TuneModelResponse": { + "fields": {} + }, + "PredictionService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "Predict": { + "requestType": "PredictRequest", + "responseType": "PredictResponse", + "options": { + "(google.api.http).post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "(google.api.http).additional_bindings.body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/placements/*}:predict", + "body": "*", + "additional_bindings": { + "post": "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict", + "body": "*" + } + } + } + ] + } + } + }, + "PredictRequest": { + "fields": { + "placement": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "pageSize": { + "type": "int32", + "id": 3 + }, + "pageToken": { + "type": "string", + "id": 4, + "options": { + "deprecated": true + } + }, + "filter": { + "type": "string", + "id": 5 + }, + "validateOnly": { + "type": "bool", + "id": 6 + }, + "params": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 7 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 8 + } + } + }, + "PredictResponse": { + "fields": { + "results": { + "rule": "repeated", + "type": "PredictionResult", + "id": 1 + }, + "attributionToken": { + "type": "string", + "id": 2 + }, + "missingIds": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "validateOnly": { + "type": "bool", + "id": 4 + } + }, + "nested": { + "PredictionResult": { + "fields": { + "id": { + "type": "string", + "id": 1 + }, + "metadata": { + "keyType": "string", + "type": "google.protobuf.Value", + "id": 2 + } + } + } + } + }, + "ProductService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateProduct": { + "requestType": "CreateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.http).body": "product", + "(google.api.method_signature)": "parent,product,product_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "body": "product" + } + }, + { + "(google.api.method_signature)": "parent,product,product_id" + } + ] + }, + "GetProduct": { + "requestType": "GetProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).get": "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListProducts": { + "requestType": "ListProductsRequest", + "responseType": "ListProductsResponse", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateProduct": { + "requestType": "UpdateProductRequest", + "responseType": "Product", + "options": { + "(google.api.http).patch": "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.http).body": "product", + "(google.api.method_signature)": "product,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{product.name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "body": "product" + } + }, + { + "(google.api.method_signature)": "product,update_mask" + } + ] + }, + "DeleteProduct": { + "requestType": "DeleteProductRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/products/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ImportProducts": { + "requestType": "ImportProductsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.ImportProductsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*/branches/*}/products:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.ImportProductsResponse", + "metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + } + } + ] + }, + "SetInventory": { + "requestType": "SetInventoryRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "(google.api.http).body": "*", + "(google.api.method_signature)": "inventory,set_mask", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.SetInventoryResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.SetInventoryMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{inventory.name=projects/*/locations/*/catalogs/*/branches/*/products/**}:setInventory", + "body": "*" + } + }, + { + "(google.api.method_signature)": "inventory,set_mask" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.SetInventoryResponse", + "metadata_type": "google.cloud.retail.v2beta.SetInventoryMetadata" + } + } + ] + }, + "AddFulfillmentPlaces": { + "requestType": "AddFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.AddFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata" + } + } + ] + }, + "RemoveFulfillmentPlaces": { + "requestType": "RemoveFulfillmentPlacesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeFulfillmentPlaces", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse", + "metadata_type": "google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata" + } + } + ] + }, + "AddLocalInventories": { + "requestType": "AddLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.AddLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:addLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.AddLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2beta.AddLocalInventoriesMetadata" + } + } + ] + }, + "RemoveLocalInventories": { + "requestType": "RemoveLocalInventoriesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "(google.api.http).body": "*", + "(google.api.method_signature)": "product", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{product=projects/*/locations/*/catalogs/*/branches/*/products/**}:removeLocalInventories", + "body": "*" + } + }, + { + "(google.api.method_signature)": "product" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.RemoveLocalInventoriesResponse", + "metadata_type": "google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata" + } + } + ] + } + } + }, + "CreateProductRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "product": { + "type": "Product", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "productId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "UpdateProductRequest": { + "fields": { + "product": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "DeleteProductRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + } + } + }, + "ListProductsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Branch" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "filter": { + "type": "string", + "id": 4 + }, + "readMask": { + "type": "google.protobuf.FieldMask", + "id": 5 + } + } + }, + "ListProductsResponse": { + "fields": { + "products": { + "rule": "repeated", + "type": "Product", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "SetInventoryRequest": { + "fields": { + "inventory": { + "type": "Product", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "setMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + }, + "setTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + }, + "allowMissing": { + "type": "bool", + "id": 4 + } + } + }, + "SetInventoryMetadata": { + "fields": {} + }, + "SetInventoryResponse": { + "fields": {} + }, + "AddFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "AddFulfillmentPlacesMetadata": { + "fields": {} + }, + "AddFulfillmentPlacesResponse": { + "fields": {} + }, + "AddLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "localInventories": { + "rule": "repeated", + "type": "LocalInventory", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "addMask": { + "type": "google.protobuf.FieldMask", + "id": 4 + }, + "addTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 6 + } + } + }, + "AddLocalInventoriesMetadata": { + "fields": {} + }, + "AddLocalInventoriesResponse": { + "fields": {} + }, + "RemoveLocalInventoriesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "allowMissing": { + "type": "bool", + "id": 3 + } + } + }, + "RemoveLocalInventoriesMetadata": { + "fields": {} + }, + "RemoveLocalInventoriesResponse": { + "fields": {} + }, + "RemoveFulfillmentPlacesRequest": { + "fields": { + "product": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Product" + } + }, + "type": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "placeIds": { + "rule": "repeated", + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "removeTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + }, + "allowMissing": { + "type": "bool", + "id": 5 + } + } + }, + "RemoveFulfillmentPlacesMetadata": { + "fields": {} + }, + "RemoveFulfillmentPlacesResponse": { + "fields": {} + }, + "PurgeMetadata": { + "fields": {} + }, + "PurgeUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "filter": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "force": { + "type": "bool", + "id": 3 + } + } + }, + "PurgeUserEventsResponse": { + "fields": { + "purgedEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "ServingConfig": { + "options": { + "(google.api.resource).type": "retail.googleapis.com/ServingConfig", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }, + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + }, + "displayName": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "modelId": { + "type": "string", + "id": 3 + }, + "priceRerankingLevel": { + "type": "string", + "id": 4 + }, + "facetControlIds": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "dynamicFacetSpec": { + "type": "SearchRequest.DynamicFacetSpec", + "id": 6 + }, + "boostControlIds": { + "rule": "repeated", + "type": "string", + "id": 7 + }, + "filterControlIds": { + "rule": "repeated", + "type": "string", + "id": 9 + }, + "redirectControlIds": { + "rule": "repeated", + "type": "string", + "id": 10 + }, + "twowaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 18 + }, + "onewaySynonymsControlIds": { + "rule": "repeated", + "type": "string", + "id": 12 + }, + "doNotAssociateControlIds": { + "rule": "repeated", + "type": "string", + "id": 13 + }, + "replacementControlIds": { + "rule": "repeated", + "type": "string", + "id": 14 + }, + "ignoreControlIds": { + "rule": "repeated", + "type": "string", + "id": 15 + }, + "diversityLevel": { + "type": "string", + "id": 8 + }, + "diversityType": { + "type": "DiversityType", + "id": 20 + }, + "enableCategoryFilterLevel": { + "type": "string", + "id": 16 + }, + "personalizationSpec": { + "type": "SearchRequest.PersonalizationSpec", + "id": 21 + }, + "solutionTypes": { + "rule": "repeated", + "type": "SolutionType", + "id": 19, + "options": { + "(google.api.field_behavior)": "IMMUTABLE" + } + } + }, + "nested": { + "DiversityType": { + "values": { + "DIVERSITY_TYPE_UNSPECIFIED": 0, + "RULE_BASED_DIVERSITY": 2, + "DATA_DRIVEN_DIVERSITY": 3 + } + } + } + }, + "ServingConfigService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateServingConfig": { + "requestType": "CreateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "parent,serving_config,serving_config_id" + } + ] + }, + "DeleteServingConfig": { + "requestType": "DeleteServingConfigRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "UpdateServingConfig": { + "requestType": "UpdateServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).patch": "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.http).body": "serving_config", + "(google.api.method_signature)": "serving_config,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v2beta/{serving_config.name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "body": "serving_config" + } + }, + { + "(google.api.method_signature)": "serving_config,update_mask" + } + ] + }, + "GetServingConfig": { + "requestType": "GetServingConfigRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).get": "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListServingConfigs": { + "requestType": "ListServingConfigsRequest", + "responseType": "ListServingConfigsResponse", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/servingConfigs" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "AddControl": { + "requestType": "AddControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:addControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + }, + "RemoveControl": { + "requestType": "RemoveControlRequest", + "responseType": "ServingConfig", + "options": { + "(google.api.http).post": "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "(google.api.http).body": "*", + "(google.api.method_signature)": "serving_config" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{serving_config=projects/*/locations/*/catalogs/*/servingConfigs/*}:removeControl", + "body": "*" + } + }, + { + "(google.api.method_signature)": "serving_config" + } + ] + } + } + }, + "CreateServingConfigRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "servingConfig": { + "type": "ServingConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "servingConfigId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateServingConfigRequest": { + "fields": { + "servingConfig": { + "type": "ServingConfig", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "DeleteServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "GetServingConfigRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + } + } + }, + "ListServingConfigsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/Catalog" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ListServingConfigsResponse": { + "fields": { + "servingConfigs": { + "rule": "repeated", + "type": "ServingConfig", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "AddControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RemoveControlRequest": { + "fields": { + "servingConfig": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "retail.googleapis.com/ServingConfig" + } + }, + "controlId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UserEventService": { + "options": { + "(google.api.default_host)": "retail.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "WriteUserEvent": { + "requestType": "WriteUserEventRequest", + "responseType": "UserEvent", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "(google.api.http).body": "user_event" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:write", + "body": "user_event" + } + } + ] + }, + "CollectUserEvent": { + "requestType": "CollectUserEventRequest", + "responseType": "google.api.HttpBody", + "options": { + "(google.api.http).get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect" + } + } + ] + }, + "PurgeUserEvents": { + "requestType": "PurgeUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.PurgeUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.PurgeMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:purge", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.PurgeUserEventsResponse", + "metadata_type": "google.cloud.retail.v2beta.PurgeMetadata" + } + } + ] + }, + "ImportUserEvents": { + "requestType": "ImportUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2beta.ImportUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:import", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.cloud.retail.v2beta.ImportUserEventsResponse", + "metadata_type": "google.cloud.retail.v2beta.ImportMetadata" + } + } + ] + }, + "RejoinUserEvents": { + "requestType": "RejoinUserEventsRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "(google.api.http).body": "*", + "(google.longrunning.operation_info).response_type": "RejoinUserEventsResponse", + "(google.longrunning.operation_info).metadata_type": "RejoinUserEventsMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v2beta/{parent=projects/*/locations/*/catalogs/*}/userEvents:rejoin", + "body": "*" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "RejoinUserEventsResponse", + "metadata_type": "RejoinUserEventsMetadata" + } + } + ] + } + } + }, + "WriteUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "UserEvent", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "CollectUserEventRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEvent": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "uri": { + "type": "string", + "id": 3 + }, + "ets": { + "type": "int64", + "id": 4 + } + } + }, + "RejoinUserEventsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "userEventRejoinScope": { + "type": "UserEventRejoinScope", + "id": 2 + } + }, + "nested": { + "UserEventRejoinScope": { + "values": { + "USER_EVENT_REJOIN_SCOPE_UNSPECIFIED": 0, + "JOINED_EVENTS": 1, + "UNJOINED_EVENTS": 2 + } + } + } + }, + "RejoinUserEventsResponse": { + "fields": { + "rejoinedUserEventsCount": { + "type": "int64", + "id": 1 + } + } + }, + "RejoinUserEventsMetadata": { + "fields": {} + } + } + } + } + } + } + }, + "api": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/api/httpbody;httpbody", + "java_multiple_files": true, + "java_outer_classname": "HttpBodyProto", + "java_package": "com.google.api", + "objc_class_prefix": "GAPI", + "cc_enable_arenas": true + }, + "nested": { + "fieldBehavior": { + "rule": "repeated", + "type": "google.api.FieldBehavior", + "id": 1052, + "extend": "google.protobuf.FieldOptions" + }, + "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 + } + }, + "resourceReference": { + "type": "google.api.ResourceReference", + "id": 1055, + "extend": "google.protobuf.FieldOptions" + }, + "resourceDefinition": { + "rule": "repeated", + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.FileOptions" + }, + "resource": { + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.MessageOptions" + }, + "ResourceDescriptor": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "pattern": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "nameField": { + "type": "string", + "id": 3 + }, + "history": { + "type": "History", + "id": 4 + }, + "plural": { + "type": "string", + "id": 5 + }, + "singular": { + "type": "string", + "id": 6 + }, + "style": { + "rule": "repeated", + "type": "Style", + "id": 10 + } + }, + "nested": { + "History": { + "values": { + "HISTORY_UNSPECIFIED": 0, + "ORIGINALLY_SINGLE_PATTERN": 1, + "FUTURE_MULTI_PATTERN": 2 + } + }, + "Style": { + "values": { + "STYLE_UNSPECIFIED": 0, + "DECLARATIVE_FRIENDLY": 1 + } + } + } + }, + "ResourceReference": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "childType": { + "type": "string", + "id": 2 + } + } + }, + "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" + }, + "HttpBody": { + "fields": { + "contentType": { + "type": "string", + "id": 1 + }, + "data": { + "type": "bytes", + "id": 2 + }, + "extensions": { + "rule": "repeated", + "type": "google.protobuf.Any", + "id": 3 + } + } + } + } + }, + "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 + } + } + }, + "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 + } + }, + "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": "string", + "id": 13 + } + } + }, + "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 + } + }, + "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 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "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_REQUIRED": 2, + "LABEL_REPEATED": 3 + } + } + } + }, + "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 + } + }, + "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 + } + }, + "phpGenericServices": { + "type": "bool", + "id": 42, + "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 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 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 + }, + "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 + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 4, + 4 + ] + ], + "nested": { + "CType": { + "values": { + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2 + } + }, + "JSType": { + "values": { + "JS_NORMAL": 0, + "JS_STRING": 1, + "JS_NUMBER": 2 + } + } + } + }, + "OneofOptions": { + "fields": { + "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 + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 5, + 5 + ] + ] + }, + "EnumValueOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "ServiceOptions": { + "fields": { + "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" + } + }, + "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 + } + } + } + } + }, + "SourceCodeInfo": { + "fields": { + "location": { + "rule": "repeated", + "type": "Location", + "id": 1 + } + }, + "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 + } + } + } + } + } + }, + "Timestamp": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, + "Duration": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, + "FieldMask": { + "fields": { + "paths": { + "rule": "repeated", + "type": "string", + "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 + } + } + }, + "Any": { + "fields": { + "type_url": { + "type": "string", + "id": 1 + }, + "value": { + "type": "bytes", + "id": 2 + } + } + }, + "Empty": { + "fields": {} + }, + "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 + } + } + } + } + }, + "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/date;date", + "java_multiple_files": true, + "java_outer_classname": "DateProto", + "java_package": "com.google.type", + "objc_class_prefix": "GTP" + }, + "nested": { + "Date": { + "fields": { + "year": { + "type": "int32", + "id": 1 + }, + "month": { + "type": "int32", + "id": 2 + }, + "day": { + "type": "int32", + "id": 3 + } + } + } + } + }, + "longrunning": { + "options": { + "cc_enable_arenas": true, + "csharp_namespace": "Google.LongRunning", + "go_package": "google.golang.org/genproto/googleapis/longrunning;longrunning", + "java_multiple_files": true, + "java_outer_classname": "OperationsProto", + "java_package": "com.google.longrunning", + "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 + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/packages/google-cloud-retail/samples/README.md b/packages/google-cloud-retail/samples/README.md new file mode 100644 index 00000000000..ccdc4ee0229 --- /dev/null +++ b/packages/google-cloud-retail/samples/README.md @@ -0,0 +1,2678 @@ +[//]: # "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 + +# [Retail API: Node.js Samples](https://github.com/googleapis/google-cloud-node) + +[![Open in Cloud Shell][shell_img]][shell_link] + + + +## Table of Contents + +* [Before you begin](#before-you-begin) +* [Samples](#samples) + * [Catalog_service.add_catalog_attribute](#catalog_service.add_catalog_attribute) + * [Catalog_service.get_attributes_config](#catalog_service.get_attributes_config) + * [Catalog_service.get_completion_config](#catalog_service.get_completion_config) + * [Catalog_service.get_default_branch](#catalog_service.get_default_branch) + * [Catalog_service.list_catalogs](#catalog_service.list_catalogs) + * [Catalog_service.remove_catalog_attribute](#catalog_service.remove_catalog_attribute) + * [Catalog_service.replace_catalog_attribute](#catalog_service.replace_catalog_attribute) + * [Catalog_service.set_default_branch](#catalog_service.set_default_branch) + * [Catalog_service.update_attributes_config](#catalog_service.update_attributes_config) + * [Catalog_service.update_catalog](#catalog_service.update_catalog) + * [Catalog_service.update_completion_config](#catalog_service.update_completion_config) + * [Completion_service.complete_query](#completion_service.complete_query) + * [Completion_service.import_completion_data](#completion_service.import_completion_data) + * [Control_service.create_control](#control_service.create_control) + * [Control_service.delete_control](#control_service.delete_control) + * [Control_service.get_control](#control_service.get_control) + * [Control_service.list_controls](#control_service.list_controls) + * [Control_service.update_control](#control_service.update_control) + * [Prediction_service.predict](#prediction_service.predict) + * [Product_service.add_fulfillment_places](#product_service.add_fulfillment_places) + * [Product_service.add_local_inventories](#product_service.add_local_inventories) + * [Product_service.create_product](#product_service.create_product) + * [Product_service.delete_product](#product_service.delete_product) + * [Product_service.get_product](#product_service.get_product) + * [Product_service.import_products](#product_service.import_products) + * [Product_service.list_products](#product_service.list_products) + * [Product_service.remove_fulfillment_places](#product_service.remove_fulfillment_places) + * [Product_service.remove_local_inventories](#product_service.remove_local_inventories) + * [Product_service.set_inventory](#product_service.set_inventory) + * [Product_service.update_product](#product_service.update_product) + * [Search_service.search](#search_service.search) + * [Serving_config_service.add_control](#serving_config_service.add_control) + * [Serving_config_service.create_serving_config](#serving_config_service.create_serving_config) + * [Serving_config_service.delete_serving_config](#serving_config_service.delete_serving_config) + * [Serving_config_service.get_serving_config](#serving_config_service.get_serving_config) + * [Serving_config_service.list_serving_configs](#serving_config_service.list_serving_configs) + * [Serving_config_service.remove_control](#serving_config_service.remove_control) + * [Serving_config_service.update_serving_config](#serving_config_service.update_serving_config) + * [User_event_service.collect_user_event](#user_event_service.collect_user_event) + * [User_event_service.import_user_events](#user_event_service.import_user_events) + * [User_event_service.purge_user_events](#user_event_service.purge_user_events) + * [User_event_service.rejoin_user_events](#user_event_service.rejoin_user_events) + * [User_event_service.write_user_event](#user_event_service.write_user_event) + * [Catalog_service.add_catalog_attribute](#catalog_service.add_catalog_attribute) + * [Catalog_service.get_attributes_config](#catalog_service.get_attributes_config) + * [Catalog_service.get_completion_config](#catalog_service.get_completion_config) + * [Catalog_service.get_default_branch](#catalog_service.get_default_branch) + * [Catalog_service.list_catalogs](#catalog_service.list_catalogs) + * [Catalog_service.remove_catalog_attribute](#catalog_service.remove_catalog_attribute) + * [Catalog_service.replace_catalog_attribute](#catalog_service.replace_catalog_attribute) + * [Catalog_service.set_default_branch](#catalog_service.set_default_branch) + * [Catalog_service.update_attributes_config](#catalog_service.update_attributes_config) + * [Catalog_service.update_catalog](#catalog_service.update_catalog) + * [Catalog_service.update_completion_config](#catalog_service.update_completion_config) + * [Completion_service.complete_query](#completion_service.complete_query) + * [Completion_service.import_completion_data](#completion_service.import_completion_data) + * [Control_service.create_control](#control_service.create_control) + * [Control_service.delete_control](#control_service.delete_control) + * [Control_service.get_control](#control_service.get_control) + * [Control_service.list_controls](#control_service.list_controls) + * [Control_service.update_control](#control_service.update_control) + * [Model_service.create_model](#model_service.create_model) + * [Model_service.delete_model](#model_service.delete_model) + * [Model_service.list_models](#model_service.list_models) + * [Model_service.pause_model](#model_service.pause_model) + * [Model_service.resume_model](#model_service.resume_model) + * [Model_service.tune_model](#model_service.tune_model) + * [Model_service.update_model](#model_service.update_model) + * [Prediction_service.predict](#prediction_service.predict) + * [Product_service.add_fulfillment_places](#product_service.add_fulfillment_places) + * [Product_service.add_local_inventories](#product_service.add_local_inventories) + * [Product_service.create_product](#product_service.create_product) + * [Product_service.delete_product](#product_service.delete_product) + * [Product_service.get_product](#product_service.get_product) + * [Product_service.import_products](#product_service.import_products) + * [Product_service.list_products](#product_service.list_products) + * [Product_service.purge_products](#product_service.purge_products) + * [Product_service.remove_fulfillment_places](#product_service.remove_fulfillment_places) + * [Product_service.remove_local_inventories](#product_service.remove_local_inventories) + * [Product_service.set_inventory](#product_service.set_inventory) + * [Product_service.update_product](#product_service.update_product) + * [Search_service.search](#search_service.search) + * [Serving_config_service.add_control](#serving_config_service.add_control) + * [Serving_config_service.create_serving_config](#serving_config_service.create_serving_config) + * [Serving_config_service.delete_serving_config](#serving_config_service.delete_serving_config) + * [Serving_config_service.get_serving_config](#serving_config_service.get_serving_config) + * [Serving_config_service.list_serving_configs](#serving_config_service.list_serving_configs) + * [Serving_config_service.remove_control](#serving_config_service.remove_control) + * [Serving_config_service.update_serving_config](#serving_config_service.update_serving_config) + * [User_event_service.collect_user_event](#user_event_service.collect_user_event) + * [User_event_service.import_user_events](#user_event_service.import_user_events) + * [User_event_service.purge_user_events](#user_event_service.purge_user_events) + * [User_event_service.rejoin_user_events](#user_event_service.rejoin_user_events) + * [User_event_service.write_user_event](#user_event_service.write_user_event) + * [Catalog_service.add_catalog_attribute](#catalog_service.add_catalog_attribute) + * [Catalog_service.batch_remove_catalog_attributes](#catalog_service.batch_remove_catalog_attributes) + * [Catalog_service.get_attributes_config](#catalog_service.get_attributes_config) + * [Catalog_service.get_completion_config](#catalog_service.get_completion_config) + * [Catalog_service.get_default_branch](#catalog_service.get_default_branch) + * [Catalog_service.list_catalogs](#catalog_service.list_catalogs) + * [Catalog_service.remove_catalog_attribute](#catalog_service.remove_catalog_attribute) + * [Catalog_service.replace_catalog_attribute](#catalog_service.replace_catalog_attribute) + * [Catalog_service.set_default_branch](#catalog_service.set_default_branch) + * [Catalog_service.update_attributes_config](#catalog_service.update_attributes_config) + * [Catalog_service.update_catalog](#catalog_service.update_catalog) + * [Catalog_service.update_completion_config](#catalog_service.update_completion_config) + * [Completion_service.complete_query](#completion_service.complete_query) + * [Completion_service.import_completion_data](#completion_service.import_completion_data) + * [Control_service.create_control](#control_service.create_control) + * [Control_service.delete_control](#control_service.delete_control) + * [Control_service.get_control](#control_service.get_control) + * [Control_service.list_controls](#control_service.list_controls) + * [Control_service.update_control](#control_service.update_control) + * [Model_service.create_model](#model_service.create_model) + * [Model_service.delete_model](#model_service.delete_model) + * [Model_service.list_models](#model_service.list_models) + * [Model_service.pause_model](#model_service.pause_model) + * [Model_service.resume_model](#model_service.resume_model) + * [Model_service.tune_model](#model_service.tune_model) + * [Model_service.update_model](#model_service.update_model) + * [Prediction_service.predict](#prediction_service.predict) + * [Product_service.add_fulfillment_places](#product_service.add_fulfillment_places) + * [Product_service.add_local_inventories](#product_service.add_local_inventories) + * [Product_service.create_product](#product_service.create_product) + * [Product_service.delete_product](#product_service.delete_product) + * [Product_service.get_product](#product_service.get_product) + * [Product_service.import_products](#product_service.import_products) + * [Product_service.list_products](#product_service.list_products) + * [Product_service.remove_fulfillment_places](#product_service.remove_fulfillment_places) + * [Product_service.remove_local_inventories](#product_service.remove_local_inventories) + * [Product_service.set_inventory](#product_service.set_inventory) + * [Product_service.update_product](#product_service.update_product) + * [Search_service.search](#search_service.search) + * [Serving_config_service.add_control](#serving_config_service.add_control) + * [Serving_config_service.create_serving_config](#serving_config_service.create_serving_config) + * [Serving_config_service.delete_serving_config](#serving_config_service.delete_serving_config) + * [Serving_config_service.get_serving_config](#serving_config_service.get_serving_config) + * [Serving_config_service.list_serving_configs](#serving_config_service.list_serving_configs) + * [Serving_config_service.remove_control](#serving_config_service.remove_control) + * [Serving_config_service.update_serving_config](#serving_config_service.update_serving_config) + * [User_event_service.collect_user_event](#user_event_service.collect_user_event) + * [User_event_service.import_user_events](#user_event_service.import_user_events) + * [User_event_service.purge_user_events](#user_event_service.purge_user_events) + * [User_event_service.rejoin_user_events](#user_event_service.rejoin_user_events) + * [User_event_service.write_user_event](#user_event_service.write_user_event) + * [Quickstart](#quickstart) + * [Quickstart](#quickstart) + +## Before you begin + +Before running the samples, make sure you've followed the steps outlined in +[Using the client library](https://github.com/googleapis/google-cloud-node#using-the-client-library). + +`cd samples` + +`npm install` + +`cd ..` + +## Samples + + + +### Catalog_service.add_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.add_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.add_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.add_catalog_attribute.js` + + +----- + + + + +### Catalog_service.get_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.get_attributes_config.js` + + +----- + + + + +### Catalog_service.get_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.get_completion_config.js` + + +----- + + + + +### Catalog_service.get_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.get_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.get_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.get_default_branch.js` + + +----- + + + + +### Catalog_service.list_catalogs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.list_catalogs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.list_catalogs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.list_catalogs.js` + + +----- + + + + +### Catalog_service.remove_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.remove_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.remove_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.remove_catalog_attribute.js` + + +----- + + + + +### Catalog_service.replace_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.replace_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.replace_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.replace_catalog_attribute.js` + + +----- + + + + +### Catalog_service.set_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.set_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.set_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.set_default_branch.js` + + +----- + + + + +### Catalog_service.update_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.update_attributes_config.js` + + +----- + + + + +### Catalog_service.update_catalog + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_catalog.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_catalog.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.update_catalog.js` + + +----- + + + + +### Catalog_service.update_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/catalog_service.update_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/catalog_service.update_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/catalog_service.update_completion_config.js` + + +----- + + + + +### Completion_service.complete_query + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/completion_service.complete_query.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/completion_service.complete_query.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/completion_service.complete_query.js` + + +----- + + + + +### Completion_service.import_completion_data + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/completion_service.import_completion_data.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/completion_service.import_completion_data.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/completion_service.import_completion_data.js` + + +----- + + + + +### Control_service.create_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.create_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.create_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/control_service.create_control.js` + + +----- + + + + +### Control_service.delete_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.delete_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.delete_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/control_service.delete_control.js` + + +----- + + + + +### Control_service.get_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.get_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.get_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/control_service.get_control.js` + + +----- + + + + +### Control_service.list_controls + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.list_controls.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.list_controls.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/control_service.list_controls.js` + + +----- + + + + +### Control_service.update_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/control_service.update_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/control_service.update_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/control_service.update_control.js` + + +----- + + + + +### Prediction_service.predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/prediction_service.predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/prediction_service.predict.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/prediction_service.predict.js` + + +----- + + + + +### Product_service.add_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.add_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.add_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.add_fulfillment_places.js` + + +----- + + + + +### Product_service.add_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.add_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.add_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.add_local_inventories.js` + + +----- + + + + +### Product_service.create_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.create_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.create_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.create_product.js` + + +----- + + + + +### Product_service.delete_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.delete_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.delete_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.delete_product.js` + + +----- + + + + +### Product_service.get_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.get_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.get_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.get_product.js` + + +----- + + + + +### Product_service.import_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.import_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.import_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.import_products.js` + + +----- + + + + +### Product_service.list_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.list_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.list_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.list_products.js` + + +----- + + + + +### Product_service.remove_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.remove_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.remove_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.remove_fulfillment_places.js` + + +----- + + + + +### Product_service.remove_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.remove_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.remove_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.remove_local_inventories.js` + + +----- + + + + +### Product_service.set_inventory + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.set_inventory.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.set_inventory.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.set_inventory.js` + + +----- + + + + +### Product_service.update_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/product_service.update_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/product_service.update_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/product_service.update_product.js` + + +----- + + + + +### Search_service.search + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/search_service.search.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/search_service.search.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/search_service.search.js` + + +----- + + + + +### Serving_config_service.add_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.add_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.add_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.add_control.js` + + +----- + + + + +### Serving_config_service.create_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.create_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.create_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.create_serving_config.js` + + +----- + + + + +### Serving_config_service.delete_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.delete_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.delete_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.delete_serving_config.js` + + +----- + + + + +### Serving_config_service.get_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.get_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.get_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.get_serving_config.js` + + +----- + + + + +### Serving_config_service.list_serving_configs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.list_serving_configs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.list_serving_configs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.list_serving_configs.js` + + +----- + + + + +### Serving_config_service.remove_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.remove_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.remove_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.remove_control.js` + + +----- + + + + +### Serving_config_service.update_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/serving_config_service.update_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/serving_config_service.update_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/serving_config_service.update_serving_config.js` + + +----- + + + + +### User_event_service.collect_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.collect_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.collect_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/user_event_service.collect_user_event.js` + + +----- + + + + +### User_event_service.import_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.import_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.import_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/user_event_service.import_user_events.js` + + +----- + + + + +### User_event_service.purge_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.purge_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.purge_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/user_event_service.purge_user_events.js` + + +----- + + + + +### User_event_service.rejoin_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.rejoin_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.rejoin_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/user_event_service.rejoin_user_events.js` + + +----- + + + + +### User_event_service.write_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2/user_event_service.write_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2/user_event_service.write_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2/user_event_service.write_user_event.js` + + +----- + + + + +### Catalog_service.add_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js` + + +----- + + + + +### Catalog_service.get_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_attributes_config.js` + + +----- + + + + +### Catalog_service.get_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_completion_config.js` + + +----- + + + + +### Catalog_service.get_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.get_default_branch.js` + + +----- + + + + +### Catalog_service.list_catalogs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.list_catalogs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.list_catalogs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.list_catalogs.js` + + +----- + + + + +### Catalog_service.remove_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js` + + +----- + + + + +### Catalog_service.replace_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js` + + +----- + + + + +### Catalog_service.set_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.set_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.set_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.set_default_branch.js` + + +----- + + + + +### Catalog_service.update_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_attributes_config.js` + + +----- + + + + +### Catalog_service.update_catalog + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_catalog.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_catalog.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_catalog.js` + + +----- + + + + +### Catalog_service.update_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/catalog_service.update_completion_config.js` + + +----- + + + + +### Completion_service.complete_query + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/completion_service.complete_query.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/completion_service.complete_query.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/completion_service.complete_query.js` + + +----- + + + + +### Completion_service.import_completion_data + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/completion_service.import_completion_data.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/completion_service.import_completion_data.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/completion_service.import_completion_data.js` + + +----- + + + + +### Control_service.create_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.create_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.create_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/control_service.create_control.js` + + +----- + + + + +### Control_service.delete_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.delete_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.delete_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/control_service.delete_control.js` + + +----- + + + + +### Control_service.get_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.get_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.get_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/control_service.get_control.js` + + +----- + + + + +### Control_service.list_controls + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.list_controls.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.list_controls.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/control_service.list_controls.js` + + +----- + + + + +### Control_service.update_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/control_service.update_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/control_service.update_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/control_service.update_control.js` + + +----- + + + + +### Model_service.create_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.create_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.create_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.create_model.js` + + +----- + + + + +### Model_service.delete_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.delete_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.delete_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.delete_model.js` + + +----- + + + + +### Model_service.list_models + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.list_models.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.list_models.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.list_models.js` + + +----- + + + + +### Model_service.pause_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.pause_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.pause_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.pause_model.js` + + +----- + + + + +### Model_service.resume_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.resume_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.resume_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.resume_model.js` + + +----- + + + + +### Model_service.tune_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.tune_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.tune_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.tune_model.js` + + +----- + + + + +### Model_service.update_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/model_service.update_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/model_service.update_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/model_service.update_model.js` + + +----- + + + + +### Prediction_service.predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/prediction_service.predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/prediction_service.predict.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/prediction_service.predict.js` + + +----- + + + + +### Product_service.add_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_fulfillment_places.js` + + +----- + + + + +### Product_service.add_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.add_local_inventories.js` + + +----- + + + + +### Product_service.create_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.create_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.create_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.create_product.js` + + +----- + + + + +### Product_service.delete_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.delete_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.delete_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.delete_product.js` + + +----- + + + + +### Product_service.get_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.get_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.get_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.get_product.js` + + +----- + + + + +### Product_service.import_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.import_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.import_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.import_products.js` + + +----- + + + + +### Product_service.list_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.list_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.list_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.list_products.js` + + +----- + + + + +### Product_service.purge_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.purge_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.purge_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.purge_products.js` + + +----- + + + + +### Product_service.remove_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_fulfillment_places.js` + + +----- + + + + +### Product_service.remove_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.remove_local_inventories.js` + + +----- + + + + +### Product_service.set_inventory + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.set_inventory.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.set_inventory.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.set_inventory.js` + + +----- + + + + +### Product_service.update_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/product_service.update_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/product_service.update_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/product_service.update_product.js` + + +----- + + + + +### Search_service.search + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/search_service.search.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/search_service.search.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/search_service.search.js` + + +----- + + + + +### Serving_config_service.add_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.add_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.add_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.add_control.js` + + +----- + + + + +### Serving_config_service.create_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.create_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.create_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.create_serving_config.js` + + +----- + + + + +### Serving_config_service.delete_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.delete_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.delete_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.delete_serving_config.js` + + +----- + + + + +### Serving_config_service.get_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.get_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.get_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.get_serving_config.js` + + +----- + + + + +### Serving_config_service.list_serving_configs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.list_serving_configs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.list_serving_configs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.list_serving_configs.js` + + +----- + + + + +### Serving_config_service.remove_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.remove_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.remove_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.remove_control.js` + + +----- + + + + +### Serving_config_service.update_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.update_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.update_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/serving_config_service.update_serving_config.js` + + +----- + + + + +### User_event_service.collect_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.collect_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.collect_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.collect_user_event.js` + + +----- + + + + +### User_event_service.import_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.import_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.import_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.import_user_events.js` + + +----- + + + + +### User_event_service.purge_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.purge_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.purge_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.purge_user_events.js` + + +----- + + + + +### User_event_service.rejoin_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.rejoin_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.rejoin_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.rejoin_user_events.js` + + +----- + + + + +### User_event_service.write_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.write_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.write_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2alpha/user_event_service.write_user_event.js` + + +----- + + + + +### Catalog_service.add_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.add_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.add_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.add_catalog_attribute.js` + + +----- + + + + +### Catalog_service.batch_remove_catalog_attributes + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js` + + +----- + + + + +### Catalog_service.get_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_attributes_config.js` + + +----- + + + + +### Catalog_service.get_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_completion_config.js` + + +----- + + + + +### Catalog_service.get_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.get_default_branch.js` + + +----- + + + + +### Catalog_service.list_catalogs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.list_catalogs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.list_catalogs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.list_catalogs.js` + + +----- + + + + +### Catalog_service.remove_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js` + + +----- + + + + +### Catalog_service.replace_catalog_attribute + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js` + + +----- + + + + +### Catalog_service.set_default_branch + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.set_default_branch.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.set_default_branch.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.set_default_branch.js` + + +----- + + + + +### Catalog_service.update_attributes_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_attributes_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_attributes_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_attributes_config.js` + + +----- + + + + +### Catalog_service.update_catalog + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_catalog.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_catalog.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_catalog.js` + + +----- + + + + +### Catalog_service.update_completion_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_completion_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_completion_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/catalog_service.update_completion_config.js` + + +----- + + + + +### Completion_service.complete_query + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/completion_service.complete_query.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/completion_service.complete_query.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/completion_service.complete_query.js` + + +----- + + + + +### Completion_service.import_completion_data + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/completion_service.import_completion_data.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/completion_service.import_completion_data.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/completion_service.import_completion_data.js` + + +----- + + + + +### Control_service.create_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.create_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.create_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/control_service.create_control.js` + + +----- + + + + +### Control_service.delete_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.delete_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.delete_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/control_service.delete_control.js` + + +----- + + + + +### Control_service.get_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.get_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.get_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/control_service.get_control.js` + + +----- + + + + +### Control_service.list_controls + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.list_controls.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.list_controls.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/control_service.list_controls.js` + + +----- + + + + +### Control_service.update_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/control_service.update_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/control_service.update_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/control_service.update_control.js` + + +----- + + + + +### Model_service.create_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.create_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.create_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.create_model.js` + + +----- + + + + +### Model_service.delete_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.delete_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.delete_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.delete_model.js` + + +----- + + + + +### Model_service.list_models + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.list_models.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.list_models.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.list_models.js` + + +----- + + + + +### Model_service.pause_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.pause_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.pause_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.pause_model.js` + + +----- + + + + +### Model_service.resume_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.resume_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.resume_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.resume_model.js` + + +----- + + + + +### Model_service.tune_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.tune_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.tune_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.tune_model.js` + + +----- + + + + +### Model_service.update_model + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/model_service.update_model.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/model_service.update_model.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/model_service.update_model.js` + + +----- + + + + +### Prediction_service.predict + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/prediction_service.predict.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/prediction_service.predict.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/prediction_service.predict.js` + + +----- + + + + +### Product_service.add_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.add_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.add_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.add_fulfillment_places.js` + + +----- + + + + +### Product_service.add_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.add_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.add_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.add_local_inventories.js` + + +----- + + + + +### Product_service.create_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.create_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.create_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.create_product.js` + + +----- + + + + +### Product_service.delete_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.delete_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.delete_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.delete_product.js` + + +----- + + + + +### Product_service.get_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.get_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.get_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.get_product.js` + + +----- + + + + +### Product_service.import_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.import_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.import_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.import_products.js` + + +----- + + + + +### Product_service.list_products + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.list_products.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.list_products.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.list_products.js` + + +----- + + + + +### Product_service.remove_fulfillment_places + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_fulfillment_places.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_fulfillment_places.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_fulfillment_places.js` + + +----- + + + + +### Product_service.remove_local_inventories + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_local_inventories.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_local_inventories.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.remove_local_inventories.js` + + +----- + + + + +### Product_service.set_inventory + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.set_inventory.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.set_inventory.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.set_inventory.js` + + +----- + + + + +### Product_service.update_product + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/product_service.update_product.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/product_service.update_product.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/product_service.update_product.js` + + +----- + + + + +### Search_service.search + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/search_service.search.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/search_service.search.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/search_service.search.js` + + +----- + + + + +### Serving_config_service.add_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.add_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.add_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.add_control.js` + + +----- + + + + +### Serving_config_service.create_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.create_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.create_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.create_serving_config.js` + + +----- + + + + +### Serving_config_service.delete_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.delete_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.delete_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.delete_serving_config.js` + + +----- + + + + +### Serving_config_service.get_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.get_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.get_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.get_serving_config.js` + + +----- + + + + +### Serving_config_service.list_serving_configs + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.list_serving_configs.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.list_serving_configs.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.list_serving_configs.js` + + +----- + + + + +### Serving_config_service.remove_control + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.remove_control.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.remove_control.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.remove_control.js` + + +----- + + + + +### Serving_config_service.update_serving_config + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.update_serving_config.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.update_serving_config.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/serving_config_service.update_serving_config.js` + + +----- + + + + +### User_event_service.collect_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.collect_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.collect_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/user_event_service.collect_user_event.js` + + +----- + + + + +### User_event_service.import_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.import_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.import_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/user_event_service.import_user_events.js` + + +----- + + + + +### User_event_service.purge_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.purge_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.purge_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/user_event_service.purge_user_events.js` + + +----- + + + + +### User_event_service.rejoin_user_events + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.rejoin_user_events.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.rejoin_user_events.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/user_event_service.rejoin_user_events.js` + + +----- + + + + +### User_event_service.write_user_event + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/generated/v2beta/user_event_service.write_user_event.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/generated/v2beta/user_event_service.write_user_event.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/generated/v2beta/user_event_service.write_user_event.js` + + +----- + + + + +### Quickstart + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/quickstart.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/quickstart.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/quickstart.js` + + +----- + + + + +### Quickstart + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main//workspace/google-cloud-node/samples/test/quickstart.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=/workspace/google-cloud-node/samples/test/quickstart.js,samples/README.md) + +__Usage:__ + + +`node /workspace/google-cloud-node/samples/test/quickstart.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/google-cloud-node&page=editor&open_in_editor=samples/README.md +[product-docs]: https://cloud.google.com/recommendations/ diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.add_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..4386360f55e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2_generated_CatalogService_AddCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The CatalogAttribute google.cloud.retail.v2.CatalogAttribute + * to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..21de131eb6c --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_CatalogService_GetAttributesConfig_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_completion_config.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..93696f792fe --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_CatalogService_GetCompletionConfig_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. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_default_branch.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..e2634590549 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_GetDefaultBranch_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. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.list_catalogs.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..98b2e88691b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_CatalogService_ListCatalogs_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 account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2.Catalog s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2.Catalog s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.remove_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..c9b1893a954 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2_generated_CatalogService_RemoveCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.replace_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..dde0a278a26 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2_generated_CatalogService_ReplaceCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2.CatalogAttribute to update. The + * following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.set_default_branch.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..d5053ff3ada --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2_generated_CatalogService_SetDefaultBranch_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. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2.SetDefaultBranchRequest.force is not set, a + * FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2.SetDefaultBranchRequest.branch_id even + * if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..67b08a13db6 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig) { + // [START retail_v2_generated_CatalogService_UpdateAttributesConfig_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 AttributesConfig google.cloud.retail.v2.AttributesConfig + * to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2.AttributesConfig to update. The + * following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_catalog.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_catalog.js new file mode 100644 index 00000000000..e505ed815c7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog) { + // [START retail_v2_generated_CatalogService_UpdateCatalog_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 Catalog google.cloud.retail.v2.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2.Catalog, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2.Catalog to update does not exist, + * a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_completion_config.js b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..0ff17c7e15b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2_generated_CatalogService_UpdateCompletionConfig_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 CompletionConfig google.cloud.retail.v2.CompletionConfig + * to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2.CompletionConfig to update. The + * following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/completion_service.complete_query.js b/packages/google-cloud-retail/samples/generated/v2/completion_service.complete_query.js new file mode 100644 index 00000000000..cfddc591fa1 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/completion_service.complete_query.js @@ -0,0 +1,122 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2_generated_CompletionService_CompleteQuery_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. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/completion_service.import_completion_data.js b/packages/google-cloud-retail/samples/generated/v2/completion_service.import_completion_data.js new file mode 100644 index 00000000000..c712950649a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_CompletionService_ImportCompletionData_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 catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/control_service.create_control.js b/packages/google-cloud-retail/samples/generated/v2/control_service.create_control.js new file mode 100644 index 00000000000..3d26c4eb157 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, control, controlId) { + // [START retail_v2_generated_ControlService_CreateControl_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. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/control_service.delete_control.js b/packages/google-cloud-retail/samples/generated/v2/control_service.delete_control.js new file mode 100644 index 00000000000..d62a37b0a3c --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ControlService_DeleteControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/control_service.get_control.js b/packages/google-cloud-retail/samples/generated/v2/control_service.get_control.js new file mode 100644 index 00000000000..3131bfcdbc1 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ControlService_GetControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/control_service.list_controls.js b/packages/google-cloud-retail/samples/generated/v2/control_service.list_controls.js new file mode 100644 index 00000000000..7acee0255e5 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_ControlService_ListControls_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 catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/control_service.update_control.js b/packages/google-cloud-retail/samples/generated/v2/control_service.update_control.js new file mode 100644 index 00000000000..b057ce67127 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2_generated_ControlService_UpdateControl_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 Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2.Control to update. The following are NOT + * supported: + * * Control.name google.cloud.retail.v2.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/prediction_service.predict.js b/packages/google-cloud-retail/samples/generated/v2/prediction_service.predict.js new file mode 100644 index 00000000000..1bb9741aa90 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/prediction_service.predict.js @@ -0,0 +1,186 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2_generated_PredictionService_Predict_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. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Managing serving configurations + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * Don't set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id to a + * random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return. Set this property to the number of + * prediction results needed. If zero, the service will choose a reasonable + * default. The maximum allowed value is 100. Values above 100 will be coerced + * to 100. + */ + // const pageSize = 1234 + /** + * This field is not used; leave it unset. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.add_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..f962e98580f --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_AddFulfillmentPlaces_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type. Duplicate + * IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.add_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2/product_service.add_local_inventories.js new file mode 100644 index 00000000000..1fbf3b4ad52 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.add_local_inventories.js @@ -0,0 +1,102 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2_generated_ProductService_AddLocalInventories_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the Product google.cloud.retail.v2.Product is + * created. If set to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.create_product.js b/packages/google-cloud-retail/samples/generated/v2/product_service.create_product.js new file mode 100644 index 00000000000..d8d2771d946 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2_generated_ProductService_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the Product google.cloud.retail.v2.Product, + * which will become the final component of the + * Product.name google.cloud.retail.v2.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2.Product s with the same + * parent google.cloud.retail.v2.CreateProductRequest.parent. Otherwise, an + * ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.delete_product.js b/packages/google-cloud-retail/samples/generated/v2/product_service.delete_product.js new file mode 100644 index 00000000000..1b3bea02a04 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.delete_product.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ProductService_DeleteProduct_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to delete does not exist, + * a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2.Product to delete can neither be a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product with more than one + * variants google.cloud.retail.v2.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.get_product.js b/packages/google-cloud-retail/samples/generated/v2/product_service.get_product.js new file mode 100644 index 00000000000..e6609f40742 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ProductService_GetProduct_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2.Product does not exist, + * a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.import_products.js b/packages/google-cloud-retail/samples/generated/v2/product_service.import_products.js new file mode 100644 index 00000000000..c3071f1fda4 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.import_products.js @@ -0,0 +1,98 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_ProductService_ImportProducts_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. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported `products` to update. If + * not set, all fields are updated. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * ImportProductsRequest.parent google.cloud.retail.v2.ImportProductsRequest.parent. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.list_products.js b/packages/google-cloud-retail/samples/generated/v2/product_service.list_products.js new file mode 100644 index 00000000000..fa4132865c5 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.list_products.js @@ -0,0 +1,133 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_ProductService_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2.Product s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2.ListProductsRequest.filter is unset. + * * List Product.Type.VARIANT google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2.Product s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2.Product.Type.PRIMARY + * Product google.cloud.retail.v2.Product or + * Product.Type.COLLECTION google.cloud.retail.v2.Product.Type.COLLECTION + * Product google.cloud.retail.v2.Product does not exist, a NOT_FOUND error + * is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2.Product to return in the + * responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2.Product.name + * * Product.id google.cloud.retail.v2.Product.id + * * Product.title google.cloud.retail.v2.Product.title + * * Product.uri google.cloud.retail.v2.Product.uri + * * Product.images google.cloud.retail.v2.Product.images + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.brands google.cloud.retail.v2.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2.Product.name is always returned no + * matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.remove_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..1db3f6f4613 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2_generated_ProductService_RemoveFulfillmentPlaces_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.remove_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..e519f38f312 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2_generated_ProductService_RemoveLocalInventories_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. Full resource name of Product google.cloud.retail.v2.Product, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2.Product is created. If set to false, a + * NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.set_inventory.js b/packages/google-cloud-retail/samples/generated/v2/product_service.set_inventory.js new file mode 100644 index 00000000000..9d03711851d --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2_generated_ProductService_SetInventory_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 inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask. + * If + * SetInventoryRequest.inventory.name google.cloud.retail.v2.Product.name + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product named in + * Product.name google.cloud.retail.v2.Product.name, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * If the Product google.cloud.retail.v2.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2.Product.price_info + * * Product.availability google.cloud.retail.v2.Product.availability + * * Product.available_quantity google.cloud.retail.v2.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * ProductService.UpdateProduct google.cloud.retail.v2.ProductService.UpdateProduct + * should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product with name + * Product.name google.cloud.retail.v2.Product.name is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2.Product is created. If set to + * false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/product_service.update_product.js b/packages/google-cloud-retail/samples/generated/v2/product_service.update_product.js new file mode 100644 index 00000000000..fc6253a0b0e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2_generated_ProductService_UpdateProduct_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 product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2.Product, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2.Product to update does not exist + * and + * allow_missing google.cloud.retail.v2.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2.Product is not + * found, a new Product google.cloud.retail.v2.Product will be created. In + * this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/search_service.search.js b/packages/google-cloud-retail/samples/generated/v2/search_service.search.js new file mode 100644 index 00000000000..744714838f9 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/search_service.search.js @@ -0,0 +1,303 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2_generated_SearchService_Search_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * filter google.cloud.retail.v2.SearchRequest.filter and + * page_categories google.cloud.retail.v2.SearchRequest.page_categories. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2.Product s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2.SearchService.Search call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2.SearchService.Search must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if page_token google.cloud.retail.v2.SearchRequest.page_token + * is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2.SearchRequest.filter for + * more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2.Product object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2.ServingConfig.boost_control_ids + * and + * SearchRequest.boost_spec google.cloud.retail.v2.SearchRequest.boost_spec + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2.LocalInventory s attributes. The + * attributes from all the matching + * variant google.cloud.retail.v2.Product.Type.VARIANT + * Product google.cloud.retail.v2.Product s or + * LocalInventory google.cloud.retail.v2.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.local_inventories.attributes google.cloud.retail.v2.LocalInventory.attributes + * map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + * Notice that if both + * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec + * and + * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec + * are set. + * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec + * will override + * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec. + */ + // const personalizationSpec = {} + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.add_control.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.add_control.js new file mode 100644 index 00000000000..0e0ee81f026 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2_generated_ServingConfigService_AddControl_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 source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.create_serving_config.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..5adc3ee4905 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, servingConfig, servingConfigId) { + // [START retail_v2_generated_ServingConfigService_CreateServingConfig_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. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.delete_serving_config.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..b9a3fe649c4 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ServingConfigService_DeleteServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.get_serving_config.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..0aea4a0429c --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2_generated_ServingConfigService_GetServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.list_serving_configs.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..2aa4c4d944d --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_ServingConfigService_ListServingConfigs_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 catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.remove_control.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.remove_control.js new file mode 100644 index 00000000000..2f32073bc1a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2_generated_ServingConfigService_RemoveControl_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 source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/serving_config_service.update_serving_config.js b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..c4ba8ac6acf --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2_generated_ServingConfigService_UpdateServingConfig_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 ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json new file mode 100644 index 00000000000..8273b0d7a5b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -0,0 +1,2139 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "2.1.1", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 114, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2.Control] to update does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls by their parent [Catalog][google.cloud.retail.v2.Catalog].", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 178, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 125, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][]s will be obsolete after 1 day, and [GetOperation][] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][]s associated with the stale updates will not be marked as [done][Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][]s will be obsolete after 1 day, and [GetOperation][] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][]s associated with the stale updates will not be marked as [done][Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][]s will be obsolete after 1 day, and [GetOperation][] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][]s associated with the stale updates will not be marked as [done][Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][]s will be obsolete after 1 day, and [GetOperation][] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][]s associated with the stale updates will not be marked as [done][Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 94, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][]s will be obsolete after 1 day, and [GetOperation][] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][]s associated with the stale updates will not be marked as [done][Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 295, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2.SearchRequest.PersonalizationSpec" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec" + } + ], + "resultType": ".google.cloud.retail.v2.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. `Operation.response` is of type `ImportResponse`. Note that it is possible for a subset of the items to be successfully inserted. `Operation.metadata` is of type `ImportMetadata`.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2.UserEventService" + } + } + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-retail/samples/generated/v2/user_event_service.collect_user_event.js b/packages/google-cloud-retail/samples/generated/v2/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..2763ab29838 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/user_event_service.collect_user_event.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_CollectUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/user_event_service.import_user_events.js b/packages/google-cloud-retail/samples/generated/v2/user_event_service.import_user_events.js new file mode 100644 index 00000000000..8c65771ff28 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2_generated_UserEventService_ImportUserEvents_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. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/user_event_service.purge_user_events.js b/packages/google-cloud-retail/samples/generated/v2/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..72caf7921ac --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/user_event_service.purge_user_events.js @@ -0,0 +1,93 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2_generated_UserEventService_PurgeUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2.UserEvent.event_type string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/user_event_service.rejoin_user_events.js b/packages/google-cloud-retail/samples/generated/v2/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..4aa66d96e2a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2_generated_UserEventService_RejoinUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2/user_event_service.write_user_event.js b/packages/google-cloud-retail/samples/generated/v2/user_event_service.write_user_event.js new file mode 100644 index 00000000000..9ebb728d75a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2/user_event_service.write_user_event.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2_generated_UserEventService_WriteUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..f0582986a6a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_AddCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..f8da57b5bf3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetAttributesConfig_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_completion_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..637169fa3ed --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_CatalogService_GetCompletionConfig_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. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_default_branch.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..8f199af6699 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_GetDefaultBranch_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. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.list_catalogs.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..6b87c0a6510 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_CatalogService_ListCatalogs_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 account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2alpha.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2alpha.Catalog s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2alpha.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2alpha_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..b3be05fd6d8 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..d8dca41e410 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2alpha.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.set_default_branch.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..73d94d95574 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2alpha_generated_CatalogService_SetDefaultBranch_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. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2alpha.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2alpha_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..875915b830f --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_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 + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2alpha.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_catalog.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_catalog.js new file mode 100644 index 00000000000..f7b87f6796d --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog) { + // [START retail_v2alpha_generated_CatalogService_UpdateCatalog_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 Catalog google.cloud.retail.v2alpha.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2alpha.Catalog, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2alpha.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2alpha.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2alpha_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_completion_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..8d90945a302 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_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 + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2alpha.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2alpha.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2alpha.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.complete_query.js b/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.complete_query.js new file mode 100644 index 00000000000..e4d6046fac9 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.complete_query.js @@ -0,0 +1,122 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2alpha_generated_CompletionService_CompleteQuery_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. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2alpha.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2alpha.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2alpha_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.import_completion_data.js b/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.import_completion_data.js new file mode 100644 index 00000000000..b95bc8a0898 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_CompletionService_ImportCompletionData_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 catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2alpha_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/control_service.create_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.create_control.js new file mode 100644 index 00000000000..ddf3a2f6881 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, control, controlId) { + // [START retail_v2alpha_generated_ControlService_CreateControl_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. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2alpha_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/control_service.delete_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.delete_control.js new file mode 100644 index 00000000000..7c2c6c9cfbd --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_DeleteControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2alpha_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/control_service.get_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.get_control.js new file mode 100644 index 00000000000..c359a57f9f9 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ControlService_GetControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2alpha_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/control_service.list_controls.js b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.list_controls.js new file mode 100644 index 00000000000..4a5f8a6c3c7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ControlService_ListControls_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 catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2alpha_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/control_service.update_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.update_control.js new file mode 100644 index 00000000000..b62bbcdaa00 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2alpha_generated_ControlService_UpdateControl_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 Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2alpha.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2alpha.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2alpha_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.create_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.create_model.js new file mode 100644 index 00000000000..f301ddfe6d3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.create_model.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, model) { + // [START retail_v2alpha_generated_ModelService_CreateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource under which to create the model. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Required. The payload of the Model to create. + */ + // const model = {} + /** + * Optional. Whether to run a dry_run to validate the request (without + * actually creating the model). + */ + // const dryRun = true + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callCreateModel() { + // Construct request + const request = { + parent, + model, + }; + + // Run request + const [operation] = await retailClient.createModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateModel(); + // [END retail_v2alpha_generated_ModelService_CreateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.delete_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.delete_model.js new file mode 100644 index 00000000000..1339dd8f195 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.delete_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ModelService_DeleteModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Model to delete. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callDeleteModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteModel(request); + console.log(response); + } + + callDeleteModel(); + // [END retail_v2alpha_generated_ModelService_DeleteModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.list_models.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.list_models.js new file mode 100644 index 00000000000..93d15b65699 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.list_models.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ModelService_ListModels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent for which to list models. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callListModels() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listModelsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListModels(); + // [END retail_v2alpha_generated_ModelService_ListModels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.pause_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.pause_model.js new file mode 100644 index 00000000000..a8df9b88cd7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.pause_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ModelService_PauseModel_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 name of the model to pause. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callPauseModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.pauseModel(request); + console.log(response); + } + + callPauseModel(); + // [END retail_v2alpha_generated_ModelService_PauseModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.resume_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.resume_model.js new file mode 100644 index 00000000000..efcf35842ab --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.resume_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ModelService_ResumeModel_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 name of the model to resume. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callResumeModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.resumeModel(request); + console.log(response); + } + + callResumeModel(); + // [END retail_v2alpha_generated_ModelService_ResumeModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.tune_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.tune_model.js new file mode 100644 index 00000000000..18b8af29a07 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.tune_model.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ModelService_TuneModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the model to tune. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callTuneModel() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await retailClient.tuneModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTuneModel(); + // [END retail_v2alpha_generated_ModelService_TuneModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/model_service.update_model.js b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.update_model.js new file mode 100644 index 00000000000..c4f16d6834a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/model_service.update_model.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model) { + // [START retail_v2alpha_generated_ModelService_UpdateModel_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 body of the updated Model. + */ + // const model = {} + /** + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, will by default update all fields. + */ + // const updateMask = {} + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callUpdateModel() { + // Construct request + const request = { + model, + }; + + // Run request + const response = await retailClient.updateModel(request); + console.log(response); + } + + callUpdateModel(); + // [END retail_v2alpha_generated_ModelService_UpdateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/prediction_service.predict.js b/packages/google-cloud-retail/samples/generated/v2alpha/prediction_service.predict.js new file mode 100644 index 00000000000..0ccea81d7d4 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/prediction_service.predict.js @@ -0,0 +1,186 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2alpha_generated_PredictionService_Predict_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. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Managing serving configurations + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * Don't set + * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2alpha.UserInfo.user_id to the + * same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id to + * a random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2alpha.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * This field is not used for now; leave it unset. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2alpha_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..72f731f6084 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2alpha.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_local_inventories.js new file mode 100644 index 00000000000..db8d35e3906 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.add_local_inventories.js @@ -0,0 +1,103 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2alpha_generated_ProductService_AddLocalInventories_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2alpha.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2alpha_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.create_product.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.create_product.js new file mode 100644 index 00000000000..50e4380b0e9 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2alpha_generated_ProductService_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2alpha.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2alpha.Product, which will become the final + * component of the Product.name google.cloud.retail.v2alpha.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2alpha.Product s with the same + * parent google.cloud.retail.v2alpha.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2alpha_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.delete_product.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.delete_product.js new file mode 100644 index 00000000000..ded21af6cae --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.delete_product.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ProductService_DeleteProduct_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2alpha.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product with more than one + * variants google.cloud.retail.v2alpha.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2alpha.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2alpha_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.get_product.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.get_product.js new file mode 100644 index 00000000000..3524a0497af --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ProductService_GetProduct_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2alpha.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2alpha_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.import_products.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.import_products.js new file mode 100644 index 00000000000..a781e33934f --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.import_products.js @@ -0,0 +1,111 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_ProductService_ImportProducts_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. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * ImportProductsRequest.parent google.cloud.retail.v2alpha.ImportProductsRequest.parent. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const notificationPubsubTopic = 'abc123' + /** + * If true, will perform the FULL import even if it would delete a large + * proportion of the products in the default branch, which could potentially + * cause outages if you have live predict/search traffic. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const skipDefaultBranchProtection = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2alpha_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.list_products.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.list_products.js new file mode 100644 index 00000000000..ee8629da502 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.list_products.js @@ -0,0 +1,144 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ProductService_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2alpha.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2alpha.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2alpha.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2alpha.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2alpha.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2alpha.Product.Type.PRIMARY + * Product google.cloud.retail.v2alpha.Product or + * Product.Type.COLLECTION google.cloud.retail.v2alpha.Product.Type.COLLECTION + * Product google.cloud.retail.v2alpha.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2alpha.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2alpha.Product.name + * * Product.id google.cloud.retail.v2alpha.Product.id + * * Product.title google.cloud.retail.v2alpha.Product.title + * * Product.uri google.cloud.retail.v2alpha.Product.uri + * * Product.images google.cloud.retail.v2alpha.Product.images + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.brands google.cloud.retail.v2alpha.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2alpha.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + /** + * If true and + * page_token google.cloud.retail.v2alpha.ListProductsRequest.page_token is + * empty, + * ListProductsResponse.total_size google.cloud.retail.v2alpha.ListProductsResponse.total_size + * is set to the total count of matched items irrespective of pagination. + * Notice that setting this field to true affects the performance. + */ + // const requireTotalSize = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2alpha_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.purge_products.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.purge_products.js new file mode 100644 index 00000000000..1909f596edc --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.purge_products.js @@ -0,0 +1,104 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_ProductService_PurgeProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * The eligible fields for filtering are: + * * `availability`: Double quoted + * Product.availability google.cloud.retail.v2alpha.Product.availability + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * Supported syntax: + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + */ + // const force = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callPurgeProducts() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeProducts(); + // [END retail_v2alpha_generated_ProductService_PurgeProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..f783b7db152 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2alpha.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..2d1f636fd49 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2alpha_generated_ProductService_RemoveLocalInventories_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. Full resource name of + * Product google.cloud.retail.v2alpha.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2alpha.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2alpha_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.set_inventory.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.set_inventory.js new file mode 100644 index 00000000000..01b3a6f7319 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2alpha_generated_ProductService_SetInventory_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 inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask. + * If + * SetInventoryRequest.inventory.name google.cloud.retail.v2alpha.Product.name + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product named in + * Product.name google.cloud.retail.v2alpha.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2alpha.Product to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2alpha.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2alpha.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2alpha.Product.price_info + * * Product.availability google.cloud.retail.v2alpha.Product.availability + * * Product.available_quantity google.cloud.retail.v2alpha.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2alpha.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * ProductService.UpdateProduct google.cloud.retail.v2alpha.ProductService.UpdateProduct + * should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product with + * name Product.name google.cloud.retail.v2alpha.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2alpha.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2alpha.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2alpha_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/product_service.update_product.js b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.update_product.js new file mode 100644 index 00000000000..311422051f3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2alpha_generated_ProductService_UpdateProduct_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 product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2alpha.Product, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2alpha.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2alpha.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2alpha.Product is + * not found, a new Product google.cloud.retail.v2alpha.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2alpha_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/search_service.search.js b/packages/google-cloud-retail/samples/generated/v2alpha/search_service.search.js new file mode 100644 index 00000000000..c48a0d38775 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/search_service.search.js @@ -0,0 +1,315 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2alpha_generated_SearchService_Search_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * filter google.cloud.retail.v2alpha.SearchRequest.filter and + * page_categories google.cloud.retail.v2alpha.SearchRequest.page_categories. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2alpha.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2alpha.Product s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2alpha.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2alpha.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * Product google.cloud.retail.v2alpha.Product s deemed by the API as + * relevant) in search results. This field is only considered if + * page_token google.cloud.retail.v2alpha.SearchRequest.page_token is + * unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2alpha.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See + * SearchRequest.filter google.cloud.retail.v2alpha.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2alpha.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2alpha.ServingConfig.boost_control_ids + * and + * SearchRequest.boost_spec google.cloud.retail.v2alpha.SearchRequest.boost_spec + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The relevance threshold of the search results. + * Defaults to + * RelevanceThreshold.HIGH google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + */ + // const relevanceThreshold = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2alpha.Product.Type.VARIANT + * Product google.cloud.retail.v2alpha.Product s or + * LocalInventory google.cloud.retail.v2alpha.LocalInventory s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2alpha.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.local_inventories.attributes google.cloud.retail.v2alpha.LocalInventory.attributes + * map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2alpha.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.place_ids + * for + * FulfillmentInfo.type google.cloud.retail.v2alpha.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2alpha.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + */ + // const personalizationSpec = {} + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2alpha_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.add_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.add_control.js new file mode 100644 index 00000000000..0459af055f7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_AddControl_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 source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2alpha_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..879de7d0688 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, servingConfig, servingConfigId) { + // [START retail_v2alpha_generated_ServingConfigService_CreateServingConfig_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. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..6163b84f498 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..dd73fc17198 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..031adf60b4a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_ServingConfigService_ListServingConfigs_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 catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.remove_control.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.remove_control.js new file mode 100644 index 00000000000..f256e5072b6 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2alpha_generated_ServingConfigService_RemoveControl_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 source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2alpha_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..bffcbad75bd --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_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 ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2alpha.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2alpha.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json new file mode 100644 index 00000000000..c71708f06aa --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json @@ -0,0 +1,2499 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "2.1.1", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2alpha", + "version": "v2alpha" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2alpha_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2alpha.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2alpha.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2alpha.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2alpha.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2alpha.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2alpha.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2alpha.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2alpha.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2alpha.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2alpha.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 114, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2alpha.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2alpha.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2alpha.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2alpha.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2alpha.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2alpha.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2alpha.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2alpha.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2alpha.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2alpha.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls linked to this catalog.", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2alpha.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2alpha.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2alpha.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_CreateModel_async", + "title": "CatalogService createModel Sample", + "origin": "API_DEFINITION", + "description": " Creates a new model.", + "canonical": true, + "file": "model_service.create_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model", + "type": ".google.cloud.retail.v2alpha.Model" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_PauseModel_async", + "title": "CatalogService pauseModel Sample", + "origin": "API_DEFINITION", + "description": " Pauses the training of an existing model.", + "canonical": true, + "file": "model_service.pause_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_ResumeModel_async", + "title": "CatalogService resumeModel Sample", + "origin": "API_DEFINITION", + "description": " Resumes the training of an existing model.", + "canonical": true, + "file": "model_service.resume_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_DeleteModel_async", + "title": "CatalogService deleteModel Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing model.", + "canonical": true, + "file": "model_service.delete_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_ListModels_async", + "title": "CatalogService listModels Sample", + "origin": "API_DEFINITION", + "description": " Lists all the models linked to this event store.", + "canonical": true, + "file": "model_service.list_models.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListModelsResponse", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_UpdateModel_async", + "title": "CatalogService updateModel Sample", + "origin": "API_DEFINITION", + "description": " Update of model metadata. Only fields that currently can be updated are: filtering_option, periodic_tuning_state. If other values are provided, this API method will ignore them.", + "canonical": true, + "file": "model_service.update_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", + "async": true, + "parameters": [ + { + "name": "model", + "type": ".google.cloud.retail.v2alpha.Model" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_TuneModel_async", + "title": "CatalogService tuneModel Sample", + "origin": "API_DEFINITION", + "description": " Tunes an existing model.", + "canonical": true, + "file": "model_service.tune_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 178, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2alpha.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2alpha.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2alpha.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2alpha.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2alpha.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 136, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "require_total_size", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2alpha.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_PurgeProducts_async", + "title": "CatalogService purgeProducts Sample", + "origin": "API_DEFINITION", + "description": " Permanently deletes all selected [Product][google.cloud.retail.v2alpha.Product]s under a branch. This process is asynchronous. If the request is valid, the removal will be enqueued and processed offline. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. Before the operation completes, some [Product][google.cloud.retail.v2alpha.Product]s may still be returned by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Depending on the number of [Product][google.cloud.retail.v2alpha.Product]s, this operation could take hours to complete. To get a sample of [Product][google.cloud.retail.v2alpha.Product]s that would be deleted, set [PurgeProductsRequest.force][google.cloud.retail.v2alpha.PurgeProductsRequest.force] to false.", + "canonical": true, + "file": "product_service.purge_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 96, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "PurgeProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.PurgeProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2alpha.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2alpha.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 103, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + }, + { + "name": "skip_default_branch_protection", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2alpha.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2alpha.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) will overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update time for the specified inventory fields will be overwritten to the time of the [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2alpha.CreateProductRequest.product], then any pre-existing inventory information for this product will be used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information will be preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2alpha.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2alpha.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2alpha.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 95, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2alpha.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2alpha.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2alpha.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2alpha.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 307, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2alpha.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec" + }, + { + "name": "relevance_threshold", + "type": ".google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2alpha.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec" + } + ], + "resultType": ".google.cloud.retail.v2alpha.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2alpha.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2alpha.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2alpha.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2alpha.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2alpha.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2alpha.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2alpha.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2alpha.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2alpha.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 86, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. Operation.response is of type ImportResponse. Note that it is possible for a subset of the items to be successfully inserted. Operation.metadata is of type ImportMetadata.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2alpha.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2alpha.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user event rejoin operation with latest product catalog. Events will not be annotated with detailed product information if product is missing from the catalog at the time the user event is ingested, and these events are stored as unjoined events with a limited usage on training and serving. This method can be used to start a join operation on specified events with latest version of product catalog. It can also be used to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2alpha.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2alpha.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2alpha.UserEventService" + } + } + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.collect_user_event.js b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..e5f542a0c09 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.collect_user_event.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_CollectUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2alpha_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.import_user_events.js b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.import_user_events.js new file mode 100644 index 00000000000..72ec1632a2e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2alpha_generated_UserEventService_ImportUserEvents_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. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2alpha_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.purge_user_events.js b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..a1468cfec63 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.purge_user_events.js @@ -0,0 +1,94 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2alpha.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2alpha_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..73257790d89 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2alpha_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.write_user_event.js b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.write_user_event.js new file mode 100644 index 00000000000..3286c8f3526 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2alpha/user_event_service.write_user_event.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2alpha_generated_UserEventService_WriteUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2alpha_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..023955f9e77 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_AddCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callAddCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.addCatalogAttribute(request); + console.log(response); + } + + callAddCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_AddCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js new file mode 100644 index 00000000000..bf64469c8e3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, attributeKeys) { + // [START retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_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 attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name keys of the + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute s to delete. + * A maximum of 1000 catalog attributes can be deleted in a batch. + */ + // const attributeKeys = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callBatchRemoveCatalogAttributes() { + // Construct request + const request = { + attributesConfig, + attributeKeys, + }; + + // Run request + const response = await retailClient.batchRemoveCatalogAttributes(request); + console.log(response); + } + + callBatchRemoveCatalogAttributes(); + // [END retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..3e9001c0dc2 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetAttributesConfig_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetAttributesConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getAttributesConfig(request); + console.log(response); + } + + callGetAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_GetAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_completion_config.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..29b6a56e821 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_CatalogService_GetCompletionConfig_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. Full CompletionConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig` + */ + // const name = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetCompletionConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getCompletionConfig(request); + console.log(response); + } + + callGetCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_GetCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_default_branch.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..ceb504cd271 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_GetDefaultBranch_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. + */ + /** + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callGetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.getDefaultBranch(request); + console.log(response); + } + + callGetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_GetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.list_catalogs.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..5bbebe009f8 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_CatalogService_ListCatalogs_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 account resource name with an associated location. + * If the caller does not have permission to list + * Catalog google.cloud.retail.v2beta.Catalog s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Catalog google.cloud.retail.v2beta.Catalog s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListCatalogsResponse.next_page_token google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token, + * received from a previous + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * CatalogService.ListCatalogs google.cloud.retail.v2beta.CatalogService.ListCatalogs + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callListCatalogs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listCatalogsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListCatalogs(); + // [END retail_v2beta_generated_CatalogService_ListCatalogs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..751109b1d4e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, key) { + // [START retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name key of the + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callRemoveCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + key, + }; + + // Run request + const response = await retailClient.removeCatalogAttribute(request); + console.log(response); + } + + callRemoveCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..0d522a7d700 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig, catalogAttribute) { + // [START retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_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. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The updated + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute to update. + * The following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2beta.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callReplaceCatalogAttribute() { + // Construct request + const request = { + attributesConfig, + catalogAttribute, + }; + + // Run request + const response = await retailClient.replaceCatalogAttribute(request); + console.log(response); + } + + callReplaceCatalogAttribute(); + // [END retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.set_default_branch.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..a3c06eea85b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START retail_v2beta_generated_CatalogService_SetDefaultBranch_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. + */ + /** + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * The final component of the resource name of a branch. + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * If there are no sufficient active products in the targeted branch and + * force google.cloud.retail.v2beta.SetDefaultBranchRequest.force is not + * set, a FAILED_PRECONDITION error is returned. + */ + // const branchId = 'abc123' + /** + * Some note on this request, this can be retrieved by + * CatalogService.GetDefaultBranch google.cloud.retail.v2beta.CatalogService.GetDefaultBranch + * before next valid default branch set occurs. + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const note = 'abc123' + /** + * If set to true, it permits switching to a branch with + * branch_id google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id + * even if it has no sufficient active products. + */ + // const force = true + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callSetDefaultBranch() { + // Construct request + const request = { + }; + + // Run request + const response = await retailClient.setDefaultBranch(request); + console.log(response); + } + + callSetDefaultBranch(); + // [END retail_v2beta_generated_CatalogService_SetDefaultBranch_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_attributes_config.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..572b44c767e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(attributesConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateAttributesConfig_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 + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2beta.AttributesConfig to update. + * The following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2beta.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateAttributesConfig() { + // Construct request + const request = { + attributesConfig, + }; + + // Run request + const response = await retailClient.updateAttributesConfig(request); + console.log(response); + } + + callUpdateAttributesConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_catalog.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_catalog.js new file mode 100644 index 00000000000..a47a3af0fab --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog) { + // [START retail_v2beta_generated_CatalogService_UpdateCatalog_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 Catalog google.cloud.retail.v2beta.Catalog to update. + * If the caller does not have permission to update the + * Catalog google.cloud.retail.v2beta.Catalog, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Catalog google.cloud.retail.v2beta.Catalog to update does not + * exist, a NOT_FOUND error is returned. + */ + // const catalog = {} + /** + * Indicates which fields in the provided + * Catalog google.cloud.retail.v2beta.Catalog to update. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCatalog() { + // Construct request + const request = { + catalog, + }; + + // Run request + const response = await retailClient.updateCatalog(request); + console.log(response); + } + + callUpdateCatalog(); + // [END retail_v2beta_generated_CatalogService_UpdateCatalog_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_completion_config.js b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..ec6fa936ea4 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(completionConfig) { + // [START retail_v2beta_generated_CatalogService_UpdateCompletionConfig_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 + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2beta.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2beta.CompletionConfig to update. + * The following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2beta.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2beta.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2beta.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callUpdateCompletionConfig() { + // Construct request + const request = { + completionConfig, + }; + + // Run request + const response = await retailClient.updateCompletionConfig(request); + console.log(response); + } + + callUpdateCompletionConfig(); + // [END retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/completion_service.complete_query.js b/packages/google-cloud-retail/samples/generated/v2beta/completion_service.complete_query.js new file mode 100644 index 00000000000..78cc60aea4a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/completion_service.complete_query.js @@ -0,0 +1,122 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(catalog, query) { + // [START retail_v2beta_generated_CompletionService_CompleteQuery_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. Catalog for which the completion is performed. + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + */ + // const catalog = 'abc123' + /** + * Required. The query used to generate suggestions. + * The maximum number of allowed characters is 255. + */ + // const query = 'abc123' + /** + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see Tags for + * Identifying Languages (https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + */ + // const languageCodes = 'abc123' + /** + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * Supported formats: + * * `UNKNOWN_DEVICE_TYPE` + * * `DESKTOP` + * * `MOBILE` + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + */ + // const deviceType = 'abc123' + /** + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * CompletionService.ImportCompletionData google.cloud.retail.v2beta.CompletionService.ImportCompletionData. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * Current supported values: + * * user-data + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * guidelines (https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + */ + // const dataset = 'abc123' + /** + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * CompletionConfig.max_suggestions google.cloud.retail.v2beta.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callCompleteQuery() { + // Construct request + const request = { + catalog, + query, + }; + + // Run request + const response = await retailClient.completeQuery(request); + console.log(response); + } + + callCompleteQuery(); + // [END retail_v2beta_generated_CompletionService_CompleteQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/completion_service.import_completion_data.js b/packages/google-cloud-retail/samples/generated/v2beta/completion_service.import_completion_data.js new file mode 100644 index 00000000000..b601643c159 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_CompletionService_ImportCompletionData_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 catalog which the suggestions dataset belongs to. + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {CompletionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CompletionServiceClient(); + + async function callImportCompletionData() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importCompletionData(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportCompletionData(); + // [END retail_v2beta_generated_CompletionService_ImportCompletionData_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/control_service.create_control.js b/packages/google-cloud-retail/samples/generated/v2beta/control_service.create_control.js new file mode 100644 index 00000000000..940db2aeaf3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, control, controlId) { + // [START retail_v2beta_generated_ControlService_CreateControl_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. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The Control to create. + */ + // const control = {} + /** + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callCreateControl() { + // Construct request + const request = { + parent, + control, + controlId, + }; + + // Run request + const response = await retailClient.createControl(request); + console.log(response); + } + + callCreateControl(); + // [END retail_v2beta_generated_ControlService_CreateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/control_service.delete_control.js b/packages/google-cloud-retail/samples/generated/v2beta/control_service.delete_control.js new file mode 100644 index 00000000000..05e61ff3845 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_DeleteControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callDeleteControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteControl(request); + console.log(response); + } + + callDeleteControl(); + // [END retail_v2beta_generated_ControlService_DeleteControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/control_service.get_control.js b/packages/google-cloud-retail/samples/generated/v2beta/control_service.get_control.js new file mode 100644 index 00000000000..94c590e2ee5 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ControlService_GetControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callGetControl() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getControl(request); + console.log(response); + } + + callGetControl(); + // [END retail_v2beta_generated_ControlService_GetControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/control_service.list_controls.js b/packages/google-cloud-retail/samples/generated/v2beta/control_service.list_controls.js new file mode 100644 index 00000000000..b353c4ba13b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ControlService_ListControls_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 catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + /** + * Optional. A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListControlsRequest.filter is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + */ + // const filter = 'abc123' + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callListControls() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listControlsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListControls(); + // [END retail_v2beta_generated_ControlService_ListControls_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/control_service.update_control.js b/packages/google-cloud-retail/samples/generated/v2beta/control_service.update_control.js new file mode 100644 index 00000000000..2cdb285471d --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(control) { + // [START retail_v2beta_generated_ControlService_UpdateControl_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 Control to update. + */ + // const control = {} + /** + * Indicates which fields in the provided + * Control google.cloud.retail.v2beta.Control to update. The following are + * NOT supported: + * * Control.name google.cloud.retail.v2beta.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ControlServiceClient(); + + async function callUpdateControl() { + // Construct request + const request = { + control, + }; + + // Run request + const response = await retailClient.updateControl(request); + console.log(response); + } + + callUpdateControl(); + // [END retail_v2beta_generated_ControlService_UpdateControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.create_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.create_model.js new file mode 100644 index 00000000000..769cbe1c8a0 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.create_model.js @@ -0,0 +1,74 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, model) { + // [START retail_v2beta_generated_ModelService_CreateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The payload of the Model google.cloud.retail.v2beta.Model to + * create. + */ + // const model = {} + /** + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + */ + // const dryRun = true + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callCreateModel() { + // Construct request + const request = { + parent, + model, + }; + + // Run request + const [operation] = await retailClient.createModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateModel(); + // [END retail_v2beta_generated_ModelService_CreateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.delete_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.delete_model.js new file mode 100644 index 00000000000..0b695637824 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.delete_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ModelService_DeleteModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * Model google.cloud.retail.v2beta.Model to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callDeleteModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteModel(request); + console.log(response); + } + + callDeleteModel(); + // [END retail_v2beta_generated_ModelService_DeleteModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.list_models.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.list_models.js new file mode 100644 index 00000000000..25775f3d704 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.list_models.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ModelService_ListModels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent for which to list models. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callListModels() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listModelsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListModels(); + // [END retail_v2beta_generated_ModelService_ListModels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.pause_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.pause_model.js new file mode 100644 index 00000000000..a0a676070bd --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.pause_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ModelService_PauseModel_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 name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callPauseModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.pauseModel(request); + console.log(response); + } + + callPauseModel(); + // [END retail_v2beta_generated_ModelService_PauseModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.resume_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.resume_model.js new file mode 100644 index 00000000000..780bfa01a5b --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.resume_model.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ModelService_ResumeModel_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 name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callResumeModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.resumeModel(request); + console.log(response); + } + + callResumeModel(); + // [END retail_v2beta_generated_ModelService_ResumeModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.tune_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.tune_model.js new file mode 100644 index 00000000000..2983b757527 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.tune_model.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ModelService_TuneModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callTuneModel() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await retailClient.tuneModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTuneModel(); + // [END retail_v2beta_generated_ModelService_TuneModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/model_service.update_model.js b/packages/google-cloud-retail/samples/generated/v2beta/model_service.update_model.js new file mode 100644 index 00000000000..fe8c25f0545 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/model_service.update_model.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model) { + // [START retail_v2beta_generated_ModelService_UpdateModel_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 body of the updated + * Model google.cloud.retail.v2beta.Model. + */ + // const model = {} + /** + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + */ + // const updateMask = {} + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callUpdateModel() { + // Construct request + const request = { + model, + }; + + // Run request + const response = await retailClient.updateModel(request); + console.log(response); + } + + callUpdateModel(); + // [END retail_v2beta_generated_ModelService_UpdateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/prediction_service.predict.js b/packages/google-cloud-retail/samples/generated/v2beta/prediction_service.predict.js new file mode 100644 index 00000000000..ec652b810ce --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/prediction_service.predict.js @@ -0,0 +1,186 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, userEvent) { + // [START retail_v2beta_generated_PredictionService_Predict_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. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Managing serving configurations + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // const placement = 'abc123' + /** + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * Don't set + * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2beta.UserInfo.user_id to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id to + * a random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2beta.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return. Set this property to the number of + * prediction results needed. If zero, the service will choose a reasonable + * default. The maximum allowed value is 100. Values above 100 will be coerced + * to 100. + */ + // const pageSize = 1234 + /** + * This field is not used; leave it unset. + */ + // const pageToken = 'abc123' + /** + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * Examples: + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + */ + // const filter = 'abc123' + /** + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + */ + // const validateOnly = true + /** + * Additional domain specific parameters for the predictions. + * Allowed values: + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // const params = 1234 + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + + // Imports the Retail library + const {PredictionServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new PredictionServiceClient(); + + async function callPredict() { + // Construct request + const request = { + placement, + userEvent, + }; + + // Run request + const response = await retailClient.predict(request); + console.log(response); + } + + callPredict(); + // [END retail_v2beta_generated_PredictionService_Predict_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..11595736757 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_AddFulfillmentPlaces_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2beta.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type. + * Duplicate IDs will be automatically ignored. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * If the total number of place IDs exceeds 2000 for this + * type google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type after + * adding, then the update will be rejected. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_local_inventories.js new file mode 100644 index 00000000000..7b39897b56e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.add_local_inventories.js @@ -0,0 +1,103 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, localInventories) { + // [START retail_v2beta_generated_ProductService_AddLocalInventories_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + */ + // const localInventories = 1234 + /** + * Indicates which inventory fields in the provided list of + * LocalInventory google.cloud.retail.v2beta.LocalInventory to update. The + * field is updated to the provided value. + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const addMask = {} + /** + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + */ + // const addTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callAddLocalInventories() { + // Construct request + const request = { + product, + localInventories, + }; + + // Run request + const [operation] = await retailClient.addLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callAddLocalInventories(); + // [END retail_v2beta_generated_ProductService_AddLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.create_product.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.create_product.js new file mode 100644 index 00000000000..b641964aef7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, product, productId) { + // [START retail_v2beta_generated_ProductService_CreateProduct_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + */ + // const parent = 'abc123' + /** + * Required. The Product google.cloud.retail.v2beta.Product to create. + */ + // const product = {} + /** + * Required. The ID to use for the + * Product google.cloud.retail.v2beta.Product, which will become the final + * component of the Product.name google.cloud.retail.v2beta.Product.name. + * If the caller does not have permission to create the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * This field must be unique among all + * Product google.cloud.retail.v2beta.Product s with the same + * parent google.cloud.retail.v2beta.CreateProductRequest.parent. + * Otherwise, an ALREADY_EXISTS error is returned. + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const productId = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callCreateProduct() { + // Construct request + const request = { + parent, + product, + productId, + }; + + // Run request + const response = await retailClient.createProduct(request); + console.log(response); + } + + callCreateProduct(); + // [END retail_v2beta_generated_ProductService_CreateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.delete_product.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.delete_product.js new file mode 100644 index 00000000000..169a645d190 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.delete_product.js @@ -0,0 +1,78 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ProductService_DeleteProduct_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to delete the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to delete does not + * exist, a NOT_FOUND error is returned. + * The Product google.cloud.retail.v2beta.Product to delete can neither be + * a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product member nor a + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product with more than one + * variants google.cloud.retail.v2beta.Product.Type.VARIANT. Otherwise, an + * INVALID_ARGUMENT error is returned. + * All inventory information for the named + * Product google.cloud.retail.v2beta.Product will be deleted. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callDeleteProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteProduct(request); + console.log(response); + } + + callDeleteProduct(); + // [END retail_v2beta_generated_ProductService_DeleteProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.get_product.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.get_product.js new file mode 100644 index 00000000000..7a0870dd0c6 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ProductService_GetProduct_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the requested Product google.cloud.retail.v2beta.Product does not + * exist, a NOT_FOUND error is returned. + */ + // const name = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callGetProduct() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getProduct(request); + console.log(response); + } + + callGetProduct(); + // [END retail_v2beta_generated_ProductService_GetProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.import_products.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.import_products.js new file mode 100644 index 00000000000..701c45762ae --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.import_products.js @@ -0,0 +1,98 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_ProductService_ImportProducts_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. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. + */ + // const errorsConfig = {} + /** + * Indicates which fields in the provided imported `products` to update. If + * not set, all fields are updated. + */ + // const updateMask = {} + /** + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * ReconciliationMode.INCREMENTAL google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL. + */ + // const reconciliationMode = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * Operation google.longrunning.Operation. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * ImportProductsRequest.parent google.cloud.retail.v2beta.ImportProductsRequest.parent. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + */ + // const notificationPubsubTopic = 'abc123' + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callImportProducts() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importProducts(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportProducts(); + // [END retail_v2beta_generated_ProductService_ImportProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.list_products.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.list_products.js new file mode 100644 index 00000000000..5a424c00a13 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.list_products.js @@ -0,0 +1,135 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ProductService_ListProducts_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * If the caller does not have permission to list + * Product google.cloud.retail.v2beta.Product s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + */ + // const parent = 'abc123' + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * If this field is negative, an INVALID_ARGUMENT error is returned. + */ + // const pageSize = 1234 + /** + * A page token + * ListProductsResponse.next_page_token google.cloud.retail.v2beta.ListProductsResponse.next_page_token, + * received from a previous + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * ProductService.ListProducts google.cloud.retail.v2beta.ProductService.ListProducts + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A filter to apply on the list results. Supported features: + * * List all the products under the parent branch if + * filter google.cloud.retail.v2beta.ListProductsRequest.filter is unset. + * * List + * Product.Type.VARIANT google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s sharing the same + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product. For example: + * `primary_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s bundled in a + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product. + * For example: + * `collection_product_id = "some_product_id"` + * * List Product google.cloud.retail.v2beta.Product s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * If the specified + * Product.Type.PRIMARY google.cloud.retail.v2beta.Product.Type.PRIMARY + * Product google.cloud.retail.v2beta.Product or + * Product.Type.COLLECTION google.cloud.retail.v2beta.Product.Type.COLLECTION + * Product google.cloud.retail.v2beta.Product does not exist, a NOT_FOUND + * error is returned. + */ + // const filter = 'abc123' + /** + * The fields of Product google.cloud.retail.v2beta.Product to return in + * the responses. If not set or empty, the following fields are returned: + * * Product.name google.cloud.retail.v2beta.Product.name + * * Product.id google.cloud.retail.v2beta.Product.id + * * Product.title google.cloud.retail.v2beta.Product.title + * * Product.uri google.cloud.retail.v2beta.Product.uri + * * Product.images google.cloud.retail.v2beta.Product.images + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.brands google.cloud.retail.v2beta.Product.brands + * If "*" is provided, all fields are returned. + * Product.name google.cloud.retail.v2beta.Product.name is always returned + * no matter what mask is set. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + */ + // const readMask = {} + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callListProducts() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listProductsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProducts(); + // [END retail_v2beta_generated_ProductService_ListProducts_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..460a1a25f82 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, type, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * Supported values: + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * This field directly corresponds to + * Product.fulfillment_info.type google.cloud.retail.v2beta.FulfillmentInfo.type. + */ + // const type = 'abc123' + /** + * Required. The IDs for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * type google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type. + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const placeIds = 'abc123' + /** + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveFulfillmentPlaces() { + // Construct request + const request = { + product, + type, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveFulfillmentPlaces(); + // [END retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_local_inventories.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..bf094481db9 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product, placeIds) { + // [START retail_v2beta_generated_ProductService_RemoveLocalInventories_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. Full resource name of + * Product google.cloud.retail.v2beta.Product, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * If the caller does not have permission to access the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + */ + // const product = 'abc123' + /** + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + */ + // const placeIds = 'abc123' + /** + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + */ + // const removeTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * Product google.cloud.retail.v2beta.Product is created. If set to false, + * a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callRemoveLocalInventories() { + // Construct request + const request = { + product, + placeIds, + }; + + // Run request + const [operation] = await retailClient.removeLocalInventories(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRemoveLocalInventories(); + // [END retail_v2beta_generated_ProductService_RemoveLocalInventories_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.set_inventory.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.set_inventory.js new file mode 100644 index 00000000000..5ce1fc6d5aa --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inventory) { + // [START retail_v2beta_generated_ProductService_SetInventory_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 inventory information to update. The allowable fields to + * update are: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * The updated inventory fields must be specified in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask. + * If + * SetInventoryRequest.inventory.name google.cloud.retail.v2beta.Product.name + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product named in + * Product.name google.cloud.retail.v2beta.Product.name, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * If the Product google.cloud.retail.v2beta.Product to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * SetInventoryRequest.set_time google.cloud.retail.v2beta.SetInventoryRequest.set_time. + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * * Adds "fulfillment_info" in + * SetInventoryRequest.set_mask google.cloud.retail.v2beta.SetInventoryRequest.set_mask + * * Specifies only the desired fulfillment types to clear in + * SetInventoryRequest.inventory.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * The last update time is recorded for the following inventory fields: + * * Product.price_info google.cloud.retail.v2beta.Product.price_info + * * Product.availability google.cloud.retail.v2beta.Product.availability + * * Product.available_quantity google.cloud.retail.v2beta.Product.available_quantity + * * Product.fulfillment_info google.cloud.retail.v2beta.Product.fulfillment_info + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * ProductService.UpdateProduct google.cloud.retail.v2beta.ProductService.UpdateProduct + * should be invoked instead. + */ + // const inventory = {} + /** + * Indicates which inventory fields in the provided + * Product google.cloud.retail.v2beta.Product to update. + * At least one field must be provided. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + */ + // const setMask = {} + /** + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + */ + // const setTime = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product with + * name Product.name google.cloud.retail.v2beta.Product.name is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the Product google.cloud.retail.v2beta.Product is created. If set + * to false, a NOT_FOUND error is returned if the + * Product google.cloud.retail.v2beta.Product is not found. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callSetInventory() { + // Construct request + const request = { + inventory, + }; + + // Run request + const [operation] = await retailClient.setInventory(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetInventory(); + // [END retail_v2beta_generated_ProductService_SetInventory_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/product_service.update_product.js b/packages/google-cloud-retail/samples/generated/v2beta/product_service.update_product.js new file mode 100644 index 00000000000..8140d581d8a --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(product) { + // [START retail_v2beta_generated_ProductService_UpdateProduct_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 product to update/create. + * If the caller does not have permission to update the + * Product google.cloud.retail.v2beta.Product, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * If the Product google.cloud.retail.v2beta.Product to update does not + * exist and + * allow_missing google.cloud.retail.v2beta.UpdateProductRequest.allow_missing + * is not set, a NOT_FOUND error is returned. + */ + // const product = {} + /** + * Indicates which fields in the provided + * Product google.cloud.retail.v2beta.Product to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + */ + // const updateMask = {} + /** + * If set to true, and the Product google.cloud.retail.v2beta.Product is + * not found, a new Product google.cloud.retail.v2beta.Product will be + * created. In this situation, `update_mask` is ignored. + */ + // const allowMissing = true + + // Imports the Retail library + const {ProductServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ProductServiceClient(); + + async function callUpdateProduct() { + // Construct request + const request = { + product, + }; + + // Run request + const response = await retailClient.updateProduct(request); + console.log(response); + } + + callUpdateProduct(); + // [END retail_v2beta_generated_ProductService_UpdateProduct_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/search_service.search.js b/packages/google-cloud-retail/samples/generated/v2beta/search_service.search.js new file mode 100644 index 00000000000..1de2864e0d3 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/search_service.search.js @@ -0,0 +1,303 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(placement, visitorId) { + // [START retail_v2beta_generated_SearchService_Search_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + */ + // const placement = 'abc123' + /** + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + */ + // const branch = 'abc123' + /** + * Raw search query. + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * filter google.cloud.retail.v2beta.SearchRequest.filter and + * page_categories google.cloud.retail.v2beta.SearchRequest.page_categories. + */ + // const query = 'abc123' + /** + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * This should be the same identifier as + * UserEvent.visitor_id google.cloud.retail.v2beta.UserEvent.visitor_id. + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + */ + // const visitorId = 'abc123' + /** + * User information. + */ + // const userInfo = {} + /** + * Maximum number of Product google.cloud.retail.v2beta.Product s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const pageSize = 1234 + /** + * A page token + * SearchResponse.next_page_token google.cloud.retail.v2beta.SearchResponse.next_page_token, + * received from a previous + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * call. Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to + * SearchService.Search google.cloud.retail.v2beta.SearchService.Search + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + */ + // const pageToken = 'abc123' + /** + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the Product google.cloud.retail.v2beta.Product s + * deemed by the API as relevant) in search results. This field is only + * considered if + * page_token google.cloud.retail.v2beta.SearchRequest.page_token is unset. + * If this field is negative, an INVALID_ARGUMENT is returned. + */ + // const offset = 1234 + /** + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#filter). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const filter = 'abc123' + /** + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * SearchRequest.canonical_filter google.cloud.retail.v2beta.SearchRequest.canonical_filter + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * See SearchRequest.filter google.cloud.retail.v2beta.SearchRequest.filter + * for more details about filter syntax. + */ + // const canonicalFilter = 'abc123' + /** + * The order in which products are returned. Products can be ordered by + * a field in an Product google.cloud.retail.v2beta.Product object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this user + * guide (https://cloud.google.com/retail/docs/filter-and-order#order). + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + */ + // const orderBy = 'abc123' + /** + * Facet specifications for faceted search. If empty, no facets are returned. + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + */ + // const facetSpecs = 1234 + /** + * Boost specification to boost certain products. See more details at this + * user guide (https://cloud.google.com/retail/docs/boosting). + * Notice that if both + * ServingConfig.boost_control_ids google.cloud.retail.v2beta.ServingConfig.boost_control_ids + * and + * SearchRequest.boost_spec google.cloud.retail.v2beta.SearchRequest.boost_spec + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + */ + // const boostSpec = {} + /** + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this user + * guide (https://cloud.google.com/retail/docs/result-size#query_expansion). + */ + // const queryExpansionSpec = {} + /** + * The keys to fetch and rollup the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s attributes, + * FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s attributes. + * The attributes from all the matching + * variant google.cloud.retail.v2beta.Product.Type.VARIANT + * Product google.cloud.retail.v2beta.Product s or + * LocalInventory google.cloud.retail.v2beta.LocalInventory s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * For FulfillmentInfo google.cloud.retail.v2beta.FulfillmentInfo, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * Supported keys are: + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * Product.local_inventories.attributes google.cloud.retail.v2beta.LocalInventory.attributes + * map. + * * attributes.key, where key is any key in the + * Product.attributes google.cloud.retail.v2beta.Product.attributes map. + * * pickupInStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "pickup-in-store". + * * shipToStore.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-1". + * * customFulfillment2.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-2". + * * customFulfillment3.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-3". + * * customFulfillment4.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-4". + * * customFulfillment5.id, where id is any + * FulfillmentInfo.place_ids google.cloud.retail.v2beta.FulfillmentInfo.place_ids + * for FulfillmentInfo.type google.cloud.retail.v2beta.FulfillmentInfo.type + * "custom-type-5". + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + */ + // const variantRollupKeys = 'abc123' + /** + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * UserEvent.page_categories google.cloud.retail.v2beta.UserEvent.page_categories; + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, replace it with + * other character(s). + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : "Sales > 2017 Black Friday Deals". + */ + // const pageCategories = 'abc123' + /** + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + */ + // const searchMode = {} + /** + * The specification for personalization. + * Notice that if both + * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec + * and + * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec + * are set. + * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec + * will override + * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec. + */ + // const personalizationSpec = {} + /** + * The labels applied to a resource must meet the following requirements: + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * See Google Cloud + * Document (https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + */ + // const labels = 1234 + /** + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + */ + // const spellCorrectionSpec = {} + + // Imports the Retail library + const {SearchServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new SearchServiceClient(); + + async function callSearch() { + // Construct request + const request = { + placement, + visitorId, + }; + + // Run request + const iterable = await retailClient.searchAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearch(); + // [END retail_v2beta_generated_SearchService_Search_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.add_control.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.add_control.js new file mode 100644 index 00000000000..35d7cd0f8dc --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_AddControl_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 source ServingConfig resource name . Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is returned. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callAddControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.addControl(request); + console.log(response); + } + + callAddControl(); + // [END retail_v2beta_generated_ServingConfigService_AddControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.create_serving_config.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..613db80c746 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, servingConfig, servingConfigId) { + // [START retail_v2beta_generated_ServingConfigService_CreateServingConfig_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. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The ServingConfig to create. + */ + // const servingConfig = {} + /** + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * This value should be 4-63 characters, and valid characters + * are /[a-z][0-9]-_/. + */ + // const servingConfigId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callCreateServingConfig() { + // Construct request + const request = { + parent, + servingConfig, + servingConfigId, + }; + + // Run request + const response = await retailClient.createServingConfig(request); + console.log(response); + } + + callCreateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_CreateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..4c97e8ba77e --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callDeleteServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteServingConfig(request); + console.log(response); + } + + callDeleteServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.get_serving_config.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..edd8ca8d490 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START retail_v2beta_generated_ServingConfigService_GetServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ServingConfig to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callGetServingConfig() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getServingConfig(request); + console.log(response); + } + + callGetServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_GetServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..ce3eedb99db --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_ServingConfigService_ListServingConfigs_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 catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callListServingConfigs() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listServingConfigsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListServingConfigs(); + // [END retail_v2beta_generated_ServingConfigService_ListServingConfigs_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.remove_control.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.remove_control.js new file mode 100644 index 00000000000..e49c6249bce --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig, controlId) { + // [START retail_v2beta_generated_ServingConfigService_RemoveControl_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 source ServingConfig resource name . Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + */ + // const servingConfig = 'abc123' + /** + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + */ + // const controlId = 'abc123' + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callRemoveControl() { + // Construct request + const request = { + servingConfig, + controlId, + }; + + // Run request + const response = await retailClient.removeControl(request); + console.log(response); + } + + callRemoveControl(); + // [END retail_v2beta_generated_ServingConfigService_RemoveControl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.update_serving_config.js b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..c39e2e42efa --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(servingConfig) { + // [START retail_v2beta_generated_ServingConfigService_UpdateServingConfig_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 ServingConfig to update. + */ + // const servingConfig = {} + /** + * Indicates which fields in the provided + * ServingConfig google.cloud.retail.v2beta.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2beta.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ServingConfigServiceClient(); + + async function callUpdateServingConfig() { + // Construct request + const request = { + servingConfig, + }; + + // Run request + const response = await retailClient.updateServingConfig(request); + console.log(response); + } + + callUpdateServingConfig(); + // [END retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json new file mode 100644 index 00000000000..62c6e5c26a8 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json @@ -0,0 +1,2483 @@ +{ + "clientLibrary": { + "name": "nodejs-retail", + "version": "2.1.1", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.retail.v2beta", + "version": "v2beta" + } + ] + }, + "snippets": [ + { + "regionTag": "retail_v2beta_generated_CatalogService_ListCatalogs_async", + "title": "CatalogService listCatalogs Sample", + "origin": "API_DEFINITION", + "description": " Lists all the [Catalog][google.cloud.retail.v2beta.Catalog]s associated with the project.", + "canonical": true, + "file": "catalog_service.list_catalogs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListCatalogsResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ListCatalogs", + "fullName": "google.cloud.retail.v2beta.CatalogService.ListCatalogs", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCatalog_async", + "title": "CatalogService updateCatalog Sample", + "origin": "API_DEFINITION", + "description": " Updates the [Catalog][google.cloud.retail.v2beta.Catalog]s.", + "canonical": true, + "file": "catalog_service.update_catalog.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": ".google.cloud.retail.v2beta.Catalog" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Catalog", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCatalog", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCatalog", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_SetDefaultBranch_async", + "title": "CatalogService setDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Set a specified branch id as default branch. API methods such as [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search], [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct], [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts] will treat requests using \"default_branch\" to the actual branch id set as default. For example, if `projects/*/locations/*/catalogs/*/branches/1` is set as default, setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/default_branch` is equivalent to setting [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to `projects/*/locations/*/catalogs/*/branches/1`. Using multiple branches can be useful when developers would like to have a staging branch to test and verify for future usage. When it becomes ready, developers switch on the staging branch using this API while keeping using `projects/*/locations/*/catalogs/*/branches/default_branch` as [SearchRequest.branch][google.cloud.retail.v2beta.SearchRequest.branch] to route the traffic to this staging branch. CAUTION: If you have live predict/search traffic, switching the default branch could potentially cause outages if the ID space of the new branch is very different from the old one. More specifically: * PredictionService will only return product IDs from branch {newBranch}. * SearchService will only return product IDs from branch {newBranch} (if branch is not explicitly set). * UserEventService will only join events with products from branch {newBranch}.", + "canonical": true, + "file": "catalog_service.set_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "branch_id", + "type": "TYPE_STRING" + }, + { + "name": "note", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "SetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.SetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetDefaultBranch_async", + "title": "CatalogService getDefaultBranch Sample", + "origin": "API_DEFINITION", + "description": " Get which branch is currently default branch set by [CatalogService.SetDefaultBranch][google.cloud.retail.v2beta.CatalogService.SetDefaultBranch] method under a specified parent catalog.", + "canonical": true, + "file": "catalog_service.get_default_branch.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.GetDefaultBranchResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetDefaultBranch", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetDefaultBranch", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2beta.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2beta.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. The catalog attributes in the request will be updated in the catalog, or inserted if they do not exist. Existing catalog attributes not included in the request will remain unchanged. Attributes that are assigned to products, but do not exist at the catalog level, are always included in the response. The product attribute is assigned default values for missing catalog attribute fields, e.g., searchable and dynamic facetable options.", + "canonical": true, + "file": "catalog_service.update_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2beta.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to add already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "catalog_service.add_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to remove does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.remove_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async", + "title": "CatalogService batchRemoveCatalogAttributes Sample", + "origin": "API_DEFINITION", + "description": " Removes all specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", + "canonical": true, + "file": "catalog_service.batch_remove_catalog_attributes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "attribute_keys", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2beta.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute] to replace does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "catalog_service.replace_catalog_attribute.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2beta.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2beta.CatalogService.ReplaceCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2beta.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_CompleteQuery_async", + "title": "CatalogService completeQuery Sample", + "origin": "API_DEFINITION", + "description": " Completes the specified prefix with keyword suggestions. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 114, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "async": true, + "parameters": [ + { + "name": "catalog", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "language_codes", + "type": "TYPE_STRING[]" + }, + { + "name": "device_type", + "type": "TYPE_STRING" + }, + { + "name": "dataset", + "type": "TYPE_STRING" + }, + { + "name": "max_suggestions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.retail.v2beta.CompleteQueryResponse", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "CompleteQuery", + "fullName": "google.cloud.retail.v2beta.CompletionService.CompleteQuery", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_CompletionService_ImportCompletionData_async", + "title": "CatalogService importCompletionData Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of processed completion dataset. Request processing is asynchronous. Partial updating is not supported. The operation is successfully finished only after the imported suggestions are indexed successfully and ready for serving. The process takes hours. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.import_completion_data.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.CompletionDataInputConfig" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "CompletionServiceClient", + "fullName": "google.cloud.retail.v2beta.CompletionServiceClient" + }, + "method": { + "shortName": "ImportCompletionData", + "fullName": "google.cloud.retail.v2beta.CompletionService.ImportCompletionData", + "service": { + "shortName": "CompletionService", + "fullName": "google.cloud.retail.v2beta.CompletionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2beta.Control] to create already exists, an ALREADY_EXISTS error is returned.", + "canonical": true, + "file": "control_service.create_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2beta.Control] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.delete_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2beta.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2beta.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2beta.Control] to update does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2beta.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2beta.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_GetControl_async", + "title": "CatalogService getControl Sample", + "origin": "API_DEFINITION", + "description": " Gets a Control.", + "canonical": true, + "file": "control_service.get_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2beta.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls by their parent [Catalog][google.cloud.retail.v2beta.Catalog].", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2beta.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2beta.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2beta.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_CreateModel_async", + "title": "CatalogService createModel Sample", + "origin": "API_DEFINITION", + "description": " Creates a new model.", + "canonical": true, + "file": "model_service.create_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model", + "type": ".google.cloud.retail.v2beta.Model" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_PauseModel_async", + "title": "CatalogService pauseModel Sample", + "origin": "API_DEFINITION", + "description": " Pauses the training of an existing model.", + "canonical": true, + "file": "model_service.pause_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_ResumeModel_async", + "title": "CatalogService resumeModel Sample", + "origin": "API_DEFINITION", + "description": " Resumes the training of an existing model.", + "canonical": true, + "file": "model_service.resume_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_DeleteModel_async", + "title": "CatalogService deleteModel Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing model.", + "canonical": true, + "file": "model_service.delete_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_ListModels_async", + "title": "CatalogService listModels Sample", + "origin": "API_DEFINITION", + "description": " Lists all the models linked to this event store.", + "canonical": true, + "file": "model_service.list_models.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListModelsResponse", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_UpdateModel_async", + "title": "CatalogService updateModel Sample", + "origin": "API_DEFINITION", + "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", + "canonical": true, + "file": "model_service.update_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", + "async": true, + "parameters": [ + { + "name": "model", + "type": ".google.cloud.retail.v2beta.Model" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_TuneModel_async", + "title": "CatalogService tuneModel Sample", + "origin": "API_DEFINITION", + "description": " Tunes an existing model.", + "canonical": true, + "file": "model_service.tune_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_PredictionService_Predict_async", + "title": "CatalogService predict Sample", + "origin": "API_DEFINITION", + "description": " Makes a recommendation prediction.", + "canonical": true, + "file": "prediction_service.predict.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 178, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "params", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.cloud.retail.v2beta.PredictResponse", + "client": { + "shortName": "PredictionServiceClient", + "fullName": "google.cloud.retail.v2beta.PredictionServiceClient" + }, + "method": { + "shortName": "Predict", + "fullName": "google.cloud.retail.v2beta.PredictionService.Predict", + "service": { + "shortName": "PredictionService", + "fullName": "google.cloud.retail.v2beta.PredictionService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_CreateProduct_async", + "title": "CatalogService createProduct Sample", + "origin": "API_DEFINITION", + "description": " Creates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.create_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "product_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "CreateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.CreateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_GetProduct_async", + "title": "CatalogService getProduct Sample", + "origin": "API_DEFINITION", + "description": " Gets a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.get_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "GetProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.GetProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ListProducts_async", + "title": "CatalogService listProducts Sample", + "origin": "API_DEFINITION", + "description": " Gets a list of [Product][google.cloud.retail.v2beta.Product]s.", + "canonical": true, + "file": "product_service.list_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 127, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "read_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListProductsResponse", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ListProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ListProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_UpdateProduct_async", + "title": "CatalogService updateProduct Sample", + "origin": "API_DEFINITION", + "description": " Updates a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.update_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "async": true, + "parameters": [ + { + "name": "product", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.retail.v2beta.Product", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "UpdateProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.UpdateProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_DeleteProduct_async", + "title": "CatalogService deleteProduct Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [Product][google.cloud.retail.v2beta.Product].", + "canonical": true, + "file": "product_service.delete_product.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2beta.ProductService.DeleteProduct", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_ImportProducts_async", + "title": "CatalogService importProducts Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of multiple [Product][google.cloud.retail.v2beta.Product]s. Request processing may be synchronous. Non-existing items are created. Note that it is possible for a subset of the [Product][google.cloud.retail.v2beta.Product]s to be successfully updated.", + "canonical": true, + "file": "product_service.import_products.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_id", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.ProductInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "reconciliation_mode", + "type": ".google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode" + }, + { + "name": "notification_pubsub_topic", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "ImportProducts", + "fullName": "google.cloud.retail.v2beta.ProductService.ImportProducts", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_SetInventory_async", + "title": "CatalogService setInventory Sample", + "origin": "API_DEFINITION", + "description": " Updates inventory information for a [Product][google.cloud.retail.v2beta.Product] while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update is enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] request. If no inventory fields are set in [CreateProductRequest.product][google.cloud.retail.v2beta.CreateProductRequest.product], then any pre-existing inventory information for this product is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "async": true, + "parameters": [ + { + "name": "inventory", + "type": ".google.cloud.retail.v2beta.Product" + }, + { + "name": "set_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "set_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "SetInventory", + "fullName": "google.cloud.retail.v2beta.ProductService.SetInventory", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async", + "title": "CatalogService addFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally adds place IDs to [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the added place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async", + "title": "CatalogService removeFulfillmentPlaces Sample", + "origin": "API_DEFINITION", + "description": " Incrementally removes place IDs from a [Product.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.place_ids]. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating fulfillment information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, the removed place IDs are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "type", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveFulfillmentPlaces", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_AddLocalInventories_async", + "title": "CatalogService addLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Updates local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places, while respecting the last update timestamps of each inventory field. This process is asynchronous and does not require the [Product][google.cloud.retail.v2beta.Product] to exist before updating inventory information. If the request is valid, the update will be enqueued and processed downstream. As a consequence, when a response is returned, updates are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 95, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "local_inventories", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "add_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "add_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "AddLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.AddLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ProductService_RemoveLocalInventories_async", + "title": "CatalogService removeLocalInventories Sample", + "origin": "API_DEFINITION", + "description": " Remove local inventory information for a [Product][google.cloud.retail.v2beta.Product] at a list of places at a removal timestamp. This process is asynchronous. If the request is valid, the removal will be enqueued and processed downstream. As a consequence, when a response is returned, removals are not immediately manifested in the [Product][google.cloud.retail.v2beta.Product] queried by [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "async": true, + "parameters": [ + { + "name": "product", + "type": "TYPE_STRING" + }, + { + "name": "place_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "remove_time", + "type": ".google.protobuf.Timestamp" + }, + { + "name": "allow_missing", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProductServiceClient", + "fullName": "google.cloud.retail.v2beta.ProductServiceClient" + }, + "method": { + "shortName": "RemoveLocalInventories", + "fullName": "google.cloud.retail.v2beta.ProductService.RemoveLocalInventories", + "service": { + "shortName": "ProductService", + "fullName": "google.cloud.retail.v2beta.ProductService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_SearchService_Search_async", + "title": "CatalogService search Sample", + "origin": "API_DEFINITION", + "description": " Performs a search. This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 295, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "async": true, + "parameters": [ + { + "name": "placement", + "type": "TYPE_STRING" + }, + { + "name": "branch", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "visitor_id", + "type": "TYPE_STRING" + }, + { + "name": "user_info", + "type": ".google.cloud.retail.v2beta.UserInfo" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "canonical_filter", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "facet_specs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "dynamic_facet_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec" + }, + { + "name": "boost_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.BoostSpec" + }, + { + "name": "query_expansion_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec" + }, + { + "name": "variant_rollup_keys", + "type": "TYPE_STRING[]" + }, + { + "name": "page_categories", + "type": "TYPE_STRING[]" + }, + { + "name": "search_mode", + "type": ".google.cloud.retail.v2beta.SearchRequest.SearchMode" + }, + { + "name": "personalization_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec" + } + ], + "resultType": ".google.cloud.retail.v2beta.SearchResponse", + "client": { + "shortName": "SearchServiceClient", + "fullName": "google.cloud.retail.v2beta.SearchServiceClient" + }, + "method": { + "shortName": "Search", + "fullName": "google.cloud.retail.v2beta.SearchService.Search", + "service": { + "shortName": "SearchService", + "fullName": "google.cloud.retail.v2beta.SearchService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2beta.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async", + "title": "CatalogService deleteServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.delete_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async", + "title": "CatalogService updateServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates a ServingConfig.", + "canonical": true, + "file": "serving_config_service.update_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2beta.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_GetServingConfig_async", + "title": "CatalogService getServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a ServingConfig. Returns a NotFound error if the ServingConfig does not exist.", + "canonical": true, + "file": "serving_config_service.get_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_ListServingConfigs_async", + "title": "CatalogService listServingConfigs Sample", + "origin": "API_DEFINITION", + "description": " Lists all ServingConfigs linked to this catalog.", + "canonical": true, + "file": "serving_config_service.list_serving_configs.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_AddControl_async", + "title": "CatalogService addControl Sample", + "origin": "API_DEFINITION", + "description": " Enables a Control on the specified ServingConfig. The control is added in the last position of the list of controls it belongs to (e.g. if it's a facet spec control it will be applied in the last position of servingConfig.facetSpecIds) Returns a ALREADY_EXISTS error if the control has already been applied. Returns a FAILED_PRECONDITION error if the addition could exceed maximum number of control allowed for that type of control.", + "canonical": true, + "file": "serving_config_service.add_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ServingConfigService_RemoveControl_async", + "title": "CatalogService removeControl Sample", + "origin": "API_DEFINITION", + "description": " Disables a Control on the specified ServingConfig. The control is removed from the ServingConfig. Returns a NOT_FOUND error if the Control is not enabled for the ServingConfig.", + "canonical": true, + "file": "serving_config_service.remove_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2beta.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2beta.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2beta.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_WriteUserEvent_async", + "title": "CatalogService writeUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event.", + "canonical": true, + "file": "user_event_service.write_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": ".google.cloud.retail.v2beta.UserEvent" + } + ], + "resultType": ".google.cloud.retail.v2beta.UserEvent", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "WriteUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.WriteUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_CollectUserEvent_async", + "title": "CatalogService collectUserEvent Sample", + "origin": "API_DEFINITION", + "description": " Writes a single user event from the browser. This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.", + "canonical": true, + "file": "user_event_service.collect_user_event.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.api.HttpBody", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_PurgeUserEvents_async", + "title": "CatalogService purgeUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Deletes permanently all user events specified by the filter provided. Depending on the number of events specified by the filter, this operation could take hours or days to complete. To test a filter, use the list command first.", + "canonical": true, + "file": "user_event_service.purge_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 86, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "PurgeUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.PurgeUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_ImportUserEvents_async", + "title": "CatalogService importUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Bulk import of User events. Request processing might be synchronous. Events that already exist are skipped. Use this method for backfilling historical user events. `Operation.response` is of type `ImportResponse`. Note that it is possible for a subset of the items to be successfully inserted. `Operation.metadata` is of type `ImportMetadata`.", + "canonical": true, + "file": "user_event_service.import_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.retail.v2beta.UserEventInputConfig" + }, + { + "name": "errors_config", + "type": ".google.cloud.retail.v2beta.ImportErrorsConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "ImportUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.ImportUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_UserEventService_RejoinUserEvents_async", + "title": "CatalogService rejoinUserEvents Sample", + "origin": "API_DEFINITION", + "description": " Starts a user-event rejoin operation with latest product catalog. Events are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method to correct events joined with the wrong product catalog. A rejoin operation can take hours or days to complete.", + "canonical": true, + "file": "user_event_service.rejoin_user_events.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event_rejoin_scope", + "type": ".google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "UserEventServiceClient", + "fullName": "google.cloud.retail.v2beta.UserEventServiceClient" + }, + "method": { + "shortName": "RejoinUserEvents", + "fullName": "google.cloud.retail.v2beta.UserEventService.RejoinUserEvents", + "service": { + "shortName": "UserEventService", + "fullName": "google.cloud.retail.v2beta.UserEventService" + } + } + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.collect_user_event.js b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..ad837df15dc --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.collect_user_event.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_CollectUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + */ + // const userEvent = 'abc123' + /** + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + */ + // const uri = 'abc123' + /** + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + */ + // const ets = 1234 + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callCollectUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.collectUserEvent(request); + console.log(response); + } + + callCollectUserEvent(); + // [END retail_v2beta_generated_UserEventService_CollectUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.import_user_events.js b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.import_user_events.js new file mode 100644 index 00000000000..5e2d40e22c7 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, inputConfig) { + // [START retail_v2beta_generated_UserEventService_ImportUserEvents_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. `projects/1234/locations/global/catalogs/default_catalog` + */ + // const parent = 'abc123' + /** + * Required. The desired input location of the data. + */ + // const inputConfig = {} + /** + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + */ + // const errorsConfig = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callImportUserEvents() { + // Construct request + const request = { + parent, + inputConfig, + }; + + // Run request + const [operation] = await retailClient.importUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportUserEvents(); + // [END retail_v2beta_generated_UserEventService_ImportUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.purge_user_events.js b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..7bd58e1d062 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.purge_user_events.js @@ -0,0 +1,94 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, filter) { + // [START retail_v2beta_generated_UserEventService_PurgeUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + */ + // const parent = 'abc123' + /** + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * * `eventType`: Double quoted + * UserEvent.event_type google.cloud.retail.v2beta.UserEvent.event_type + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * Examples: + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * The filtering fields are assumed to have an implicit AND. + */ + // const filter = 'abc123' + /** + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + */ + // const force = true + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callPurgeUserEvents() { + // Construct request + const request = { + parent, + filter, + }; + + // Run request + const [operation] = await retailClient.purgeUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callPurgeUserEvents(); + // [END retail_v2beta_generated_UserEventService_PurgeUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..9c24f1a5154 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START retail_v2beta_generated_UserEventService_RejoinUserEvents_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * `USER_EVENT_REJOIN_SCOPE_UNSPECIFIED` if this field is not set, or set to + * an invalid integer value. + */ + // const userEventRejoinScope = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callRejoinUserEvents() { + // Construct request + const request = { + parent, + }; + + // Run request + const [operation] = await retailClient.rejoinUserEvents(request); + const [response] = await operation.promise(); + console.log(response); + } + + callRejoinUserEvents(); + // [END retail_v2beta_generated_UserEventService_RejoinUserEvents_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.write_user_event.js b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.write_user_event.js new file mode 100644 index 00000000000..9e2d4d93808 --- /dev/null +++ b/packages/google-cloud-retail/samples/generated/v2beta/user_event_service.write_user_event.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, userEvent) { + // [START retail_v2beta_generated_UserEventService_WriteUserEvent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + + // Imports the Retail library + const {UserEventServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new UserEventServiceClient(); + + async function callWriteUserEvent() { + // Construct request + const request = { + parent, + userEvent, + }; + + // Run request + const response = await retailClient.writeUserEvent(request); + console.log(response); + } + + callWriteUserEvent(); + // [END retail_v2beta_generated_UserEventService_WriteUserEvent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-retail/samples/package.json b/packages/google-cloud-retail/samples/package.json new file mode 100644 index 00000000000..c4e6019e866 --- /dev/null +++ b/packages/google-cloud-retail/samples/package.json @@ -0,0 +1,25 @@ +{ + "name": "nodejs-retail", + "private": true, + "license": "Apache-2.0", + "author": "Google LLC", + "engines": { + "node": ">=12.0.0" + }, + "files": [ + "*.js" + ], + "scripts": { + "test": "c8 mocha" + }, + "dependencies": { + "@google-cloud/retail": "^2.1.1", + "@google-cloud/bigquery": "^6.0.0", + "@google-cloud/storage": "^6.0.0" + }, + "devDependencies": { + "c8": "^7.1.0", + "chai": "^4.2.0", + "mocha": "^8.0.0" + } +} \ No newline at end of file diff --git a/packages/google-cloud-retail/samples/quickstart.js b/packages/google-cloud-retail/samples/quickstart.js new file mode 100644 index 00000000000..e8b65192f32 --- /dev/null +++ b/packages/google-cloud-retail/samples/quickstart.js @@ -0,0 +1,46 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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'; + +async function main(projectId, location) { + // [START nodejs_retail_quickstart] + + // Imports the Google Cloud client library + const {CatalogServiceClient} = require('@google-cloud/retail'); + + // TODO(developer): uncomment these variables with your information + // const projectId = 'my-project' + // const location = 'global' + + // Creates a client + const client = new CatalogServiceClient(); + + async function listCatalogs() { + const catalogs = await client.listCatalogs({ + parent: `projects/${projectId}/locations/${location}`, + }); + console.info(catalogs); + } + listCatalogs(); + // [END nodejs_retail_quickstart] +} + +main(...process.argv.slice(2)).catch(err => { + console.error(err.message); + process.exitCode = 1; +}); +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); diff --git a/packages/google-cloud-retail/samples/test/quickstart.js b/packages/google-cloud-retail/samples/test/quickstart.js new file mode 100644 index 00000000000..5f93004506a --- /dev/null +++ b/packages/google-cloud-retail/samples/test/quickstart.js @@ -0,0 +1,43 @@ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +const path = require('path'); +const cp = require('child_process'); +const {before, describe, it} = require('mocha'); +const {CatalogServiceClient} = require('@google-cloud/retail'); +const {assert} = require('chai'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +const cwd = path.join(__dirname, '..'); + +const client = new CatalogServiceClient(); + +describe('Quickstart', () => { + let projectId; + + before(async () => { + projectId = await client.getProjectId(); + }); + + it('should run quickstart', async () => { + const stdout = execSync(`node ./quickstart.js ${projectId} global`, {cwd}); + assert.match(stdout, /default_catalog/); + }); +}); diff --git a/packages/google-cloud-retail/src/index.ts b/packages/google-cloud-retail/src/index.ts new file mode 100644 index 00000000000..016870e8792 --- /dev/null +++ b/packages/google-cloud-retail/src/index.ts @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by synthtool. ** +// ** https://github.com/googleapis/synthtool ** +// ** All changes to this file may be overwritten. ** + +import * as v2 from './v2'; +import * as v2alpha from './v2alpha'; +import * as v2beta from './v2beta'; + +const CatalogServiceClient = v2beta.CatalogServiceClient; +type CatalogServiceClient = v2beta.CatalogServiceClient; +const CompletionServiceClient = v2beta.CompletionServiceClient; +type CompletionServiceClient = v2beta.CompletionServiceClient; +const ControlServiceClient = v2beta.ControlServiceClient; +type ControlServiceClient = v2beta.ControlServiceClient; +const ModelServiceClient = v2beta.ModelServiceClient; +type ModelServiceClient = v2beta.ModelServiceClient; +const PredictionServiceClient = v2beta.PredictionServiceClient; +type PredictionServiceClient = v2beta.PredictionServiceClient; +const ProductServiceClient = v2beta.ProductServiceClient; +type ProductServiceClient = v2beta.ProductServiceClient; +const SearchServiceClient = v2beta.SearchServiceClient; +type SearchServiceClient = v2beta.SearchServiceClient; +const ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +type ServingConfigServiceClient = v2beta.ServingConfigServiceClient; +const UserEventServiceClient = v2beta.UserEventServiceClient; +type UserEventServiceClient = v2beta.UserEventServiceClient; + +export { + v2, + v2alpha, + v2beta, + CatalogServiceClient, + CompletionServiceClient, + ControlServiceClient, + ModelServiceClient, + PredictionServiceClient, + ProductServiceClient, + SearchServiceClient, + ServingConfigServiceClient, + UserEventServiceClient, +}; +export default { + v2, + v2alpha, + v2beta, + CatalogServiceClient, + CompletionServiceClient, + ControlServiceClient, + ModelServiceClient, + PredictionServiceClient, + ProductServiceClient, + SearchServiceClient, + ServingConfigServiceClient, + UserEventServiceClient, +}; +import * as protos from '../protos/protos'; +export {protos}; diff --git a/packages/google-cloud-retail/src/v2/catalog_service_client.ts b/packages/google-cloud-retail/src/v2/catalog_service_client.ts new file mode 100644 index 00000000000..5b75717098a --- /dev/null +++ b/packages/google-cloud-retail/src/v2/catalog_service_client.ts @@ -0,0 +1,2455 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2 + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listCatalogs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'catalogs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{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.cloud.retail.v2.CatalogService', + 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.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.CatalogService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CatalogService, + 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 catalogServiceStubMethods = [ + 'listCatalogs', + 'updateCatalog', + 'setDefaultBranch', + 'getDefaultBranch', + 'getCompletionConfig', + 'updateCompletionConfig', + 'getAttributesConfig', + 'updateAttributesConfig', + 'addCatalogAttribute', + 'removeCatalogAttribute', + 'replaceCatalogAttribute', + ]; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Updates the {@link google.cloud.retail.v2.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Catalog|Catalog}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Catalog|Catalog} to update does not exist, + * a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is 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 [Catalog]{@link google.cloud.retail.v2.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.update_catalog.js + * region_tag:retail_v2_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest | undefined, + {} | undefined + ] + >; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest | null | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest | null | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request?: protos.google.cloud.retail.v2.IUpdateCatalogRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.ICatalog, + | protos.google.cloud.retail.v2.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.ICatalog, + protos.google.cloud.retail.v2.IUpdateCatalogRequest | 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({ + 'catalog.name': request.catalog!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } + /** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2.SearchRequest.branch|SearchRequest.branch} to + * route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.force|force} is not set, a + * FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2.SetDefaultBranchRequest.branch_id|branch_id} even + * if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.set_default_branch.js + * region_tag:retail_v2_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2.ISetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.ISetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } + /** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @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 [GetDefaultBranchResponse]{@link google.cloud.retail.v2.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.get_default_branch.js + * region_tag:retail_v2_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2.IGetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2.IGetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @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 [CompletionConfig]{@link google.cloud.retail.v2.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.get_completion_config.js + * region_tag:retail_v2_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest | undefined, + {} | undefined + ] + >; + getCompletionConfig( + request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } + /** + * Updates the {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.CompletionConfig} request.completionConfig + * Required. The {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig} + * to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig} to update. The + * following are the only supported fields: + * + * * {@link google.cloud.retail.v2.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.update_completion_config.js + * region_tag:retail_v2_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest | undefined, + {} | undefined + ] + >; + updateCompletionConfig( + request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + | protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest | 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({ + 'completion_config.name': request.completionConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig( + request, + options, + callback + ); + } + /** + * Gets an {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @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 [AttributesConfig]{@link google.cloud.retail.v2.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.get_attributes_config.js + * region_tag:retail_v2_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest | undefined, + {} | undefined + ] + >; + getAttributesConfig( + request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } + /** + * Updates the {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.AttributesConfig} request.attributesConfig + * Required. The {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} + * to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} to update. The + * following is the only supported field: + * + * * {@link google.cloud.retail.v2.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.update_attributes_config.js + * region_tag:retail_v2_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest | undefined, + {} | undefined + ] + >; + updateAttributesConfig( + request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest | 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({ + 'attributes_config.name': request.attributesConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig( + request, + options, + callback + ); + } + /** + * Adds the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to add + * already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2.CatalogAttribute} request.catalogAttribute + * Required. The {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} + * to add. + * @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 [AttributesConfig]{@link google.cloud.retail.v2.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest | undefined, + {} | undefined + ] + >; + addCatalogAttribute( + request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } + /** + * Removes the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to remove. + * @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 [AttributesConfig]{@link google.cloud.retail.v2.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest | undefined, + {} | undefined + ] + >; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute( + request, + options, + callback + ); + } + /** + * Replaces the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} by updating the + * catalog attribute with the same + * {@link google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest | undefined, + {} | undefined + ] + >; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + | protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute( + request, + options, + callback + ); + } + + /** + * Lists all the {@link google.cloud.retail.v2.Catalog|Catalog}s associated with + * the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is 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 Array of [Catalog]{@link google.cloud.retail.v2.Catalog}. + * 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest | null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ] + >; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse | null | undefined, + protos.google.cloud.retail.v2.ICatalog + > + ): void; + listCatalogs( + request: protos.google.cloud.retail.v2.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse | null | undefined, + protos.google.cloud.retail.v2.ICatalog + > + ): void; + listCatalogs( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + | protos.google.cloud.retail.v2.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2.ICatalog + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListCatalogsRequest, + protos.google.cloud.retail.v2.IListCatalogsResponse | null | undefined, + protos.google.cloud.retail.v2.ICatalog + > + ): Promise< + [ + protos.google.cloud.retail.v2.ICatalog[], + protos.google.cloud.retail.v2.IListCatalogsRequest | null, + protos.google.cloud.retail.v2.IListCatalogsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @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 [Catalog]{@link google.cloud.retail.v2.Catalog} 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Catalog|Catalog}s under this location, regardless + * of whether or not this location exists, a PERMISSION_DENIED error is + * returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Catalog|Catalog}s to return. If + * unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/catalog_service.list_catalogs.js + * region_tag:retail_v2_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2.IListCatalogsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/catalog_service_client_config.json b/packages/google-cloud-retail/src/v2/catalog_service_client_config.json new file mode 100644 index 00000000000..407c2a8de65 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CatalogService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/catalog_service_proto_list.json b/packages/google-cloud-retail/src/v2/catalog_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/catalog_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/completion_service_client.ts b/packages/google-cloud-retail/src/v2/completion_service_client.ts new file mode 100644 index 00000000000..073bef1cafe --- /dev/null +++ b/packages/google-cloud-retail/src/v2/completion_service_client.ts @@ -0,0 +1,1356 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportCompletionDataResponse' + ) as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.CompletionService', + 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.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.CompletionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.CompletionService, + 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 completionServiceStubMethods = [ + 'completeQuery', + 'importCompletionData', + ]; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @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 [CompleteQueryResponse]{@link google.cloud.retail.v2.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.complete_query.js + * region_tag:retail_v2_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest | undefined, + {} | undefined + ] + >; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest | null | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request: protos.google.cloud.retail.v2.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest | null | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request?: protos.google.cloud.retail.v2.ICompleteQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + | protos.google.cloud.retail.v2.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.ICompleteQueryResponse, + protos.google.cloud.retail.v2.ICompleteQueryRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + + /** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request?: protos.google.cloud.retail.v2.IImportCompletionDataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/completion_service.import_completion_data.js + * region_tag:retail_v2_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.ImportCompletionDataResponse, + protos.google.cloud.retail.v2.ImportMetadata + > + > { + 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.importCompletionData, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.ImportCompletionDataResponse, + protos.google.cloud.retail.v2.ImportMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/completion_service_client_config.json b/packages/google-cloud-retail/src/v2/completion_service_client_config.json new file mode 100644 index 00000000000..a6bffad0d24 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2.CompletionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/completion_service_proto_list.json b/packages/google-cloud-retail/src/v2/completion_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/completion_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/control_service_client.ts b/packages/google-cloud-retail/src/v2/control_service_client.ts new file mode 100644 index 00000000000..1b1c792b370 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/control_service_client.ts @@ -0,0 +1,1633 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2 + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listControls: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'controls' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{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.cloud.retail.v2.ControlService', + 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.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.ControlService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ControlService, + 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 controlServiceStubMethods = [ + 'createControl', + 'deleteControl', + 'updateControl', + 'getControl', + 'listControls', + ]; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2.Control|Control} to create already exists, + * an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [Control]{@link google.cloud.retail.v2.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/control_service.create_control.js + * region_tag:retail_v2_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2.ICreateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest | undefined, + {} | undefined + ] + >; + createControl( + request: protos.google.cloud.retail.v2.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest | null | undefined, + {} | null | undefined + > + ): void; + createControl( + request: protos.google.cloud.retail.v2.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest | null | undefined, + {} | null | undefined + > + ): void; + createControl( + request?: protos.google.cloud.retail.v2.ICreateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IControl, + | protos.google.cloud.retail.v2.ICreateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } + /** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2.Control|Control} to delete does not exist, + * a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/control_service.delete_control.js + * region_tag:retail_v2_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2.IDeleteControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest | undefined, + {} | undefined + ] + >; + deleteControl( + request: protos.google.cloud.retail.v2.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request: protos.google.cloud.retail.v2.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request?: protos.google.cloud.retail.v2.IDeleteControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } + /** + * Updates a Control. + * + * {@link google.cloud.retail.v2.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2.Control|Control} to update does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Control|Control} to update. The following are NOT + * supported: + * + * * {@link google.cloud.retail.v2.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/control_service.update_control.js + * region_tag:retail_v2_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2.IUpdateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest | undefined, + {} | undefined + ] + >; + updateControl( + request: protos.google.cloud.retail.v2.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest | null | undefined, + {} | null | undefined + > + ): void; + updateControl( + request: protos.google.cloud.retail.v2.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest | null | undefined, + {} | null | undefined + > + ): void; + updateControl( + request?: protos.google.cloud.retail.v2.IUpdateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IControl, + | protos.google.cloud.retail.v2.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest | 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({ + 'control.name': request.control!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } + /** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/control_service.get_control.js + * region_tag:retail_v2_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2.IGetControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | undefined, + {} | undefined + ] + >; + getControl( + request: protos.google.cloud.retail.v2.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request: protos.google.cloud.retail.v2.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request?: protos.google.cloud.retail.v2.IGetControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls by their parent + * {@link google.cloud.retail.v2.Catalog|Catalog}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2.Control}. + * 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2.IListControlsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IControl[], + protos.google.cloud.retail.v2.IListControlsRequest | null, + protos.google.cloud.retail.v2.IListControlsResponse + ] + >; + listControls( + request: protos.google.cloud.retail.v2.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse | null | undefined, + protos.google.cloud.retail.v2.IControl + > + ): void; + listControls( + request: protos.google.cloud.retail.v2.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse | null | undefined, + protos.google.cloud.retail.v2.IControl + > + ): void; + listControls( + request?: protos.google.cloud.retail.v2.IListControlsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + | protos.google.cloud.retail.v2.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IControl + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse | null | undefined, + protos.google.cloud.retail.v2.IControl + > + ): Promise< + [ + protos.google.cloud.retail.v2.IControl[], + protos.google.cloud.retail.v2.IListControlsRequest | null, + protos.google.cloud.retail.v2.IListControlsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2.Control} 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2.IListControlsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/control_service.list_controls.js + * region_tag:retail_v2_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2.IListControlsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/control_service_client_config.json b/packages/google-cloud-retail/src/v2/control_service_client_config.json new file mode 100644 index 00000000000..004c29452fe --- /dev/null +++ b/packages/google-cloud-retail/src/v2/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ControlService": { + "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": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/control_service_proto_list.json b/packages/google-cloud-retail/src/v2/control_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/control_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/gapic_metadata.json b/packages/google-cloud-retail/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..63577bc31d6 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/gapic_metadata.json @@ -0,0 +1,571 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/index.ts b/packages/google-cloud-retail/src/v2/index.ts new file mode 100644 index 00000000000..a7e4f6ba79f --- /dev/null +++ b/packages/google-cloud-retail/src/v2/index.ts @@ -0,0 +1,26 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/packages/google-cloud-retail/src/v2/prediction_service_client.ts b/packages/google-cloud-retail/src/v2/prediction_service_client.ts new file mode 100644 index 00000000000..9dc1b1aecf5 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/prediction_service_client.ts @@ -0,0 +1,1239 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2 + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{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.cloud.retail.v2.PredictionService', + 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.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.PredictionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.PredictionService, + 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 predictionServiceStubMethods = ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.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.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Managing serving configurations] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * + * Don't set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id} to a + * random unique ID and leave + * {@link google.cloud.retail.v2.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return. Set this property to the number of + * prediction results needed. If zero, the service will choose a reasonable + * default. The maximum allowed value is 100. Values above 100 will be coerced + * to 100. + * @param {string} request.pageToken + * This field is not used; leave it unset. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @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 [PredictResponse]{@link google.cloud.retail.v2.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/prediction_service.predict.js + * region_tag:retail_v2_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | undefined, + {} | undefined + ] + >; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request: protos.google.cloud.retail.v2.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request?: protos.google.cloud.retail.v2.IPredictRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IPredictResponse, + protos.google.cloud.retail.v2.IPredictRequest | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/prediction_service_client_config.json b/packages/google-cloud-retail/src/v2/prediction_service_client_config.json new file mode 100644 index 00000000000..9ab95d31a0c --- /dev/null +++ b/packages/google-cloud-retail/src/v2/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.PredictionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/prediction_service_proto_list.json b/packages/google-cloud-retail/src/v2/prediction_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/prediction_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/product_service_client.ts b/packages/google-cloud-retail/src/v2/product_service_client.ts new file mode 100644 index 00000000000..b43eeb496f0 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/product_service_client.ts @@ -0,0 +1,3254 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2.Product|Product} information + * of the customer's website. + * @class + * @memberof v2 + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listProducts: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'products' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportProductsResponse' + ) as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata' + ) as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryResponse' + ) as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.SetInventoryMetadata' + ) as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesResponse' + ) as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.AddLocalInventoriesMetadata' + ) as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesResponse' + ) as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RemoveLocalInventoriesMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata) + ), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata) + ), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata) + ), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind( + removeFulfillmentPlacesResponse + ), + removeFulfillmentPlacesMetadata.decode.bind( + removeFulfillmentPlacesMetadata + ) + ), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata) + ), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind( + removeLocalInventoriesResponse + ), + removeLocalInventoriesMetadata.decode.bind( + removeLocalInventoriesMetadata + ) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.ProductService', + 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.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.ProductService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ProductService, + 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 productServiceStubMethods = [ + 'createProduct', + 'getProduct', + 'listProducts', + 'updateProduct', + 'deleteProduct', + 'importProducts', + 'setInventory', + 'addFulfillmentPlaces', + 'removeFulfillmentPlaces', + 'addLocalInventories', + 'removeLocalInventories', + ]; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.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.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The {@link google.cloud.retail.v2.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the {@link google.cloud.retail.v2.Product|Product}, + * which will become the final component of the + * {@link google.cloud.retail.v2.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2.Product|Product}s with the same + * {@link google.cloud.retail.v2.CreateProductRequest.parent|parent}. Otherwise, an + * ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is 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 [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.create_product.js + * region_tag:retail_v2_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest | undefined, + {} | undefined + ] + >; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest | null | undefined, + {} | null | undefined + > + ): void; + createProduct( + request: protos.google.cloud.retail.v2.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest | null | undefined, + {} | null | undefined + > + ): void; + createProduct( + request?: protos.google.cloud.retail.v2.ICreateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IProduct, + | protos.google.cloud.retail.v2.ICreateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.ICreateProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2.Product|Product} does not exist, + * a NOT_FOUND error is 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 [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.get_product.js + * region_tag:retail_v2_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | undefined, + {} | undefined + ] + >; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request: protos.google.cloud.retail.v2.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request?: protos.google.cloud.retail.v2.IGetProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IGetProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } + /** + * Updates a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not exist + * and + * {@link google.cloud.retail.v2.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, a new {@link google.cloud.retail.v2.Product|Product} will be created. In + * this situation, `update_mask` is ignored. + * @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 [Product]{@link google.cloud.retail.v2.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.update_product.js + * region_tag:retail_v2_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest | undefined, + {} | undefined + ] + >; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest | null | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request: protos.google.cloud.retail.v2.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest | null | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request?: protos.google.cloud.retail.v2.IUpdateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IProduct, + | protos.google.cloud.retail.v2.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct, + protos.google.cloud.retail.v2.IUpdateProductRequest | 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({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } + /** + * Deletes a {@link google.cloud.retail.v2.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to delete does not exist, + * a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2.Product|Product} to delete can neither be a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} member nor a + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} with more than one + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2.Product|Product} will be 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 [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/product_service.delete_product.js + * region_tag:retail_v2_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest | undefined, + {} | undefined + ] + >; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request: protos.google.cloud.retail.v2.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request?: protos.google.cloud.retail.v2.IDeleteProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + + /** + * Bulk import of multiple {@link google.cloud.retail.v2.Product|Product}s. + * + * Request processing may be synchronous. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported `products` to update. If + * not set, all fields are updated. + * @param {google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * {@link google.longrunning.Operation|Operation}. + * + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * {@link google.cloud.retail.v2.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request: protos.google.cloud.retail.v2.IImportProductsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request?: protos.google.cloud.retail.v2.IImportProductsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.import_products.js + * region_tag:retail_v2_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.ImportProductsResponse, + protos.google.cloud.retail.v2.ImportMetadata + > + > { + 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.importProducts, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.ImportProductsResponse, + protos.google.cloud.retail.v2.ImportMetadata + >; + } + /** + * Updates inventory information for a + * {@link google.cloud.retail.v2.Product|Product} while respecting the last update + * timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link |Operation}s will be obsolete after 1 day, and + * {@link |GetOperation} API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the {@link |Operation}s associated with the + * stale updates will not be marked as {@link Operation.done|done} until being + * obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link google.cloud.retail.v2.Product.name|SetInventoryRequest.inventory.name} + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.Product|Product} named in + * {@link google.cloud.retail.v2.Product.name|Product.name}, regardless of whether + * or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update does not have + * existing inventory information, the provided inventory information will be + * inserted. + * + * If the {@link google.cloud.retail.v2.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} with name + * {@link google.cloud.retail.v2.Product.name|Product.name} is not found, the + * inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2.Product|Product} is created. If set to + * false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request: protos.google.cloud.retail.v2.ISetInventoryRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request?: protos.google.cloud.retail.v2.ISetInventoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >, + 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({ + 'inventory.name': request.inventory!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } + /** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.set_inventory.js + * region_tag:retail_v2_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.SetInventoryResponse, + protos.google.cloud.retail.v2.SetInventoryMetadata + > + > { + 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.setInventory, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.SetInventoryResponse, + protos.google.cloud.retail.v2.SetInventoryMetadata + >; + } + /** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link |Operation}s will be obsolete after 1 day, and + * {@link |GetOperation} API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the {@link |Operation}s associated with the + * stale updates will not be marked as {@link Operation.done|done} until being + * obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type}. Duplicate + * IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IAddFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.AddFulfillmentPlacesMetadata + > + > { + 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.addFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.AddFulfillmentPlacesMetadata + >; + } + /** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link |Operation}s will be obsolete after 1 day, and + * {@link |GetOperation} API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the {@link |Operation}s associated with the + * stale updates will not be marked as {@link Operation.done|done} until being + * obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}, such as + * the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the fulfillment information will still be processed and retained for + * at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_fulfillment_places.js + * region_tag:retail_v2_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + > + > { + 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.removeFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.RemoveFulfillmentPlacesMetadata + >; + } + /** + * Updates local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link |Operation}s will be obsolete after 1 day, and + * {@link |GetOperation} API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the {@link |Operation}s associated with the + * stale updates will not be marked as {@link Operation.done|done} until being + * obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory will still be processed and retained for at most + * 1 day and processed once the {@link google.cloud.retail.v2.Product|Product} is + * created. If set to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2.IAddLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.add_local_inventories.js + * region_tag:retail_v2_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2.AddLocalInventoriesMetadata + > + > { + 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.addLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2.AddLocalInventoriesMetadata + >; + } + /** + * Remove local inventory information for a + * {@link google.cloud.retail.v2.Product|Product} at a list of places at a removal + * timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2.Product|Product} queried by + * {@link google.cloud.retail.v2.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link |Operation}s will be obsolete after 1 day, and + * {@link |GetOperation} API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the {@link |Operation}s associated with the + * stale updates will not be marked as {@link Operation.done|done} until being + * obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of {@link google.cloud.retail.v2.Product|Product}, + * such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2.Product|Product}, regardless of whether or not it + * exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2.Product|Product} is not + * found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2.Product|Product} is created. If set to false, a + * NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2.IRemoveLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/product_service.remove_local_inventories.js + * region_tag:retail_v2_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.RemoveLocalInventoriesMetadata + > + > { + 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.removeLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.RemoveLocalInventoriesMetadata + >; + } + /** + * Gets a list of {@link google.cloud.retail.v2.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is 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 Array of [Product]{@link google.cloud.retail.v2.Product}. + * 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest | null, + protos.google.cloud.retail.v2.IListProductsResponse + ] + >; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse | null | undefined, + protos.google.cloud.retail.v2.IProduct + > + ): void; + listProducts( + request: protos.google.cloud.retail.v2.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse | null | undefined, + protos.google.cloud.retail.v2.IProduct + > + ): void; + listProducts( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + | protos.google.cloud.retail.v2.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IProduct + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListProductsRequest, + protos.google.cloud.retail.v2.IListProductsResponse | null | undefined, + protos.google.cloud.retail.v2.IProduct + > + ): Promise< + [ + protos.google.cloud.retail.v2.IProduct[], + protos.google.cloud.retail.v2.IListProductsRequest | null, + protos.google.cloud.retail.v2.IListProductsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @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 [Product]{@link google.cloud.retail.v2.Product} 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2.Product|Product}s under this branch, regardless of + * whether or not this branch exists, a PERMISSION_DENIED error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2.ListProductsRequest.filter|filter} is unset. + * * List {@link google.cloud.retail.v2.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2.Product|Product}s sharing the same + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s bundled in a + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2.Product|Product}s with a partibular type. + * For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2.Product|Product} or + * {@link google.cloud.retail.v2.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2.Product|Product} does not exist, a NOT_FOUND error + * is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2.Product|Product} to return in the + * responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2.Product.name|Product.name} + * * {@link google.cloud.retail.v2.Product.id|Product.id} + * * {@link google.cloud.retail.v2.Product.title|Product.title} + * * {@link google.cloud.retail.v2.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2.Product.images|Product.images} + * * {@link google.cloud.retail.v2.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2.Product.name|Product.name} is always returned no + * matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/product_service.list_products.js + * region_tag:retail_v2_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2.IListProductsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/product_service_client_config.json b/packages/google-cloud-retail/src/v2/product_service_client_config.json new file mode 100644 index 00000000000..32245ac6134 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ProductService": { + "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 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/product_service_proto_list.json b/packages/google-cloud-retail/src/v2/product_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/product_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/search_service_client.ts b/packages/google-cloud-retail/src/v2/search_service_client.ts new file mode 100644 index 00000000000..4f20e8f9bc0 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/search_service_client.ts @@ -0,0 +1,1977 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2 + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + search: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'results' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{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.cloud.retail.v2.SearchService', + 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.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.SearchService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.SearchService, + 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 searchServiceStubMethods = ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. + * 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest | null, + protos.google.cloud.retail.v2.ISearchResponse + ] + >; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult + > + ): void; + search( + request: protos.google.cloud.retail.v2.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult + > + ): void; + search( + request?: protos.google.cloud.retail.v2.ISearchRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.ISearchRequest, + protos.google.cloud.retail.v2.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2.SearchResponse.ISearchResult + > + ): Promise< + [ + protos.google.cloud.retail.v2.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2.ISearchRequest | null, + protos.google.cloud.retail.v2.ISearchResponse + ] + > | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult} 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `search`, 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.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2.Product|Product}s to return. If + * unspecified, defaults to a reasonable value. The maximum allowed value is + * 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2.SearchService.Search|SearchService.Search} must + * match the call that provided the page token. Otherwise, an INVALID_ARGUMENT + * error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if {@link google.cloud.retail.v2.SearchRequest.page_token|page_token} + * is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2.SearchRequest.filter|SearchRequest.filter} for + * more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2.Product|Product} object. Leave it + * unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s attributes, + * {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s attributes. The + * attributes from all the matching + * {@link google.cloud.retail.v2.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2.Product|Product}s or + * {@link google.cloud.retail.v2.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/search_service.search.js + * region_tag:retail_v2_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/search_service_client_config.json b/packages/google-cloud-retail/src/v2/search_service_client_config.json new file mode 100644 index 00000000000..5132c12db6d --- /dev/null +++ b/packages/google-cloud-retail/src/v2/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2.SearchService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/search_service_proto_list.json b/packages/google-cloud-retail/src/v2/search_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/search_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2/serving_config_service_client.ts new file mode 100644 index 00000000000..d23ae556e17 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/serving_config_service_client.ts @@ -0,0 +1,1824 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2 + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listServingConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'servingConfigs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{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.cloud.retail.v2.ServingConfigService', + 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.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.ServingConfigService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ServingConfigService, + 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 servingConfigServiceStubMethods = [ + 'createServingConfig', + 'deleteServingConfig', + 'updateServingConfig', + 'getServingConfig', + 'listServingConfigs', + 'addControl', + 'removeControl', + ]; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a ServingConfig. + * + * A maximum of 100 {@link google.cloud.retail.v2.ServingConfig|ServingConfig}s are + * allowed in a {@link google.cloud.retail.v2.Catalog|Catalog}, otherwise a + * FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.create_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest | undefined, + {} | undefined + ] + >; + createServingConfig( + request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } + /** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.delete_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest | undefined, + {} | undefined + ] + >; + deleteServingConfig( + request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } + /** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.update_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest | undefined, + {} | undefined + ] + >; + updateServingConfig( + request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest | 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({ + 'serving_config.name': request.servingConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } + /** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.get_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest | undefined, + {} | undefined + ] + >; + getServingConfig( + request: protos.google.cloud.retail.v2.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request: protos.google.cloud.retail.v2.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest | null | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } + /** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is 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 [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.add_control.js + * region_tag:retail_v2_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2.IAddControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | undefined, + {} | undefined + ] + >; + addControl( + request: protos.google.cloud.retail.v2.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request: protos.google.cloud.retail.v2.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request?: protos.google.cloud.retail.v2.IAddControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } + /** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @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 [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.remove_control.js + * region_tag:retail_v2_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2.IRemoveControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest | undefined, + {} | undefined + ] + >; + removeControl( + request: protos.google.cloud.retail.v2.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest | null | undefined, + {} | null | undefined + > + ): void; + removeControl( + request: protos.google.cloud.retail.v2.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest | null | undefined, + {} | null | undefined + > + ): void; + removeControl( + request?: protos.google.cloud.retail.v2.IRemoveControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IServingConfig, + | protos.google.cloud.retail.v2.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. + * 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig[], + protos.google.cloud.retail.v2.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2.IListServingConfigsResponse + ] + >; + listServingConfigs( + request: protos.google.cloud.retail.v2.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + | protos.google.cloud.retail.v2.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IServingConfig + > + ): void; + listServingConfigs( + request: protos.google.cloud.retail.v2.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + | protos.google.cloud.retail.v2.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IServingConfig + > + ): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + | protos.google.cloud.retail.v2.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IServingConfig + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + | protos.google.cloud.retail.v2.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2.IServingConfig + > + ): Promise< + [ + protos.google.cloud.retail.v2.IServingConfig[], + protos.google.cloud.retail.v2.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2.IListServingConfigsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2.ServingConfig} 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/serving_config_service.list_serving_configs.js + * region_tag:retail_v2_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/serving_config_service_client_config.json b/packages/google-cloud-retail/src/v2/serving_config_service_client_config.json new file mode 100644 index 00000000000..3f5419b8c62 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ServingConfigService": { + "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": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/serving_config_service_proto_list.json b/packages/google-cloud-retail/src/v2/serving_config_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/serving_config_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2/user_event_service_client.ts b/packages/google-cloud-retail/src/v2/user_event_service_client.ts new file mode 100644 index 00000000000..e6e38be5774 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/user_event_service_client.ts @@ -0,0 +1,1734 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2 + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=projects/*/locations/*/operations/*}', + additional_bindings: [ + { + get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + }, + {get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}'}, + {get: '/v2/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=projects/*/locations/*}/operations', + additional_bindings: [ + {get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations'}, + {get: '/v2/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeUserEventsResponse' + ) as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.PurgeMetadata' + ) as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportUserEventsResponse' + ) as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.ImportMetadata' + ) as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsResponse' + ) as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.RejoinUserEventsMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata) + ), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata) + ), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.UserEventService', + 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.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2.UserEventService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.UserEventService, + 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 userEventServiceStubMethods = [ + 'writeUserEvent', + 'collectUserEvent', + 'purgeUserEvents', + 'importUserEvents', + 'rejoinUserEvents', + ]; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.write_user_event.js + * region_tag:retail_v2_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest | undefined, + {} | undefined + ] + >; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest | null | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request: protos.google.cloud.retail.v2.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest | null | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2.IWriteUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2.IUserEvent, + | protos.google.cloud.retail.v2.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2.IUserEvent, + protos.google.cloud.retail.v2.IWriteUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @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 [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.collect_user_event.js + * region_tag:retail_v2_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest | undefined, + {} | undefined + ] + >; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest | null | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request: protos.google.cloud.retail.v2.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest | null | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2.ICollectUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2.ICollectUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + + /** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2.UserEvent.event_type|UserEvent.event_type} string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2.IPurgeUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.purge_user_events.js + * region_tag:retail_v2_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.PurgeUserEventsResponse, + protos.google.cloud.retail.v2.PurgeMetadata + > + > { + 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.purgeUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.PurgeUserEventsResponse, + protos.google.cloud.retail.v2.PurgeMetadata + >; + } + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * `Operation.response` is of type `ImportResponse`. Note that it is + * possible for a subset of the items to be successfully inserted. + * `Operation.metadata` is of type `ImportMetadata`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request: protos.google.cloud.retail.v2.IImportUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request?: protos.google.cloud.retail.v2.IImportUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.import_user_events.js + * region_tag:retail_v2_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.ImportUserEventsResponse, + protos.google.cloud.retail.v2.ImportMetadata + > + > { + 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.importUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.ImportUserEventsResponse, + protos.google.cloud.retail.v2.ImportMetadata + >; + } + /** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2.IRejoinUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/user_event_service.rejoin_user_events.js + * region_tag:retail_v2_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2.RejoinUserEventsResponse, + protos.google.cloud.retail.v2.RejoinUserEventsMetadata + > + > { + 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.rejoinUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2.RejoinUserEventsResponse, + protos.google.cloud.retail.v2.RejoinUserEventsMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2/user_event_service_client_config.json b/packages/google-cloud-retail/src/v2/user_event_service_client_config.json new file mode 100644 index 00000000000..a3938b37468 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2.UserEventService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2/user_event_service_proto_list.json b/packages/google-cloud-retail/src/v2/user_event_service_proto_list.json new file mode 100644 index 00000000000..cd900335805 --- /dev/null +++ b/packages/google-cloud-retail/src/v2/user_event_service_proto_list.json @@ -0,0 +1,19 @@ +[ + "../../protos/google/cloud/retail/v2/catalog.proto", + "../../protos/google/cloud/retail/v2/catalog_service.proto", + "../../protos/google/cloud/retail/v2/common.proto", + "../../protos/google/cloud/retail/v2/completion_service.proto", + "../../protos/google/cloud/retail/v2/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/prediction_service.proto", + "../../protos/google/cloud/retail/v2/product.proto", + "../../protos/google/cloud/retail/v2/product_service.proto", + "../../protos/google/cloud/retail/v2/promotion.proto", + "../../protos/google/cloud/retail/v2/purge_config.proto", + "../../protos/google/cloud/retail/v2/search_service.proto", + "../../protos/google/cloud/retail/v2/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_service.proto", + "../../protos/google/cloud/retail/v2/user_event.proto", + "../../protos/google/cloud/retail/v2/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts b/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts new file mode 100644 index 00000000000..64f1bcf3108 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/catalog_service_client.ts @@ -0,0 +1,2588 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2alpha + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listCatalogs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'catalogs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{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.cloud.retail.v2alpha.CatalogService', + 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.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.CatalogService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CatalogService, + 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 catalogServiceStubMethods = [ + 'listCatalogs', + 'updateCatalog', + 'setDefaultBranch', + 'getDefaultBranch', + 'getCompletionConfig', + 'updateCompletionConfig', + 'getAttributesConfig', + 'updateAttributesConfig', + 'addCatalogAttribute', + 'removeCatalogAttribute', + 'replaceCatalogAttribute', + ]; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Updates the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is 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 [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_catalog.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest | undefined, + {} | undefined + ] + >; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + | protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + | protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request?: protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + | protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICatalog, + | protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICatalog, + protos.google.cloud.retail.v2alpha.IUpdateCatalogRequest | 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({ + 'catalog.name': request.catalog!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } + /** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2alpha.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2alpha.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2alpha.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.set_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.ISetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } + /** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2alpha.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @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 [GetDefaultBranchResponse]{@link google.cloud.retail.v2alpha.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_default_branch.js + * region_tag:retail_v2alpha_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2alpha.IGetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig + * @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 [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + ( + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | undefined + ), + {} | undefined + ] + >; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + ( + | protos.google.cloud.retail.v2alpha.IGetCompletionConfigRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } + /** + * Updates the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2alpha.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2alpha.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2alpha.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_completion_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | undefined + ), + {} | undefined + ] + >; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompletionConfig, + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompletionConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateCompletionConfigRequest + | 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({ + 'completion_config.name': request.completionConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig( + request, + options, + callback + ); + } + /** + * Gets an {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @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 [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.get_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | undefined + ), + {} | undefined + ] + >; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IGetAttributesConfigRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } + /** + * Updates the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2alpha.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.update_attributes_config.js + * region_tag:retail_v2alpha_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | undefined + ), + {} | undefined + ] + >; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateAttributesConfigRequest + | 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({ + 'attributes_config.name': request.attributesConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig( + request, + options, + callback + ); + } + /** + * Adds the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to add. + * @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 [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | undefined + ), + {} | undefined + ] + >; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IAddCatalogAttributeRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } + /** + * Removes the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to remove. + * @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 [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | undefined + ), + {} | undefined + ] + >; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IRemoveCatalogAttributeRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute( + request, + options, + callback + ); + } + /** + * Replaces the specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig} by + * updating the catalog attribute with the same + * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2alpha.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2alpha.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2alpha_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | undefined + ), + {} | undefined + ] + >; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IAttributesConfig, + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IAttributesConfig, + ( + | protos.google.cloud.retail.v2alpha.IReplaceCatalogAttributeRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute( + request, + options, + callback + ); + } + + /** + * Lists all the {@link google.cloud.retail.v2alpha.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is 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 Array of [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. + * 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest | null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ] + >; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + | protos.google.cloud.retail.v2alpha.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.ICatalog + > + ): void; + listCatalogs( + request: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + | protos.google.cloud.retail.v2alpha.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.ICatalog + > + ): void; + listCatalogs( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + | protos.google.cloud.retail.v2alpha.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.ICatalog + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + | protos.google.cloud.retail.v2alpha.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.ICatalog + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICatalog[], + protos.google.cloud.retail.v2alpha.IListCatalogsRequest | null, + protos.google.cloud.retail.v2alpha.IListCatalogsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @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 [Catalog]{@link google.cloud.retail.v2alpha.Catalog} 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Catalog|Catalog}s to + * return. If unspecified, defaults to 50. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2alpha.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/catalog_service.list_catalogs.js + * region_tag:retail_v2alpha_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2alpha.IListCatalogsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/catalog_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/catalog_service_client_config.json new file mode 100644 index 00000000000..08407daa19a --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CatalogService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/catalog_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/catalog_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/catalog_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts b/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts new file mode 100644 index 00000000000..95593a850d4 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/completion_service_client.ts @@ -0,0 +1,1427 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportCompletionDataResponse' + ) as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.CompletionService', + 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.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.CompletionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.CompletionService, + 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 completionServiceStubMethods = [ + 'completeQuery', + 'importCompletionData', + ]; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2alpha.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2alpha.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @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 [CompleteQueryResponse]{@link google.cloud.retail.v2alpha.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.complete_query.js + * region_tag:retail_v2alpha_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest | undefined, + {} | undefined + ] + >; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + | protos.google.cloud.retail.v2alpha.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + | protos.google.cloud.retail.v2alpha.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request?: protos.google.cloud.retail.v2alpha.ICompleteQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + | protos.google.cloud.retail.v2alpha.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + | protos.google.cloud.retail.v2alpha.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.ICompleteQueryResponse, + protos.google.cloud.retail.v2alpha.ICompleteQueryRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + + /** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request?: protos.google.cloud.retail.v2alpha.IImportCompletionDataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/completion_service.import_completion_data.js + * region_tag:retail_v2alpha_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.ImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + > + > { + 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.importCompletionData, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.ImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/completion_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/completion_service_client_config.json new file mode 100644 index 00000000000..ac2795a5fb1 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.CompletionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/completion_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/completion_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/completion_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/control_service_client.ts b/packages/google-cloud-retail/src/v2alpha/control_service_client.ts new file mode 100644 index 00000000000..bfa3e9c0feb --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/control_service_client.ts @@ -0,0 +1,1723 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2alpha + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listControls: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'controls' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{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.cloud.retail.v2alpha.ControlService', + 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.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.ControlService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ControlService, + 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 controlServiceStubMethods = [ + 'createControl', + 'deleteControl', + 'updateControl', + 'getControl', + 'listControls', + ]; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.create_control.js + * region_tag:retail_v2alpha_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest | undefined, + {} | undefined + ] + >; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createControl( + request: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createControl( + request?: protos.google.cloud.retail.v2alpha.ICreateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.ICreateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.ICreateControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } + /** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2alpha.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.delete_control.js + * region_tag:retail_v2alpha_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest | undefined, + {} | undefined + ] + >; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request?: protos.google.cloud.retail.v2alpha.IDeleteControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } + /** + * Updates a Control. + * + * {@link google.cloud.retail.v2alpha.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2alpha.Control|Control} to delete does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2alpha.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.update_control.js + * region_tag:retail_v2alpha_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest | undefined, + {} | undefined + ] + >; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateControl( + request: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateControl( + request?: protos.google.cloud.retail.v2alpha.IUpdateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IUpdateControlRequest | 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({ + 'control.name': request.control!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } + /** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2alpha.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.get_control.js + * region_tag:retail_v2alpha_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest | undefined, + {} | undefined + ] + >; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request: protos.google.cloud.retail.v2alpha.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request?: protos.google.cloud.retail.v2alpha.IGetControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IControl, + | protos.google.cloud.retail.v2alpha.IGetControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl, + protos.google.cloud.retail.v2alpha.IGetControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2alpha.Control}. + * 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest | null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ] + >; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + | protos.google.cloud.retail.v2alpha.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IControl + > + ): void; + listControls( + request: protos.google.cloud.retail.v2alpha.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + | protos.google.cloud.retail.v2alpha.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IControl + > + ): void; + listControls( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + | protos.google.cloud.retail.v2alpha.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IControl + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListControlsRequest, + | protos.google.cloud.retail.v2alpha.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IControl + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IControl[], + protos.google.cloud.retail.v2alpha.IListControlsRequest | null, + protos.google.cloud.retail.v2alpha.IListControlsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2alpha.Control} 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2alpha.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/control_service.list_controls.js + * region_tag:retail_v2alpha_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2alpha.IListControlsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/control_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/control_service_client_config.json new file mode 100644 index 00000000000..9a86d786b23 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ControlService": { + "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": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/control_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/control_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/control_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/gapic_metadata.json b/packages/google-cloud-retail/src/v2alpha/gapic_metadata.json new file mode 100644 index 00000000000..89ef22cebb6 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/gapic_metadata.json @@ -0,0 +1,669 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2alpha", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "PurgeProducts": { + "methods": [ + "purgeProducts" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/index.ts b/packages/google-cloud-retail/src/v2alpha/index.ts new file mode 100644 index 00000000000..74f290ddf79 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {ModelServiceClient} from './model_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/packages/google-cloud-retail/src/v2alpha/model_service_client.ts b/packages/google-cloud-retail/src/v2alpha/model_service_client.ts new file mode 100644 index 00000000000..7b82d9b2df3 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/model_service_client.ts @@ -0,0 +1,1986 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/model_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './model_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the Predict() api. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). + * + * This service allows customers to e.g.: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * @class + * @memberof v2alpha + */ +export class ModelServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + modelServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ModelServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ModelServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ModelServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listModels: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'models' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const createModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.Model' + ) as gax.protobuf.Type; + const createModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.CreateModelMetadata' + ) as gax.protobuf.Type; + const tuneModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.TuneModelResponse' + ) as gax.protobuf.Type; + const tuneModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.TuneModelMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + createModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createModelResponse.decode.bind(createModelResponse), + createModelMetadata.decode.bind(createModelMetadata) + ), + tuneModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + tuneModelResponse.decode.bind(tuneModelResponse), + tuneModelMetadata.decode.bind(tuneModelMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ModelService', + 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.modelServiceStub) { + return this.modelServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ModelService. + this.modelServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.ModelService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ModelService, + 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 modelServiceStubMethods = [ + 'createModel', + 'pauseModel', + 'resumeModel', + 'deleteModel', + 'listModels', + 'updateModel', + 'tuneModel', + ]; + for (const methodName of modelServiceStubMethods) { + const callPromise = this.modelServiceStub.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.modelServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Pauses the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to pause. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Model]{@link google.cloud.retail.v2alpha.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.pause_model.js + * region_tag:retail_v2alpha_generated_ModelService_PauseModel_async + */ + pauseModel( + request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest | undefined, + {} | undefined + ] + >; + pauseModel( + request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): void; + pauseModel( + request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): void; + pauseModel( + request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IModel, + | protos.google.cloud.retail.v2alpha.IPauseModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseModel(request, options, callback); + } + /** + * Resumes the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to resume. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Model]{@link google.cloud.retail.v2alpha.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.resume_model.js + * region_tag:retail_v2alpha_generated_ModelService_ResumeModel_async + */ + resumeModel( + request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest | undefined, + {} | undefined + ] + >; + resumeModel( + request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): void; + resumeModel( + request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): void; + resumeModel( + request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IModel, + | protos.google.cloud.retail.v2alpha.IResumeModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeModel(request, options, callback); + } + /** + * Deletes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the [Model] to delete. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.delete_model.js + * region_tag:retail_v2alpha_generated_ModelService_DeleteModel_async + */ + deleteModel( + request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest | undefined, + {} | undefined + ] + >; + deleteModel( + request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteModel( + request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteModel( + request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteModel(request, options, callback); + } + /** + * Update of model metadata. Only fields that + * currently can be updated are: filtering_option, periodic_tuning_state. + * If other values are provided, this API method will ignore them. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Model} request.model + * Required. The body of the updated [Model]. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, will by default update all fields. + * @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 [Model]{@link google.cloud.retail.v2alpha.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.update_model.js + * region_tag:retail_v2alpha_generated_ModelService_UpdateModel_async + */ + updateModel( + request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest | undefined, + {} | undefined + ] + >; + updateModel( + request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): void; + updateModel( + request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): void; + updateModel( + request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IModel, + | protos.google.cloud.retail.v2alpha.IUpdateModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest | 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({ + 'model.name': request.model!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateModel(request, options, callback); + } + + /** + * Creates a new model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource under which to create the model. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {google.cloud.retail.v2alpha.Model} request.model + * Required. The payload of the [Model] to create. + * @param {boolean} [request.dryRun] + * Optional. Whether to run a dry_run to validate the request (without + * actually creating the model). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.create_model.js + * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async + */ + createModel( + request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createModel( + request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createModel( + request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createModel( + request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createModel(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.create_model.js + * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async + */ + async checkCreateModelProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.Model, + protos.google.cloud.retail.v2alpha.CreateModelMetadata + > + > { + 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.createModel, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.Model, + protos.google.cloud.retail.v2alpha.CreateModelMetadata + >; + } + /** + * Tunes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the model to tune. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.tune_model.js + * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async + */ + tuneModel( + request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + tuneModel( + request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + tuneModel( + request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + tuneModel( + request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.tuneModel(request, options, callback); + } + /** + * Check the status of the long running operation returned by `tuneModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.tune_model.js + * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async + */ + async checkTuneModelProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.TuneModelResponse, + protos.google.cloud.retail.v2alpha.TuneModelMetadata + > + > { + 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.tuneModel, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.TuneModelResponse, + protos.google.cloud.retail.v2alpha.TuneModelMetadata + >; + } + /** + * Lists all the models linked to this event store. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @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 [Model]{@link google.cloud.retail.v2alpha.Model}. + * 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModels( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel[], + protos.google.cloud.retail.v2alpha.IListModelsRequest | null, + protos.google.cloud.retail.v2alpha.IListModelsResponse + ] + >; + listModels( + request: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2alpha.IModel + > + ): void; + listModels( + request: protos.google.cloud.retail.v2alpha.IListModelsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2alpha.IModel + > + ): void; + listModels( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + | protos.google.cloud.retail.v2alpha.IListModelsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IModel + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2alpha.IModel + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IModel[], + protos.google.cloud.retail.v2alpha.IListModelsRequest | null, + protos.google.cloud.retail.v2alpha.IListModelsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listModels(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @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 [Model]{@link google.cloud.retail.v2alpha.Model} 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModelsStream( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.createStream( + this.innerApiCalls.listModels as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listModels`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Model]{@link google.cloud.retail.v2alpha.Model}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/model_service.list_models.js + * region_tag:retail_v2alpha_generated_ModelService_ListModels_async + */ + listModelsAsync( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.asyncIterate( + this.innerApiCalls['listModels'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.modelServiceStub && !this._terminated) { + return this.modelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/model_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/model_service_client_config.json new file mode 100644 index 00000000000..282bed5605e --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/model_service_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ModelService": { + "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": { + "CreateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ResumeModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TuneModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/model_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/model_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/model_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts b/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts new file mode 100644 index 00000000000..c9007825523 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/prediction_service_client.ts @@ -0,0 +1,1304 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2alpha + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{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.cloud.retail.v2alpha.PredictionService', + 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.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.PredictionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.PredictionService, + 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 predictionServiceStubMethods = ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.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.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Managing serving configurations] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * + * Don't set + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2alpha.UserInfo.user_id|UserInfo.user_id} to the + * same fixed ID for different users. If you are trying to receive + * non-personalized recommendations (not recommended; this can negatively + * impact model performance), instead set + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link google.cloud.retail.v2alpha.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return per page. Set this property + * to the number of prediction results needed. If zero, the service will + * choose a reasonable default. The maximum allowed value is 100. Values + * above 100 will be coerced to 100. + * @param {string} request.pageToken + * This field is not used for now; leave it unset. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @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 [PredictResponse]{@link google.cloud.retail.v2alpha.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/prediction_service.predict.js + * region_tag:retail_v2alpha_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | undefined, + {} | undefined + ] + >; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request: protos.google.cloud.retail.v2alpha.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request?: protos.google.cloud.retail.v2alpha.IPredictRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IPredictResponse, + protos.google.cloud.retail.v2alpha.IPredictRequest | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/prediction_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/prediction_service_client_config.json new file mode 100644 index 00000000000..ed48fe50101 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.PredictionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/prediction_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/prediction_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/prediction_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/product_service_client.ts b/packages/google-cloud-retail/src/v2alpha/product_service_client.ts new file mode 100644 index 00000000000..723bc9e25a3 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/product_service_client.ts @@ -0,0 +1,3568 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2alpha.Product|Product} + * information of the customer's website. + * @class + * @memberof v2alpha + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listProducts: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'products' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const purgeProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsResponse' + ) as gax.protobuf.Type; + const purgeProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeProductsMetadata' + ) as gax.protobuf.Type; + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportProductsResponse' + ) as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata' + ) as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryResponse' + ) as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.SetInventoryMetadata' + ) as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesResponse' + ) as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata' + ) as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse' + ) as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeProductsResponse.decode.bind(purgeProductsResponse), + purgeProductsMetadata.decode.bind(purgeProductsMetadata) + ), + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata) + ), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata) + ), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata) + ), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind( + removeFulfillmentPlacesResponse + ), + removeFulfillmentPlacesMetadata.decode.bind( + removeFulfillmentPlacesMetadata + ) + ), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata) + ), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind( + removeLocalInventoriesResponse + ), + removeLocalInventoriesMetadata.decode.bind( + removeLocalInventoriesMetadata + ) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ProductService', + 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.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.ProductService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ProductService, + 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 productServiceStubMethods = [ + 'createProduct', + 'getProduct', + 'listProducts', + 'updateProduct', + 'deleteProduct', + 'purgeProducts', + 'importProducts', + 'setInventory', + 'addFulfillmentPlaces', + 'removeFulfillmentPlaces', + 'addLocalInventories', + 'removeLocalInventories', + ]; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.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.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The {@link google.cloud.retail.v2alpha.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2alpha.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2alpha.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2alpha.Product|Product}s with the same + * {@link google.cloud.retail.v2alpha.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is 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 [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.create_product.js + * region_tag:retail_v2alpha_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest | undefined, + {} | undefined + ] + >; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createProduct( + request: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createProduct( + request?: protos.google.cloud.retail.v2alpha.ICreateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.ICreateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.ICreateProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2alpha.Product|Product} does not + * exist, a NOT_FOUND error is 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 [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.get_product.js + * region_tag:retail_v2alpha_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest | undefined, + {} | undefined + ] + >; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request: protos.google.cloud.retail.v2alpha.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request?: protos.google.cloud.retail.v2alpha.IGetProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IGetProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } + /** + * Updates a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2alpha.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, a new {@link google.cloud.retail.v2alpha.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @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 [Product]{@link google.cloud.retail.v2alpha.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.update_product.js + * region_tag:retail_v2alpha_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest | undefined, + {} | undefined + ] + >; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request?: protos.google.cloud.retail.v2alpha.IUpdateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IProduct, + | protos.google.cloud.retail.v2alpha.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct, + protos.google.cloud.retail.v2alpha.IUpdateProductRequest | 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({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } + /** + * Deletes a {@link google.cloud.retail.v2alpha.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2alpha.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} member nor a + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} with more than one + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2alpha.Product|Product} will be 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 [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.delete_product.js + * region_tag:retail_v2alpha_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest | undefined, + {} | undefined + ] + >; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request?: protos.google.cloud.retail.v2alpha.IDeleteProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + + /** + * Permanently deletes all selected + * {@link google.cloud.retail.v2alpha.Product|Product}s under a branch. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed offline. Depending on the number of + * {@link google.cloud.retail.v2alpha.Product|Product}s, this operation could take + * hours to complete. Before the operation completes, some + * {@link google.cloud.retail.v2alpha.Product|Product}s may still be returned by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Depending on the number of {@link google.cloud.retail.v2alpha.Product|Product}s, + * this operation could take hours to complete. To get a sample of + * {@link google.cloud.retail.v2alpha.Product|Product}s that would be deleted, set + * {@link google.cloud.retail.v2alpha.PurgeProductsRequest.force|PurgeProductsRequest.force} + * to false. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the branch under which the products are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}/branches/${branchId}` + * @param {string} request.filter + * Required. The filter string to specify the products to be deleted with a + * length limit of 5,000 characters. + * + * Empty string filter is not allowed. "*" implies delete all items in a + * branch. + * + * The eligible fields for filtering are: + * + * * `availability`: Double quoted + * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * string. + * * `create_time` : in ISO 8601 "zulu" format. + * + * Supported syntax: + * + * * Comparators (">", "<", ">=", "<=", "="). + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" + * * availability = "IN_STOCK" + * + * * Conjunctions ("AND") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER" + * + * * Disjunctions ("OR") + * Examples: + * * create_time <= "2015-02-13T17:05:46Z" OR availability = "IN_STOCK" + * + * * Can support nested queries. + * Examples: + * * (create_time <= "2015-02-13T17:05:46Z" AND availability = "PREORDER") + * OR (create_time >= "2015-02-14T13:03:32Z" AND availability = "IN_STOCK") + * + * * Filter Limits: + * * Filter should not contain more than 6 conditions. + * * Max nesting depth should not exceed 2 levels. + * + * Examples queries: + * * Delete back order products created before a timestamp. + * create_time <= "2015-02-13T17:05:46Z" OR availability = "BACKORDER" + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeProducts( + request: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeProducts( + request?: protos.google.cloud.retail.v2alpha.IPurgeProductsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeProducts(request, options, callback); + } + /** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + async checkPurgeProductsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.PurgeProductsResponse, + protos.google.cloud.retail.v2alpha.PurgeProductsMetadata + > + > { + 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.purgeProducts, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.PurgeProductsResponse, + protos.google.cloud.retail.v2alpha.PurgeProductsMetadata + >; + } + /** + * Bulk import of multiple {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * Request processing may be synchronous. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2alpha.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2alpha.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported 'products' to update. If + * not set, will by default update all fields. + * @param {google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification will be sent to + * specified Pub/Sub topic. The message data will be JSON string of a + * {@link google.longrunning.Operation|Operation}. + * + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that both + * `cloud-retail-customer-data-access@system.gserviceaccount.com` and + * `service-@gcp-sa-retail.iam.gserviceaccount.com` + * have the `pubsub.topics.publish` IAM permission on the topic. + * + * Only supported when + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {boolean} request.skipDefaultBranchProtection + * If true, will perform the FULL import even if it would delete a large + * proportion of the products in the default branch, which could potentially + * cause outages if you have live predict/search traffic. + * + * Only supported when + * {@link google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode|ImportProductsRequest.reconciliation_mode} + * is set to `FULL`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request?: protos.google.cloud.retail.v2alpha.IImportProductsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.import_products.js + * region_tag:retail_v2alpha_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.ImportProductsResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + > + > { + 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.importProducts, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.ImportProductsResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + >; + } + /** + * Updates inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) will overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update time for the specified inventory fields will be overwritten to the + * time of the + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product will be used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information will be preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link google.cloud.retail.v2alpha.Product.name|SetInventoryRequest.inventory.name} + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2alpha.Product|Product} named in + * {@link google.cloud.retail.v2alpha.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2alpha.Product|Product} to update has + * existing inventory information, the provided inventory information will be + * merged while respecting the last update time for each inventory field, + * using the provided or default value for + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2alpha.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2alpha.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2alpha.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} with + * name {@link google.cloud.retail.v2alpha.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2alpha.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request?: protos.google.cloud.retail.v2alpha.ISetInventoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >, + 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({ + 'inventory.name': request.inventory!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } + /** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.set_inventory.js + * region_tag:retail_v2alpha_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.SetInventoryResponse, + protos.google.cloud.retail.v2alpha.SetInventoryMetadata + > + > { + 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.setInventory, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.SetInventoryResponse, + protos.google.cloud.retail.v2alpha.SetInventoryMetadata + >; + } + /** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + > + > { + 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.addFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesMetadata + >; + } + /** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_fulfillment_places.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + > + > { + 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.removeFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesMetadata + >; + } + /** + * Updates local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2alpha.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IAddLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.add_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + > + > { + 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.addLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.AddLocalInventoriesMetadata + >; + } + /** + * Remove local inventory information for a + * {@link google.cloud.retail.v2alpha.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2alpha.Product|Product} queried by + * {@link google.cloud.retail.v2alpha.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2alpha.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2alpha.Product|Product}, regardless of whether or + * not it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2alpha.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2alpha.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2alpha.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.remove_local_inventories.js + * region_tag:retail_v2alpha_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + > + > { + 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.removeLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesMetadata + >; + } + /** + * Gets a list of {@link google.cloud.retail.v2alpha.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @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 [Product]{@link google.cloud.retail.v2alpha.Product}. + * 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest | null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ] + >; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + | protos.google.cloud.retail.v2alpha.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IProduct + > + ): void; + listProducts( + request: protos.google.cloud.retail.v2alpha.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + | protos.google.cloud.retail.v2alpha.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IProduct + > + ): void; + listProducts( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + | protos.google.cloud.retail.v2alpha.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IProduct + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListProductsRequest, + | protos.google.cloud.retail.v2alpha.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IProduct + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IProduct[], + protos.google.cloud.retail.v2alpha.IListProductsRequest | null, + protos.google.cloud.retail.v2alpha.IListProductsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @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 [Product]{@link google.cloud.retail.v2alpha.Product} 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2alpha.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to 100. The maximum allowed value is 1000. + * Values above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2alpha.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2alpha.Product|Product}s sharing the same + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s bundled in a + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2alpha.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2alpha.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2alpha.Product|Product} or + * {@link google.cloud.retail.v2alpha.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2alpha.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2alpha.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2alpha.Product.name|Product.name} + * * {@link google.cloud.retail.v2alpha.Product.id|Product.id} + * * {@link google.cloud.retail.v2alpha.Product.title|Product.title} + * * {@link google.cloud.retail.v2alpha.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2alpha.Product.images|Product.images} + * * {@link google.cloud.retail.v2alpha.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2alpha.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2alpha.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {boolean} request.requireTotalSize + * If true and + * {@link google.cloud.retail.v2alpha.ListProductsRequest.page_token|page_token} is + * empty, + * {@link google.cloud.retail.v2alpha.ListProductsResponse.total_size|ListProductsResponse.total_size} + * is set to the total count of matched items irrespective of pagination. + * + * Notice that setting this field to true affects the performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2alpha.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.list_products.js + * region_tag:retail_v2alpha_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2alpha.IListProductsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/product_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/product_service_client_config.json new file mode 100644 index 00000000000..416ef1ec1c3 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/product_service_client_config.json @@ -0,0 +1,104 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ProductService": { + "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 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "PurgeProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/product_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/product_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/product_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/search_service_client.ts b/packages/google-cloud-retail/src/v2alpha/search_service_client.ts new file mode 100644 index 00000000000..1c956ee9538 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/search_service_client.ts @@ -0,0 +1,2072 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2alpha + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + search: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'results' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{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.cloud.retail.v2alpha.SearchService', + 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.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.SearchService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.SearchService, + 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 searchServiceStubMethods = ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Please enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. + * 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest | null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ] + >; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult + > + ): void; + search( + request: protos.google.cloud.retail.v2alpha.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult + > + ): void; + search( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.ISearchRequest, + protos.google.cloud.retail.v2alpha.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2alpha.ISearchRequest | null, + protos.google.cloud.retail.v2alpha.ISearchResponse + ] + > | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult} 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `search`, 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.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2alpha.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2alpha.Product|Product}s to + * return. If unspecified, defaults to a reasonable value. The maximum allowed + * value is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2alpha.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2alpha.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the + * {@link google.cloud.retail.v2alpha.Product|Product}s deemed by the API as + * relevant) in search results. This field is only considered if + * {@link google.cloud.retail.v2alpha.SearchRequest.page_token|page_token} is + * unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2alpha.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See + * {@link google.cloud.retail.v2alpha.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2alpha.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2alpha.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2alpha.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2alpha.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold} request.relevanceThreshold + * The relevance threshold of the search results. + * + * Defaults to + * {@link google.cloud.retail.v2alpha.SearchRequest.RelevanceThreshold.HIGH|RelevanceThreshold.HIGH}, + * which means only the most relevant results are shown, and the least number + * of results are returned. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#relevance_thresholding). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s attributes, + * {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2alpha.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2alpha.Product|Product}s or + * {@link google.cloud.retail.v2alpha.LocalInventory|LocalInventory}s are merged + * and de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2alpha.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2alpha.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2alpha.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, please replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2alpha.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2alpha.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/search_service.search.js + * region_tag:retail_v2alpha_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2alpha.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/search_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/search_service_client_config.json new file mode 100644 index 00000000000..71a5a478c8c --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.SearchService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/search_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/search_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/search_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts new file mode 100644 index 00000000000..ea614bd0bc2 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client.ts @@ -0,0 +1,1923 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2alpha + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listServingConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'servingConfigs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{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.cloud.retail.v2alpha.ServingConfigService', + 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.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.ServingConfigService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha + .ServingConfigService, + 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 servingConfigServiceStubMethods = [ + 'createServingConfig', + 'deleteServingConfig', + 'updateServingConfig', + 'getServingConfig', + 'listServingConfigs', + 'addControl', + 'removeControl', + ]; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a ServingConfig. + * + * A maximum of 100 + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig}s are allowed in + * a {@link google.cloud.retail.v2alpha.Catalog|Catalog}, otherwise a + * FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.create_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + ( + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | undefined + ), + {} | undefined + ] + >; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request?: protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + ( + | protos.google.cloud.retail.v2alpha.ICreateServingConfigRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } + /** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.delete_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | undefined + ), + {} | undefined + ] + >; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.retail.v2alpha.IDeleteServingConfigRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } + /** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2alpha.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2alpha.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.update_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | undefined + ), + {} | undefined + ] + >; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + ( + | protos.google.cloud.retail.v2alpha.IUpdateServingConfigRequest + | 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({ + 'serving_config.name': request.servingConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } + /** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.get_serving_config.js + * region_tag:retail_v2alpha_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest | undefined, + {} | undefined + ] + >; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request?: protos.google.cloud.retail.v2alpha.IGetServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IGetServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } + /** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is 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 [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.add_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest | undefined, + {} | undefined + ] + >; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request: protos.google.cloud.retail.v2alpha.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request?: protos.google.cloud.retail.v2alpha.IAddControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IAddControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IAddControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } + /** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id} + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @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 [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.remove_control.js + * region_tag:retail_v2alpha_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest | undefined, + {} | undefined + ] + >; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeControl( + request: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeControl( + request?: protos.google.cloud.retail.v2alpha.IRemoveControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IServingConfig, + | protos.google.cloud.retail.v2alpha.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig, + protos.google.cloud.retail.v2alpha.IRemoveControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. + * 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ] + >; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + | protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IServingConfig + > + ): void; + listServingConfigs( + request: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + | protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IServingConfig + > + ): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + | protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IServingConfig + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + | protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2alpha.IServingConfig + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IServingConfig[], + protos.google.cloud.retail.v2alpha.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2alpha.IListServingConfigsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig} 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id} + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2alpha.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2alpha/serving_config_service.list_serving_configs.js + * region_tag:retail_v2alpha_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2alpha.IListServingConfigsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/serving_config_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client_config.json new file mode 100644 index 00000000000..6489c5db6ef --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ServingConfigService": { + "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": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/serving_config_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/serving_config_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/serving_config_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts b/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts new file mode 100644 index 00000000000..43ed8a39f08 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/user_event_service_client.ts @@ -0,0 +1,1812 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2alpha + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2alpha/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2alpha/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2alpha/{name=projects/*/locations/*}/operations'}, + {get: '/v2alpha/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeUserEventsResponse' + ) as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.PurgeMetadata' + ) as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportUserEventsResponse' + ) as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.ImportMetadata' + ) as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsResponse' + ) as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.RejoinUserEventsMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata) + ), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata) + ), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.UserEventService', + 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.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2alpha.UserEventService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.UserEventService, + 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 userEventServiceStubMethods = [ + 'writeUserEvent', + 'collectUserEvent', + 'purgeUserEvents', + 'importUserEvents', + 'rejoinUserEvents', + ]; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2alpha.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.write_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest | undefined, + {} | undefined + ] + >; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + | protos.google.cloud.retail.v2alpha.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + | protos.google.cloud.retail.v2alpha.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2alpha.IWriteUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + | protos.google.cloud.retail.v2alpha.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IUserEvent, + | protos.google.cloud.retail.v2alpha.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2alpha.IUserEvent, + protos.google.cloud.retail.v2alpha.IWriteUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @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 [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.collect_user_event.js + * region_tag:retail_v2alpha_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest | undefined, + {} | undefined + ] + >; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2alpha.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2alpha.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2alpha.ICollectUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2alpha.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2alpha.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2alpha.ICollectUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + + /** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2alpha.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2alpha.IPurgeUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.purge_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.PurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.PurgeMetadata + > + > { + 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.purgeUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.PurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.PurgeMetadata + >; + } + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * Operation.response is of type ImportResponse. Note that it is + * possible for a subset of the items to be successfully inserted. + * Operation.metadata is of type ImportMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2alpha.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2alpha.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request?: protos.google.cloud.retail.v2alpha.IImportUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.import_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.ImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + > + > { + 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.importUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.ImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.ImportMetadata + >; + } + /** + * Starts a user event rejoin operation with latest product catalog. Events + * will not be annotated with detailed product information if product is + * missing from the catalog at the time the user event is ingested, and these + * events are stored as unjoined events with a limited usage on training and + * serving. This method can be used to start a join operation on specified + * events with latest version of product catalog. It can also be used to + * correct events joined with the wrong product catalog. A rejoin operation + * can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2alpha.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * USER_EVENT_REJOIN_SCOPE_UNSPECIFIED if this field is not set, or set to an + * invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2alpha.IRejoinUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/user_event_service.rejoin_user_events.js + * region_tag:retail_v2alpha_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2alpha.RejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.RejoinUserEventsMetadata + > + > { + 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.rejoinUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2alpha.RejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.RejoinUserEventsMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/user_event_service_client_config.json b/packages/google-cloud-retail/src/v2alpha/user_event_service_client_config.json new file mode 100644 index 00000000000..21dfac2e12b --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.UserEventService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2alpha/user_event_service_proto_list.json b/packages/google-cloud-retail/src/v2alpha/user_event_service_proto_list.json new file mode 100644 index 00000000000..50adbaecf53 --- /dev/null +++ b/packages/google-cloud-retail/src/v2alpha/user_event_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2alpha/catalog.proto", + "../../protos/google/cloud/retail/v2alpha/catalog_service.proto", + "../../protos/google/cloud/retail/v2alpha/common.proto", + "../../protos/google/cloud/retail/v2alpha/completion_service.proto", + "../../protos/google/cloud/retail/v2alpha/control.proto", + "../../protos/google/cloud/retail/v2alpha/control_service.proto", + "../../protos/google/cloud/retail/v2alpha/export_config.proto", + "../../protos/google/cloud/retail/v2alpha/import_config.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.proto", + "../../protos/google/cloud/retail/v2alpha/prediction_service.proto", + "../../protos/google/cloud/retail/v2alpha/product.proto", + "../../protos/google/cloud/retail/v2alpha/product_service.proto", + "../../protos/google/cloud/retail/v2alpha/promotion.proto", + "../../protos/google/cloud/retail/v2alpha/purge_config.proto", + "../../protos/google/cloud/retail/v2alpha/search_service.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config.proto", + "../../protos/google/cloud/retail/v2alpha/serving_config_service.proto", + "../../protos/google/cloud/retail/v2alpha/user_event.proto", + "../../protos/google/cloud/retail/v2alpha/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts b/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts new file mode 100644 index 00000000000..16126450947 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/catalog_service_client.ts @@ -0,0 +1,2680 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/catalog_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './catalog_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for managing catalog configuration. + * @class + * @memberof v2beta + */ +export class CatalogServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + catalogServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CatalogServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CatalogServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listCatalogs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'catalogs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{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.cloud.retail.v2beta.CatalogService', + 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.catalogServiceStub) { + return this.catalogServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CatalogService. + this.catalogServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.CatalogService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CatalogService, + 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 catalogServiceStubMethods = [ + 'listCatalogs', + 'updateCatalog', + 'setDefaultBranch', + 'getDefaultBranch', + 'getCompletionConfig', + 'updateCompletionConfig', + 'getAttributesConfig', + 'updateAttributesConfig', + 'addCatalogAttribute', + 'removeCatalogAttribute', + 'batchRemoveCatalogAttributes', + 'replaceCatalogAttribute', + ]; + for (const methodName of catalogServiceStubMethods) { + const callPromise = this.catalogServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.catalogServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Updates the {@link google.cloud.retail.v2beta.Catalog|Catalog}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Catalog} request.catalog + * Required. The {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Catalog|Catalog}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Catalog|Catalog} to update does not + * exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Catalog|Catalog} to update. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is 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 [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_catalog.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCatalog_async + */ + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest | undefined, + {} | undefined + ] + >; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + | protos.google.cloud.retail.v2beta.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + | protos.google.cloud.retail.v2beta.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCatalog( + request?: protos.google.cloud.retail.v2beta.IUpdateCatalogRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.ICatalog, + | protos.google.cloud.retail.v2beta.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICatalog, + | protos.google.cloud.retail.v2beta.IUpdateCatalogRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICatalog, + protos.google.cloud.retail.v2beta.IUpdateCatalogRequest | 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({ + 'catalog.name': request.catalog!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCatalog(request, options, callback); + } + /** + * Set a specified branch id as default branch. API methods such as + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search}, + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct}, + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * will treat requests using "default_branch" to the actual branch id set as + * default. + * + * For example, if `projects/* /locations/* /catalogs/* /branches/1` is set as + * default, setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/default_branch` is equivalent + * to setting + * {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} to + * `projects/* /locations/* /catalogs/* /branches/1`. + * + * Using multiple branches can be useful when developers would like + * to have a staging branch to test and verify for future usage. When it + * becomes ready, developers switch on the staging branch using this API while + * keeping using `projects/* /locations/* /catalogs/* /branches/default_branch` + * as {@link google.cloud.retail.v2beta.SearchRequest.branch|SearchRequest.branch} + * to route the traffic to this staging branch. + * + * CAUTION: If you have live predict/search traffic, switching the default + * branch could potentially cause outages if the ID space of the new branch is + * very different from the old one. + * + * More specifically: + * + * * PredictionService will only return product IDs from branch {newBranch}. + * * SearchService will only return product IDs from branch {newBranch} + * (if branch is not explicitly set). + * * UserEventService will only join events with products from branch + * {newBranch}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Full resource name of the catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.branchId + * The final component of the resource name of a branch. + * + * This field must be one of "0", "1" or "2". Otherwise, an INVALID_ARGUMENT + * error is returned. + * + * If there are no sufficient active products in the targeted branch and + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.force|force} is not + * set, a FAILED_PRECONDITION error is returned. + * @param {string} request.note + * Some note on this request, this can be retrieved by + * {@link google.cloud.retail.v2beta.CatalogService.GetDefaultBranch|CatalogService.GetDefaultBranch} + * before next valid default branch set occurs. + * + * This field must be a UTF-8 encoded string with a length limit of 1,000 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {boolean} request.force + * If set to true, it permits switching to a branch with + * {@link google.cloud.retail.v2beta.SetDefaultBranchRequest.branch_id|branch_id} + * even if it has no sufficient active products. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.set_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_SetDefaultBranch_async + */ + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + setDefaultBranch( + request?: protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.ISetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultBranch(request, options, callback); + } + /** + * Get which branch is currently default branch set by + * {@link google.cloud.retail.v2beta.CatalogService.SetDefaultBranch|CatalogService.SetDefaultBranch} + * method under a specified parent catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @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 [GetDefaultBranchResponse]{@link google.cloud.retail.v2beta.GetDefaultBranchResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_default_branch.js + * region_tag:retail_v2beta_generated_CatalogService_GetDefaultBranch_async + */ + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest | undefined, + {} | undefined + ] + >; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDefaultBranch( + request?: protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + | protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse, + protos.google.cloud.retail.v2beta.IGetDefaultBranchRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full CompletionConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/completionConfig` + * @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 [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest | undefined, + {} | undefined + ] + >; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompletionConfig, + protos.google.cloud.retail.v2beta.IGetCompletionConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } + /** + * Updates the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.CompletionConfig} request.completionConfig + * Required. The + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to + * update does not exist, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CompletionConfig|CompletionConfig} to update. + * The following are the only supported fields: + * + * * {@link google.cloud.retail.v2beta.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2beta.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2beta.CompletionConfig.auto_learning|CompletionConfig.auto_learning} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CompletionConfig]{@link google.cloud.retail.v2beta.CompletionConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_completion_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompletionConfig, + ( + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | undefined + ), + {} | undefined + ] + >; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompletionConfig, + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompletionConfig, + ( + | protos.google.cloud.retail.v2beta.IUpdateCompletionConfigRequest + | 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({ + 'completion_config.name': request.completionConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig( + request, + options, + callback + ); + } + /** + * Gets an {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @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 [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.get_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest | undefined, + {} | undefined + ] + >; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IGetAttributesConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } + /** + * Updates the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * The catalog attributes in the request will be updated in the catalog, or + * inserted if they do not exist. Existing catalog attributes not included in + * the request will remain unchanged. Attributes that are assigned to + * products, but do not exist at the catalog level, are always included in the + * response. The product attribute is assigned default values for missing + * catalog attribute fields, e.g., searchable and dynamic facetable options. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.AttributesConfig} request.attributesConfig + * Required. The + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} to update. + * The following is the only supported field: + * + * * {@link google.cloud.retail.v2beta.AttributesConfig.catalog_attributes|AttributesConfig.catalog_attributes} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.update_attributes_config.js + * region_tag:retail_v2beta_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | undefined + ), + {} | undefined + ] + >; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IUpdateAttributesConfigRequest + | 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({ + 'attributes_config.name': request.attributesConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig( + request, + options, + callback + ); + } + /** + * Adds the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * add already exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to add. + * @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 [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest | undefined, + {} | undefined + ] + >; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + protos.google.cloud.retail.v2beta.IAddCatalogAttributeRequest | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } + /** + * Removes the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * remove does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string} request.key + * Required. The attribute name key of the + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to remove. + * @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 [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | undefined + ), + {} | undefined + ] + >; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IRemoveCatalogAttributeRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute( + request, + options, + callback + ); + } + /** + * Removes all specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s from the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. The attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string[]} request.attributeKeys + * Required. The attribute name keys of the + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s to delete. + * A maximum of 1000 catalog attributes can be deleted in a batch. + * @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 [BatchRemoveCatalogAttributesResponse]{@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js + * region_tag:retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async + */ + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + ( + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | undefined + ), + {} | undefined + ] + >; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | null + | undefined, + {} | null | undefined + > + ): void; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | null + | undefined, + {} | null | undefined + > + ): void; + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + ( + | protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchRemoveCatalogAttributes( + request, + options, + callback + ); + } + /** + * Replaces the specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig} by updating + * the catalog attribute with the same + * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to + * replace does not exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. Full AttributesConfig resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {google.cloud.retail.v2beta.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute} to update. + * The following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.CatalogAttribute.key|CatalogAttribute.key} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AttributesConfig]{@link google.cloud.retail.v2beta.AttributesConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2beta_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | undefined + ), + {} | undefined + ] + >; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IAttributesConfig, + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IAttributesConfig, + ( + | protos.google.cloud.retail.v2beta.IReplaceCatalogAttributeRequest + | 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({ + attributes_config: request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute( + request, + options, + callback + ); + } + + /** + * Lists all the {@link google.cloud.retail.v2beta.Catalog|Catalog}s associated + * with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is 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 Array of [Catalog]{@link google.cloud.retail.v2beta.Catalog}. + * 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest | null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ] + >; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + | protos.google.cloud.retail.v2beta.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.ICatalog + > + ): void; + listCatalogs( + request: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + | protos.google.cloud.retail.v2beta.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.ICatalog + > + ): void; + listCatalogs( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + | protos.google.cloud.retail.v2beta.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.ICatalog + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListCatalogsRequest, + | protos.google.cloud.retail.v2beta.IListCatalogsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.ICatalog + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICatalog[], + protos.google.cloud.retail.v2beta.IListCatalogsRequest | null, + protos.google.cloud.retail.v2beta.IListCatalogsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listCatalogs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @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 [Catalog]{@link google.cloud.retail.v2beta.Catalog} 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 `listCatalogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCatalogsStream( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.createStream( + this.innerApiCalls.listCatalogs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCatalogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The account resource name with an associated location. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Catalog|Catalog}s under this location, + * regardless of whether or not this location exists, a PERMISSION_DENIED + * error is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Catalog|Catalog}s to return. + * If unspecified, defaults to 50. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListCatalogsResponse.next_page_token|ListCatalogsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.CatalogService.ListCatalogs|CatalogService.ListCatalogs} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Catalog]{@link google.cloud.retail.v2beta.Catalog}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/catalog_service.list_catalogs.js + * region_tag:retail_v2beta_generated_CatalogService_ListCatalogs_async + */ + listCatalogsAsync( + request?: protos.google.cloud.retail.v2beta.IListCatalogsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listCatalogs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listCatalogs.asyncIterate( + this.innerApiCalls['listCatalogs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.catalogServiceStub && !this._terminated) { + return this.catalogServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/catalog_service_client_config.json b/packages/google-cloud-retail/src/v2beta/catalog_service_client_config.json new file mode 100644 index 00000000000..3554c7046eb --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/catalog_service_client_config.json @@ -0,0 +1,95 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CatalogService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "ListCatalogs": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCatalog": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "SetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetDefaultBranch": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateCompletionConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "GetAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "UpdateAttributesConfig": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "AddCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "RemoveCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "BatchRemoveCatalogAttributes": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ReplaceCatalogAttribute": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/catalog_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/catalog_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/catalog_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/completion_service_client.ts b/packages/google-cloud-retail/src/v2beta/completion_service_client.ts new file mode 100644 index 00000000000..52182c21368 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/completion_service_client.ts @@ -0,0 +1,1427 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/completion_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './completion_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Auto-completion service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class CompletionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + completionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of CompletionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof CompletionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const importCompletionDataResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportCompletionDataResponse' + ) as gax.protobuf.Type; + const importCompletionDataMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + importCompletionData: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importCompletionDataResponse.decode.bind(importCompletionDataResponse), + importCompletionDataMetadata.decode.bind(importCompletionDataMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.CompletionService', + 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.completionServiceStub) { + return this.completionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.CompletionService. + this.completionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.CompletionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.CompletionService, + 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 completionServiceStubMethods = [ + 'completeQuery', + 'importCompletionData', + ]; + for (const methodName of completionServiceStubMethods) { + const callPromise = this.completionServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.completionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Completes the specified prefix with keyword suggestions. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.catalog + * Required. Catalog for which the completion is performed. + * + * Full resource name of catalog, such as + * `projects/* /locations/global/catalogs/default_catalog`. + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string} request.visitorId + * Required field. A unique identifier for tracking visitors. For example, + * this could be implemented with an HTTP cookie, which should be able to + * uniquely identify a visitor on a single device. This unique identifier + * should not change if the visitor logs in or out of the website. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {string[]} request.languageCodes + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * The language filters applied to the output suggestions. If set, it should + * contain the language of the query. If not set, suggestions are returned + * without considering language restrictions. This is the BCP-47 language + * code, such as "en-US" or "sr-Latn". For more information, see [Tags for + * Identifying Languages](https://tools.ietf.org/html/bcp47). The maximum + * number of language codes is 3. + * @param {string} request.deviceType + * The device type context for completion suggestions. + * It is useful to apply different suggestions on different device types, e.g. + * `DESKTOP`, `MOBILE`. If it is empty, the suggestions are across all device + * types. + * + * Supported formats: + * + * * `UNKNOWN_DEVICE_TYPE` + * + * * `DESKTOP` + * + * * `MOBILE` + * + * * A customized string starts with `OTHER_`, e.g. `OTHER_IPHONE`. + * @param {string} request.dataset + * Determines which dataset to use for fetching completion. "user-data" will + * use the imported dataset through + * {@link google.cloud.retail.v2beta.CompletionService.ImportCompletionData|CompletionService.ImportCompletionData}. + * "cloud-retail" will use the dataset generated by cloud retail based on user + * events. If leave empty, it will use the "user-data". + * + * Current supported values: + * + * * user-data + * + * * cloud-retail: + * This option requires enabling auto-learning function first. See + * [guidelines](https://cloud.google.com/retail/docs/completion-overview#generated-completion-dataset). + * @param {number} request.maxSuggestions + * Completion max suggestions. If left unset or set to 0, then will fallback + * to the configured value + * {@link google.cloud.retail.v2beta.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions}. + * + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + * @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 [CompleteQueryResponse]{@link google.cloud.retail.v2beta.CompleteQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.complete_query.js + * region_tag:retail_v2beta_generated_CompletionService_CompleteQuery_async + */ + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest | undefined, + {} | undefined + ] + >; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + | protos.google.cloud.retail.v2beta.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + | protos.google.cloud.retail.v2beta.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): void; + completeQuery( + request?: protos.google.cloud.retail.v2beta.ICompleteQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + | protos.google.cloud.retail.v2beta.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + | protos.google.cloud.retail.v2beta.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.ICompleteQueryResponse, + protos.google.cloud.retail.v2beta.ICompleteQueryRequest | 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({ + catalog: request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.completeQuery(request, options, callback); + } + + /** + * Bulk import of processed completion dataset. + * + * Request processing is asynchronous. Partial updating is not supported. + * + * The operation is successfully finished only after the imported suggestions + * are indexed successfully and ready for serving. The process takes hours. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog which the suggestions dataset belongs to. + * + * Format: `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.CompletionDataInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {string} request.notificationPubsubTopic + * Pub/Sub topic for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * {@link google.longrunning.Operation|Operation}. + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importCompletionData( + request?: protos.google.cloud.retail.v2beta.IImportCompletionDataRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importCompletionData(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importCompletionData()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/completion_service.import_completion_data.js + * region_tag:retail_v2beta_generated_CompletionService_ImportCompletionData_async + */ + async checkImportCompletionDataProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.ImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + > + > { + 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.importCompletionData, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.ImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.completionServiceStub && !this._terminated) { + return this.completionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/completion_service_client_config.json b/packages/google-cloud-retail/src/v2beta/completion_service_client_config.json new file mode 100644 index 00000000000..1865fe66ef1 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/completion_service_client_config.json @@ -0,0 +1,45 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.CompletionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CompleteQuery": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "ImportCompletionData": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/completion_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/completion_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/completion_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/control_service_client.ts b/packages/google-cloud-retail/src/v2beta/control_service_client.ts new file mode 100644 index 00000000000..603bd5bb1b4 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/control_service_client.ts @@ -0,0 +1,1724 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/control_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './control_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying Control. + * @class + * @memberof v2beta + */ +export class ControlServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + controlServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ControlServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ControlServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listControls: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'controls' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{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.cloud.retail.v2beta.ControlService', + 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.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.ControlService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ControlService, + 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 controlServiceStubMethods = [ + 'createControl', + 'deleteControl', + 'updateControl', + 'getControl', + 'listControls', + ]; + for (const methodName of controlServiceStubMethods) { + const callPromise = this.controlServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.controlServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to create already + * exists, an ALREADY_EXISTS error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent catalog. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to create. + * @param {string} request.controlId + * Required. The ID to use for the Control, which will become the final + * component of the Control's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.create_control.js + * region_tag:retail_v2beta_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest | undefined, + {} | undefined + ] + >; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createControl( + request: protos.google.cloud.retail.v2beta.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createControl( + request?: protos.google.cloud.retail.v2beta.ICreateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.ICreateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.ICreateControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.ICreateControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } + /** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2beta.Control|Control} to delete does not + * exist, a NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.delete_control.js + * region_tag:retail_v2beta_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest | undefined, + {} | undefined + ] + >; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteControl( + request?: protos.google.cloud.retail.v2beta.IDeleteControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } + /** + * Updates a Control. + * + * {@link google.cloud.retail.v2beta.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2beta.Control|Control} to update does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Control|Control} to update. The following are + * NOT supported: + * + * * {@link google.cloud.retail.v2beta.Control.name|Control.name} + * + * If not set or empty, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.update_control.js + * region_tag:retail_v2beta_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest | undefined, + {} | undefined + ] + >; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateControl( + request: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateControl( + request?: protos.google.cloud.retail.v2beta.IUpdateControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.IUpdateControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IUpdateControlRequest | 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({ + 'control.name': request.control!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateControl(request, options, callback); + } + /** + * Gets a Control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Control to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/controls/{control_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Control]{@link google.cloud.retail.v2beta.Control}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.get_control.js + * region_tag:retail_v2beta_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest | undefined, + {} | undefined + ] + >; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request: protos.google.cloud.retail.v2beta.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): void; + getControl( + request?: protos.google.cloud.retail.v2beta.IGetControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IControl, + | protos.google.cloud.retail.v2beta.IGetControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl, + protos.google.cloud.retail.v2beta.IGetControlRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls by their parent + * {@link google.cloud.retail.v2beta.Catalog|Catalog}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2beta.Control}. + * 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest | null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ] + >; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + | protos.google.cloud.retail.v2beta.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IControl + > + ): void; + listControls( + request: protos.google.cloud.retail.v2beta.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + | protos.google.cloud.retail.v2beta.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IControl + > + ): void; + listControls( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + | protos.google.cloud.retail.v2beta.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IControl + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListControlsRequest, + | protos.google.cloud.retail.v2beta.IListControlsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IControl + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IControl[], + protos.google.cloud.retail.v2beta.IListControlsRequest | null, + protos.google.cloud.retail.v2beta.IListControlsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listControls(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @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 [Control]{@link google.cloud.retail.v2beta.Control} 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 `listControlsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listControlsStream( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.createStream( + this.innerApiCalls.listControls as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listControls`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListControls` call. + * Provide this to retrieve the subsequent page. + * @param {string} [request.filter] + * Optional. A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListControlsRequest.filter|filter} is unset. + * * List controls that are used in a single ServingConfig: + * 'serving_config = "boosted_home_page_cvr"' + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Control]{@link google.cloud.retail.v2beta.Control}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/control_service.list_controls.js + * region_tag:retail_v2beta_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2beta.IListControlsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listControls']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listControls.asyncIterate( + this.innerApiCalls['listControls'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.controlServiceStub && !this._terminated) { + return this.controlServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/control_service_client_config.json b/packages/google-cloud-retail/src/v2beta/control_service_client_config.json new file mode 100644 index 00000000000..b7572aeb833 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ControlService": { + "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": { + "CreateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListControls": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/control_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/control_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/control_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/gapic_metadata.json b/packages/google-cloud-retail/src/v2beta/gapic_metadata.json new file mode 100644 index 00000000000..7bda8b31b52 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/gapic_metadata.json @@ -0,0 +1,669 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.retail.v2beta", + "libraryPackage": "@google-cloud/retail", + "services": { + "CatalogService": { + "clients": { + "grpc": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CatalogServiceClient", + "rpcs": { + "UpdateCatalog": { + "methods": [ + "updateCatalog" + ] + }, + "SetDefaultBranch": { + "methods": [ + "setDefaultBranch" + ] + }, + "GetDefaultBranch": { + "methods": [ + "getDefaultBranch" + ] + }, + "GetCompletionConfig": { + "methods": [ + "getCompletionConfig" + ] + }, + "UpdateCompletionConfig": { + "methods": [ + "updateCompletionConfig" + ] + }, + "GetAttributesConfig": { + "methods": [ + "getAttributesConfig" + ] + }, + "UpdateAttributesConfig": { + "methods": [ + "updateAttributesConfig" + ] + }, + "AddCatalogAttribute": { + "methods": [ + "addCatalogAttribute" + ] + }, + "RemoveCatalogAttribute": { + "methods": [ + "removeCatalogAttribute" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "ReplaceCatalogAttribute": { + "methods": [ + "replaceCatalogAttribute" + ] + }, + "ListCatalogs": { + "methods": [ + "listCatalogs", + "listCatalogsStream", + "listCatalogsAsync" + ] + } + } + } + } + }, + "CompletionService": { + "clients": { + "grpc": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "CompletionServiceClient", + "rpcs": { + "CompleteQuery": { + "methods": [ + "completeQuery" + ] + }, + "ImportCompletionData": { + "methods": [ + "importCompletionData" + ] + } + } + } + } + }, + "ControlService": { + "clients": { + "grpc": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ControlServiceClient", + "rpcs": { + "CreateControl": { + "methods": [ + "createControl" + ] + }, + "DeleteControl": { + "methods": [ + "deleteControl" + ] + }, + "UpdateControl": { + "methods": [ + "updateControl" + ] + }, + "GetControl": { + "methods": [ + "getControl" + ] + }, + "ListControls": { + "methods": [ + "listControls", + "listControlsStream", + "listControlsAsync" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "ProductService": { + "clients": { + "grpc": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProductServiceClient", + "rpcs": { + "CreateProduct": { + "methods": [ + "createProduct" + ] + }, + "GetProduct": { + "methods": [ + "getProduct" + ] + }, + "UpdateProduct": { + "methods": [ + "updateProduct" + ] + }, + "DeleteProduct": { + "methods": [ + "deleteProduct" + ] + }, + "ImportProducts": { + "methods": [ + "importProducts" + ] + }, + "SetInventory": { + "methods": [ + "setInventory" + ] + }, + "AddFulfillmentPlaces": { + "methods": [ + "addFulfillmentPlaces" + ] + }, + "RemoveFulfillmentPlaces": { + "methods": [ + "removeFulfillmentPlaces" + ] + }, + "AddLocalInventories": { + "methods": [ + "addLocalInventories" + ] + }, + "RemoveLocalInventories": { + "methods": [ + "removeLocalInventories" + ] + }, + "ListProducts": { + "methods": [ + "listProducts", + "listProductsStream", + "listProductsAsync" + ] + } + } + } + } + }, + "SearchService": { + "clients": { + "grpc": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SearchServiceClient", + "rpcs": { + "Search": { + "methods": [ + "search", + "searchStream", + "searchAsync" + ] + } + } + } + } + }, + "ServingConfigService": { + "clients": { + "grpc": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ServingConfigServiceClient", + "rpcs": { + "CreateServingConfig": { + "methods": [ + "createServingConfig" + ] + }, + "DeleteServingConfig": { + "methods": [ + "deleteServingConfig" + ] + }, + "UpdateServingConfig": { + "methods": [ + "updateServingConfig" + ] + }, + "GetServingConfig": { + "methods": [ + "getServingConfig" + ] + }, + "AddControl": { + "methods": [ + "addControl" + ] + }, + "RemoveControl": { + "methods": [ + "removeControl" + ] + }, + "ListServingConfigs": { + "methods": [ + "listServingConfigs", + "listServingConfigsStream", + "listServingConfigsAsync" + ] + } + } + } + } + }, + "UserEventService": { + "clients": { + "grpc": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "UserEventServiceClient", + "rpcs": { + "WriteUserEvent": { + "methods": [ + "writeUserEvent" + ] + }, + "CollectUserEvent": { + "methods": [ + "collectUserEvent" + ] + }, + "PurgeUserEvents": { + "methods": [ + "purgeUserEvents" + ] + }, + "ImportUserEvents": { + "methods": [ + "importUserEvents" + ] + }, + "RejoinUserEvents": { + "methods": [ + "rejoinUserEvents" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/index.ts b/packages/google-cloud-retail/src/v2beta/index.ts new file mode 100644 index 00000000000..74f290ddf79 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/index.ts @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {CatalogServiceClient} from './catalog_service_client'; +export {CompletionServiceClient} from './completion_service_client'; +export {ControlServiceClient} from './control_service_client'; +export {ModelServiceClient} from './model_service_client'; +export {PredictionServiceClient} from './prediction_service_client'; +export {ProductServiceClient} from './product_service_client'; +export {SearchServiceClient} from './search_service_client'; +export {ServingConfigServiceClient} from './serving_config_service_client'; +export {UserEventServiceClient} from './user_event_service_client'; diff --git a/packages/google-cloud-retail/src/v2beta/model_service_client.ts b/packages/google-cloud-retail/src/v2beta/model_service_client.ts new file mode 100644 index 00000000000..210906d3140 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/model_service_client.ts @@ -0,0 +1,1989 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/model_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './model_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the `Predict()` API. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). + * + * This service allows you to do the following: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * @class + * @memberof v2beta + */ +export class ModelServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + modelServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ModelServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ModelServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ModelServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listModels: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'models' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const createModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.Model' + ) as gax.protobuf.Type; + const createModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.CreateModelMetadata' + ) as gax.protobuf.Type; + const tuneModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.TuneModelResponse' + ) as gax.protobuf.Type; + const tuneModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.TuneModelMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + createModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createModelResponse.decode.bind(createModelResponse), + createModelMetadata.decode.bind(createModelMetadata) + ), + tuneModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + tuneModelResponse.decode.bind(tuneModelResponse), + tuneModelMetadata.decode.bind(tuneModelMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ModelService', + 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.modelServiceStub) { + return this.modelServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ModelService. + this.modelServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.ModelService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ModelService, + 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 modelServiceStubMethods = [ + 'createModel', + 'pauseModel', + 'resumeModel', + 'deleteModel', + 'listModels', + 'updateModel', + 'tuneModel', + ]; + for (const methodName of modelServiceStubMethods) { + const callPromise = this.modelServiceStub.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.modelServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Pauses the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Model]{@link google.cloud.retail.v2beta.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.pause_model.js + * region_tag:retail_v2beta_generated_ModelService_PauseModel_async + */ + pauseModel( + request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest | undefined, + {} | undefined + ] + >; + pauseModel( + request: protos.google.cloud.retail.v2beta.IPauseModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): void; + pauseModel( + request: protos.google.cloud.retail.v2beta.IPauseModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): void; + pauseModel( + request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IModel, + | protos.google.cloud.retail.v2beta.IPauseModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseModel(request, options, callback); + } + /** + * Resumes the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Model]{@link google.cloud.retail.v2beta.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.resume_model.js + * region_tag:retail_v2beta_generated_ModelService_ResumeModel_async + */ + resumeModel( + request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest | undefined, + {} | undefined + ] + >; + resumeModel( + request: protos.google.cloud.retail.v2beta.IResumeModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): void; + resumeModel( + request: protos.google.cloud.retail.v2beta.IResumeModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): void; + resumeModel( + request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IModel, + | protos.google.cloud.retail.v2beta.IResumeModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeModel(request, options, callback); + } + /** + * Deletes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.retail.v2beta.Model|Model} to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.delete_model.js + * region_tag:retail_v2beta_generated_ModelService_DeleteModel_async + */ + deleteModel( + request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest | undefined, + {} | undefined + ] + >; + deleteModel( + request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteModel( + request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): void; + deleteModel( + request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteModel(request, options, callback); + } + /** + * Update of model metadata. Only fields that + * currently can be updated are: `filtering_option` and + * `periodic_tuning_state`. + * If other values are provided, this API method ignores them. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Model} request.model + * Required. The body of the updated + * {@link google.cloud.retail.v2beta.Model|Model}. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + * @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 [Model]{@link google.cloud.retail.v2beta.Model}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.update_model.js + * region_tag:retail_v2beta_generated_ModelService_UpdateModel_async + */ + updateModel( + request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest | undefined, + {} | undefined + ] + >; + updateModel( + request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): void; + updateModel( + request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): void; + updateModel( + request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IModel, + | protos.google.cloud.retail.v2beta.IUpdateModelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest | 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({ + 'model.name': request.model!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateModel(request, options, callback); + } + + /** + * Creates a new model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2beta.Model} request.model + * Required. The payload of the {@link google.cloud.retail.v2beta.Model|Model} to + * create. + * @param {boolean} [request.dryRun] + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.create_model.js + * region_tag:retail_v2beta_generated_ModelService_CreateModel_async + */ + createModel( + request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + createModel( + request: protos.google.cloud.retail.v2beta.ICreateModelRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createModel( + request: protos.google.cloud.retail.v2beta.ICreateModelRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + createModel( + request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createModel(request, options, callback); + } + /** + * Check the status of the long running operation returned by `createModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.create_model.js + * region_tag:retail_v2beta_generated_ModelService_CreateModel_async + */ + async checkCreateModelProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.Model, + protos.google.cloud.retail.v2beta.CreateModelMetadata + > + > { + 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.createModel, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.Model, + protos.google.cloud.retail.v2beta.CreateModelMetadata + >; + } + /** + * Tunes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.tune_model.js + * region_tag:retail_v2beta_generated_ModelService_TuneModel_async + */ + tuneModel( + request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + tuneModel( + request: protos.google.cloud.retail.v2beta.ITuneModelRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + tuneModel( + request: protos.google.cloud.retail.v2beta.ITuneModelRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + tuneModel( + request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.tuneModel(request, options, callback); + } + /** + * Check the status of the long running operation returned by `tuneModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.tune_model.js + * region_tag:retail_v2beta_generated_ModelService_TuneModel_async + */ + async checkTuneModelProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.TuneModelResponse, + protos.google.cloud.retail.v2beta.TuneModelMetadata + > + > { + 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.tuneModel, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.TuneModelResponse, + protos.google.cloud.retail.v2beta.TuneModelMetadata + >; + } + /** + * Lists all the models linked to this event store. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @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 [Model]{@link google.cloud.retail.v2beta.Model}. + * 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModels( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel[], + protos.google.cloud.retail.v2beta.IListModelsRequest | null, + protos.google.cloud.retail.v2beta.IListModelsResponse + ] + >; + listModels( + request: protos.google.cloud.retail.v2beta.IListModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2beta.IModel + > + ): void; + listModels( + request: protos.google.cloud.retail.v2beta.IListModelsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2beta.IModel + > + ): void; + listModels( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + | protos.google.cloud.retail.v2beta.IListModelsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IModel + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse | null | undefined, + protos.google.cloud.retail.v2beta.IModel + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IModel[], + protos.google.cloud.retail.v2beta.IListModelsRequest | null, + protos.google.cloud.retail.v2beta.IListModelsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listModels(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @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 [Model]{@link google.cloud.retail.v2beta.Model} 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModelsStream( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.createStream( + this.innerApiCalls.listModels as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listModels`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 50. Max allowed value is 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListModels` + * call. Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Model]{@link google.cloud.retail.v2beta.Model}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/model_service.list_models.js + * region_tag:retail_v2beta_generated_ModelService_ListModels_async + */ + listModelsAsync( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.asyncIterate( + this.innerApiCalls['listModels'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.modelServiceStub && !this._terminated) { + return this.modelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/model_service_client_config.json b/packages/google-cloud-retail/src/v2beta/model_service_client_config.json new file mode 100644 index 00000000000..7b1e02dc61d --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/model_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ModelService": { + "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": { + "CreateModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PauseModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResumeModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TuneModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/model_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/model_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/model_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts b/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts new file mode 100644 index 00000000000..c2ad7f54fe2 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/prediction_service_client.ts @@ -0,0 +1,1304 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/prediction_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './prediction_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for making recommendation prediction. + * @class + * @memberof v2beta + */ +export class PredictionServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + predictionServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of PredictionServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof PredictionServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{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.cloud.retail.v2beta.PredictionService', + 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.predictionServiceStub) { + return this.predictionServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.PredictionService. + this.predictionServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.PredictionService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.PredictionService, + 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 predictionServiceStubMethods = ['predict']; + for (const methodName of predictionServiceStubMethods) { + const callPromise = this.predictionServiceStub.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.predictionServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Makes a recommendation prediction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Managing serving configurations] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. Context about the user, what they are looking at and what action + * they took to trigger the predict request. Note that this user event detail + * won't be ingested to userEvent logs. Thus, a separate userEvent write + * request is required for event logging. + * + * Don't set + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2beta.UserInfo.user_id|UserInfo.user_id} to the same + * fixed ID for different users. If you are trying to receive non-personalized + * recommendations (not recommended; this can negatively impact model + * performance), instead set + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link google.cloud.retail.v2beta.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return. Set this property to the number of + * prediction results needed. If zero, the service will choose a reasonable + * default. The maximum allowed value is 100. Values above 100 will be coerced + * to 100. + * @param {string} request.pageToken + * This field is not used; leave it unset. + * @param {string} request.filter + * Filter for restricting prediction results with a length limit of 5,000 + * characters. Accepts values for tags and the `filterOutOfStockItems` flag. + * + * * Tag expressions. Restricts predictions to products that match all of the + * specified tags. Boolean operators `OR` and `NOT` are supported if the + * expression is enclosed in parentheses, and must be separated from the + * tag values by a space. `-"tagA"` is also supported and is equivalent to + * `NOT "tagA"`. Tag values must be double quoted UTF-8 encoded strings + * with a size limit of 1,000 characters. + * + * Note: "Recently viewed" models don't support tag filtering at the + * moment. + * + * * filterOutOfStockItems. Restricts predictions to products that do not + * have a + * stockState value of OUT_OF_STOCK. + * + * Examples: + * + * * tag=("Red" OR "Blue") tag="New-Arrival" tag=(NOT "promotional") + * * filterOutOfStockItems tag=(-"promotional") + * * filterOutOfStockItems + * + * If your filter blocks all prediction results, the API will return generic + * (unfiltered) popular products. If you only want results strictly matching + * the filters, set `strictFiltering` to True in `PredictRequest.params` to + * receive empty results instead. + * Note that the API will never return items with storageStatus of "EXPIRED" + * or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * @param {boolean} request.validateOnly + * Use validate only mode for this prediction query. If set to true, a + * dummy model will be used that returns arbitrary products. + * Note that the validate only mode should only be used for testing the API, + * or if the model is not ready. + * @param {number[]} request.params + * Additional domain specific parameters for the predictions. + * + * Allowed values: + * + * * `returnProduct`: Boolean. If set to true, the associated product + * object will be returned in the `results.metadata` field in the + * prediction response. + * * `returnScore`: Boolean. If set to true, the prediction 'score' + * corresponding to each returned product will be set in the + * `results.metadata` field in the prediction response. The given + * 'score' indicates the probability of an product being clicked/purchased + * given the user's context and history. + * * `strictFiltering`: Boolean. True by default. If set to false, the service + * will return generic (unfiltered) popular products instead of empty if + * your filter blocks all prediction results. + * * `priceRerankLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-price-reranking', 'low-price-reranking', + * 'medium-price-reranking', 'high-price-reranking'}. This gives + * request-level control and adjusts prediction results based on product + * price. + * * `diversityLevel`: String. Default empty. If set to be non-empty, then + * it needs to be one of {'no-diversity', 'low-diversity', + * 'medium-diversity', 'high-diversity', 'auto-diversity'}. This gives + * request-level control and adjusts prediction results based on product + * category. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @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 [PredictResponse]{@link google.cloud.retail.v2beta.PredictResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/prediction_service.predict.js + * region_tag:retail_v2beta_generated_PredictionService_Predict_async + */ + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | undefined, + {} | undefined + ] + >; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request: protos.google.cloud.retail.v2beta.IPredictRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | null | undefined, + {} | null | undefined + > + ): void; + predict( + request?: protos.google.cloud.retail.v2beta.IPredictRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IPredictResponse, + protos.google.cloud.retail.v2beta.IPredictRequest | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.predictionServiceStub && !this._terminated) { + return this.predictionServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/prediction_service_client_config.json b/packages/google-cloud-retail/src/v2beta/prediction_service_client_config.json new file mode 100644 index 00000000000..ab64c45e11f --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/prediction_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.PredictionService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Predict": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/prediction_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/prediction_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/prediction_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/product_service_client.ts b/packages/google-cloud-retail/src/v2beta/product_service_client.ts new file mode 100644 index 00000000000..2ac7ca4c4df --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/product_service_client.ts @@ -0,0 +1,3363 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/product_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './product_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting {@link google.cloud.retail.v2beta.Product|Product} + * information of the customer's website. + * @class + * @memberof v2beta + */ +export class ProductServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + productServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProductServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ProductServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listProducts: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'products' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const importProductsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportProductsResponse' + ) as gax.protobuf.Type; + const importProductsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata' + ) as gax.protobuf.Type; + const setInventoryResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryResponse' + ) as gax.protobuf.Type; + const setInventoryMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.SetInventoryMetadata' + ) as gax.protobuf.Type; + const addFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const addFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse' + ) as gax.protobuf.Type; + const removeFulfillmentPlacesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata' + ) as gax.protobuf.Type; + const addLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesResponse' + ) as gax.protobuf.Type; + const addLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.AddLocalInventoriesMetadata' + ) as gax.protobuf.Type; + const removeLocalInventoriesResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse' + ) as gax.protobuf.Type; + const removeLocalInventoriesMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + importProducts: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importProductsResponse.decode.bind(importProductsResponse), + importProductsMetadata.decode.bind(importProductsMetadata) + ), + setInventory: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setInventoryResponse.decode.bind(setInventoryResponse), + setInventoryMetadata.decode.bind(setInventoryMetadata) + ), + addFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addFulfillmentPlacesResponse.decode.bind(addFulfillmentPlacesResponse), + addFulfillmentPlacesMetadata.decode.bind(addFulfillmentPlacesMetadata) + ), + removeFulfillmentPlaces: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeFulfillmentPlacesResponse.decode.bind( + removeFulfillmentPlacesResponse + ), + removeFulfillmentPlacesMetadata.decode.bind( + removeFulfillmentPlacesMetadata + ) + ), + addLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + addLocalInventoriesResponse.decode.bind(addLocalInventoriesResponse), + addLocalInventoriesMetadata.decode.bind(addLocalInventoriesMetadata) + ), + removeLocalInventories: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + removeLocalInventoriesResponse.decode.bind( + removeLocalInventoriesResponse + ), + removeLocalInventoriesMetadata.decode.bind( + removeLocalInventoriesMetadata + ) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ProductService', + 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.productServiceStub) { + return this.productServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ProductService. + this.productServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.ProductService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ProductService, + 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 productServiceStubMethods = [ + 'createProduct', + 'getProduct', + 'listProducts', + 'updateProduct', + 'deleteProduct', + 'importProducts', + 'setInventory', + 'addFulfillmentPlaces', + 'removeFulfillmentPlaces', + 'addLocalInventories', + 'removeLocalInventories', + ]; + for (const methodName of productServiceStubMethods) { + const callPromise = this.productServiceStub.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.productServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch`. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The {@link google.cloud.retail.v2beta.Product|Product} to create. + * @param {string} request.productId + * Required. The ID to use for the + * {@link google.cloud.retail.v2beta.Product|Product}, which will become the final + * component of the {@link google.cloud.retail.v2beta.Product.name|Product.name}. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * This field must be unique among all + * {@link google.cloud.retail.v2beta.Product|Product}s with the same + * {@link google.cloud.retail.v2beta.CreateProductRequest.parent|parent}. + * Otherwise, an ALREADY_EXISTS error is returned. + * + * This field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is 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 [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.create_product.js + * region_tag:retail_v2beta_generated_ProductService_CreateProduct_async + */ + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest | undefined, + {} | undefined + ] + >; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createProduct( + request: protos.google.cloud.retail.v2beta.ICreateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createProduct( + request?: protos.google.cloud.retail.v2beta.ICreateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.ICreateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.ICreateProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.ICreateProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProduct(request, options, callback); + } + /** + * Gets a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the requested {@link google.cloud.retail.v2beta.Product|Product} does not + * exist, a NOT_FOUND error is 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 [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.get_product.js + * region_tag:retail_v2beta_generated_ProductService_GetProduct_async + */ + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest | undefined, + {} | undefined + ] + >; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request: protos.google.cloud.retail.v2beta.IGetProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): void; + getProduct( + request?: protos.google.cloud.retail.v2beta.IGetProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IGetProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProduct(request, options, callback); + } + /** + * Updates a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.product + * Required. The product to update/create. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * exist and + * {@link google.cloud.retail.v2beta.UpdateProductRequest.allow_missing|allow_missing} + * is not set, a NOT_FOUND error is returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. The immutable and + * output only fields are NOT supported. If not set, all supported fields (the + * fields that are neither immutable nor output only) are updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * + * The attribute key can be updated by setting the mask path as + * "attributes.${key_name}". If a key name is present in the mask but not in + * the patching product from the request, this key will be deleted after the + * update. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, a new {@link google.cloud.retail.v2beta.Product|Product} will be + * created. In this situation, `update_mask` is ignored. + * @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 [Product]{@link google.cloud.retail.v2beta.Product}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.update_product.js + * region_tag:retail_v2beta_generated_ProductService_UpdateProduct_async + */ + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest | undefined, + {} | undefined + ] + >; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateProduct( + request?: protos.google.cloud.retail.v2beta.IUpdateProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IProduct, + | protos.google.cloud.retail.v2beta.IUpdateProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct, + protos.google.cloud.retail.v2beta.IUpdateProductRequest | 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({ + 'product.name': request.product!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateProduct(request, options, callback); + } + /** + * Deletes a {@link google.cloud.retail.v2beta.Product|Product}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to delete the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to delete does not + * exist, a NOT_FOUND error is returned. + * + * The {@link google.cloud.retail.v2beta.Product|Product} to delete can neither be + * a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} member nor a + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} with more than one + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variants}. Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * All inventory information for the named + * {@link google.cloud.retail.v2beta.Product|Product} will be 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 [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.delete_product.js + * region_tag:retail_v2beta_generated_ProductService_DeleteProduct_async + */ + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest | undefined, + {} | undefined + ] + >; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteProduct( + request?: protos.google.cloud.retail.v2beta.IDeleteProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteProductRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteProductRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProduct(request, options, callback); + } + + /** + * Bulk import of multiple {@link google.cloud.retail.v2beta.Product|Product}s. + * + * Request processing may be synchronous. + * Non-existing items are created. + * + * Note that it is possible for a subset of the + * {@link google.cloud.retail.v2beta.Product|Product}s to be successfully updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * `projects/1234/locations/global/catalogs/default_catalog/branches/default_branch` + * + * If no updateMask is specified, requires products.create permission. + * If updateMask is specified, requires products.update permission. + * @param {string} request.requestId + * Deprecated. This field has no effect. + * @param {google.cloud.retail.v2beta.ProductInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided imported `products` to update. If + * not set, all fields are updated. + * @param {google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode} request.reconciliationMode + * The mode of reconciliation between existing products and the products to be + * imported. Defaults to + * {@link google.cloud.retail.v2beta.ImportProductsRequest.ReconciliationMode.INCREMENTAL|ReconciliationMode.INCREMENTAL}. + * @param {string} request.notificationPubsubTopic + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is JSON string of a + * {@link google.longrunning.Operation|Operation}. + * + * Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. It has + * to be within the same project as + * {@link google.cloud.retail.v2beta.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request: protos.google.cloud.retail.v2beta.IImportProductsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importProducts( + request?: protos.google.cloud.retail.v2beta.IImportProductsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importProducts(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.import_products.js + * region_tag:retail_v2beta_generated_ProductService_ImportProducts_async + */ + async checkImportProductsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.ImportProductsResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + > + > { + 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.importProducts, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.ImportProductsResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + >; + } + /** + * Updates inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} while respecting the last + * update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update is enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update times for the specified inventory fields are overwritten by the + * times of the + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * request. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.CreateProductRequest.product|CreateProductRequest.product}, + * then any pre-existing inventory information for this product is used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information is preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2beta.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link google.longrunning.Operation.done|done} until + * they are obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Product} request.inventory + * Required. The inventory information to update. The allowable fields to + * update are: + * + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * The updated inventory fields must be specified in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}. + * + * If + * {@link google.cloud.retail.v2beta.Product.name|SetInventoryRequest.inventory.name} + * is empty or invalid, an INVALID_ARGUMENT error is returned. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2beta.Product|Product} named in + * {@link google.cloud.retail.v2beta.Product.name|Product.name}, regardless of + * whether or not it exists, a PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update does not + * have existing inventory information, the provided inventory information + * will be inserted. + * + * If the {@link google.cloud.retail.v2beta.Product|Product} to update has existing + * inventory information, the provided inventory information will be merged + * while respecting the last update time for each inventory field, using the + * provided or default value for + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_time|SetInventoryRequest.set_time}. + * + * The caller can replace place IDs for a subset of fulfillment types in the + * following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types and corresponding place IDs + * to update in + * {@link google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * + * The caller can clear all place IDs from a subset of fulfillment types in + * the following ways: + * + * * Adds "fulfillment_info" in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask} + * * Specifies only the desired fulfillment types to clear in + * {@link google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|SetInventoryRequest.inventory.fulfillment_info.place_ids} + * + * The last update time is recorded for the following inventory fields: + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.availability|Product.availability} + * * {@link google.cloud.retail.v2beta.Product.available_quantity|Product.available_quantity} + * * {@link google.cloud.retail.v2beta.Product.fulfillment_info|Product.fulfillment_info} + * + * If a full overwrite of inventory information while ignoring timestamps is + * needed, + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * should be invoked instead. + * @param {google.protobuf.FieldMask} request.setMask + * Indicates which inventory fields in the provided + * {@link google.cloud.retail.v2beta.Product|Product} to update. + * + * At least one field must be provided. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.setTime + * The time when the request is issued, used to prevent + * out-of-order updates on inventory fields with the last update time + * recorded. If not provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} with + * name {@link google.cloud.retail.v2beta.Product.name|Product.name} is not found, + * the inventory update will still be processed and retained for at most 1 day + * until the {@link google.cloud.retail.v2beta.Product|Product} is created. If set + * to false, a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + setInventory( + request?: protos.google.cloud.retail.v2beta.ISetInventoryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >, + 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({ + 'inventory.name': request.inventory!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.setInventory(request, options, callback); + } + /** + * Check the status of the long running operation returned by `setInventory()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.set_inventory.js + * region_tag:retail_v2beta_generated_ProductService_SetInventory_async + */ + async checkSetInventoryProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.SetInventoryResponse, + protos.google.cloud.retail.v2beta.SetInventoryMetadata + > + > { + 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.setInventory, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.SetInventoryResponse, + protos.google.cloud.retail.v2beta.SetInventoryMetadata + >; + } + /** + * Incrementally adds place IDs to + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the added place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}, such + * as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery" to be added for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type}. + * Duplicate IDs will be automatically ignored. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * + * If the total number of place IDs exceeds 2000 for this + * {@link google.cloud.retail.v2beta.AddFulfillmentPlacesRequest.type|type} after + * adding, then the update will be rejected. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addFulfillmentPlaces(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_AddFulfillmentPlaces_async + */ + async checkAddFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + > + > { + 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.addFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.AddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.AddFulfillmentPlacesMetadata + >; + } + /** + * Incrementally removes place IDs from a + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|Product.fulfillment_info.place_ids}. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * fulfillment information. If the request is valid, the update will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, the removed place IDs are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string} request.type + * Required. The fulfillment type, including commonly used types (such as + * pickup in store and same day delivery), and custom types. + * + * Supported values: + * + * * "pickup-in-store" + * * "ship-to-store" + * * "same-day-delivery" + * * "next-day-delivery" + * * "custom-type-1" + * * "custom-type-2" + * * "custom-type-3" + * * "custom-type-4" + * * "custom-type-5" + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * + * This field directly corresponds to + * {@link google.cloud.retail.v2beta.FulfillmentInfo.type|Product.fulfillment_info.type}. + * @param {string[]} request.placeIds + * Required. The IDs for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}, + * such as the store IDs for "pickup-in-store" or the region IDs for + * "same-day-delivery", to be removed for this + * {@link google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest.type|type}. + * + * At least 1 value is required, and a maximum of 2000 values are allowed. + * Each value must be a string with a length limit of 10 characters, matching + * the pattern `[a-zA-Z0-9_-]+`, such as "store1" or "REGION-2". Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the fulfillment updates are issued, used to prevent + * out-of-order updates on fulfillment information. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the fulfillment information will still be processed and retained + * for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeFulfillmentPlaces( + request?: protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeFulfillmentPlaces( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeFulfillmentPlaces()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_fulfillment_places.js + * region_tag:retail_v2beta_generated_ProductService_RemoveFulfillmentPlaces_async + */ + async checkRemoveFulfillmentPlacesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + > + > { + 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.removeFulfillmentPlaces, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesMetadata + >; + } + /** + * Updates local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places, while + * respecting the last update timestamps of each inventory field. + * + * This process is asynchronous and does not require the + * {@link google.cloud.retail.v2beta.Product|Product} to exist before updating + * inventory information. If the request is valid, the update will be enqueued + * and processed downstream. As a consequence, when a response is returned, + * updates are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {number[]} request.localInventories + * Required. A list of inventory information at difference places. Each place + * is identified by its place ID. At most 3000 inventories are allowed per + * request. + * @param {google.protobuf.FieldMask} request.addMask + * Indicates which inventory fields in the provided list of + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory} to update. The + * field is updated to the provided value. + * + * If a field is set while the place does not have a previous local inventory, + * the local inventory at that store is created. + * + * If a field is set while the value of that field is not provided, the + * original field value, if it exists, is deleted. + * + * If the mask is not set or set with empty paths, all inventory fields will + * be updated. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned and the entire update will be ignored. + * @param {google.protobuf.Timestamp} request.addTime + * The time when the inventory updates are issued. Used to prevent + * out-of-order updates on local inventory fields. If not provided, the + * internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory will still be processed and retained for at + * most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + addLocalInventories( + request?: protos.google.cloud.retail.v2beta.IAddLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.addLocalInventories(request, options, callback); + } + /** + * Check the status of the long running operation returned by `addLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.add_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_AddLocalInventories_async + */ + async checkAddLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.AddLocalInventoriesMetadata + > + > { + 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.addLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.AddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.AddLocalInventoriesMetadata + >; + } + /** + * Remove local inventory information for a + * {@link google.cloud.retail.v2beta.Product|Product} at a list of places at a + * removal timestamp. + * + * This process is asynchronous. If the request is valid, the removal will be + * enqueued and processed downstream. As a consequence, when a response is + * returned, removals are not immediately manifested in the + * {@link google.cloud.retail.v2beta.Product|Product} queried by + * {@link google.cloud.retail.v2beta.ProductService.GetProduct|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.product + * Required. Full resource name of + * {@link google.cloud.retail.v2beta.Product|Product}, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`. + * + * If the caller does not have permission to access the + * {@link google.cloud.retail.v2beta.Product|Product}, regardless of whether or not + * it exists, a PERMISSION_DENIED error is returned. + * @param {string[]} request.placeIds + * Required. A list of place IDs to have their inventory deleted. + * At most 3000 place IDs are allowed per request. + * @param {google.protobuf.Timestamp} request.removeTime + * The time when the inventory deletions are issued. Used to prevent + * out-of-order updates and deletions on local inventory fields. If not + * provided, the internal system time will be used. + * @param {boolean} request.allowMissing + * If set to true, and the {@link google.cloud.retail.v2beta.Product|Product} is + * not found, the local inventory removal request will still be processed and + * retained for at most 1 day and processed once the + * {@link google.cloud.retail.v2beta.Product|Product} is created. If set to false, + * a NOT_FOUND error is returned if the + * {@link google.cloud.retail.v2beta.Product|Product} is not found. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + removeLocalInventories( + request?: protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >, + 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({ + product: request.product ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeLocalInventories( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `removeLocalInventories()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.remove_local_inventories.js + * region_tag:retail_v2beta_generated_ProductService_RemoveLocalInventories_async + */ + async checkRemoveLocalInventoriesProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + > + > { + 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.removeLocalInventories, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.RemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.RemoveLocalInventoriesMetadata + >; + } + /** + * Gets a list of {@link google.cloud.retail.v2beta.Product|Product}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is 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 Array of [Product]{@link google.cloud.retail.v2beta.Product}. + * 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest | null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ] + >; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + | protos.google.cloud.retail.v2beta.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IProduct + > + ): void; + listProducts( + request: protos.google.cloud.retail.v2beta.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + | protos.google.cloud.retail.v2beta.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IProduct + > + ): void; + listProducts( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + | protos.google.cloud.retail.v2beta.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IProduct + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListProductsRequest, + | protos.google.cloud.retail.v2beta.IListProductsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IProduct + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IProduct[], + protos.google.cloud.retail.v2beta.IListProductsRequest | null, + protos.google.cloud.retail.v2beta.IListProductsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @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 [Product]{@link google.cloud.retail.v2beta.Product} 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 `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listProductsStream( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. Use + * `default_branch` as the branch ID, to list products under the default + * branch. + * + * If the caller does not have permission to list + * {@link google.cloud.retail.v2beta.Product|Product}s under this branch, + * regardless of whether or not this branch exists, a PERMISSION_DENIED error + * is returned. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to 100. The maximum allowed value is 1000. Values + * above 1000 will be coerced to 1000. + * + * If this field is negative, an INVALID_ARGUMENT error is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.ListProductsResponse.next_page_token|ListProductsResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {string} request.filter + * A filter to apply on the list results. Supported features: + * + * * List all the products under the parent branch if + * {@link google.cloud.retail.v2beta.ListProductsRequest.filter|filter} is unset. + * * List + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|Product.Type.VARIANT} + * {@link google.cloud.retail.v2beta.Product|Product}s sharing the same + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product}. For example: + * `primary_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s bundled in a + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product}. + * For example: + * `collection_product_id = "some_product_id"` + * * List {@link google.cloud.retail.v2beta.Product|Product}s with a partibular + * type. For example: + * `type = "PRIMARY"` + * `type = "VARIANT"` + * `type = "COLLECTION"` + * + * If the field is unrecognizable, an INVALID_ARGUMENT error is returned. + * + * If the specified + * {@link google.cloud.retail.v2beta.Product.Type.PRIMARY|Product.Type.PRIMARY} + * {@link google.cloud.retail.v2beta.Product|Product} or + * {@link google.cloud.retail.v2beta.Product.Type.COLLECTION|Product.Type.COLLECTION} + * {@link google.cloud.retail.v2beta.Product|Product} does not exist, a NOT_FOUND + * error is returned. + * @param {google.protobuf.FieldMask} request.readMask + * The fields of {@link google.cloud.retail.v2beta.Product|Product} to return in + * the responses. If not set or empty, the following fields are returned: + * + * * {@link google.cloud.retail.v2beta.Product.name|Product.name} + * * {@link google.cloud.retail.v2beta.Product.id|Product.id} + * * {@link google.cloud.retail.v2beta.Product.title|Product.title} + * * {@link google.cloud.retail.v2beta.Product.uri|Product.uri} + * * {@link google.cloud.retail.v2beta.Product.images|Product.images} + * * {@link google.cloud.retail.v2beta.Product.price_info|Product.price_info} + * * {@link google.cloud.retail.v2beta.Product.brands|Product.brands} + * + * If "*" is provided, all fields are returned. + * {@link google.cloud.retail.v2beta.Product.name|Product.name} is always returned + * no matter what mask is set. + * + * If an unsupported or unknown field is provided, an INVALID_ARGUMENT error + * is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Product]{@link google.cloud.retail.v2beta.Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/product_service.list_products.js + * region_tag:retail_v2beta_generated_ProductService_ListProducts_async + */ + listProductsAsync( + request?: protos.google.cloud.retail.v2beta.IListProductsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.productServiceStub && !this._terminated) { + return this.productServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/product_service_client_config.json b/packages/google-cloud-retail/src/v2beta/product_service_client_config.json new file mode 100644 index 00000000000..459b579d7a8 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/product_service_client_config.json @@ -0,0 +1,99 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ProductService": { + "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 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "GetProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ListProducts": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "UpdateProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "DeleteProduct": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportProducts": { + "timeout_millis": 300000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "SetInventory": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveFulfillmentPlaces": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "AddLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "RemoveLocalInventories": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/product_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/product_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/product_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/search_service_client.ts b/packages/google-cloud-retail/src/v2beta/search_service_client.ts new file mode 100644 index 00000000000..ea996eaeafc --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/search_service_client.ts @@ -0,0 +1,2042 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/search_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './search_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for search. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * @class + * @memberof v2beta + */ +export class SearchServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + searchServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SearchServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof SearchServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + branchPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + search: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'results' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{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.cloud.retail.v2beta.SearchService', + 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.searchServiceStub) { + return this.searchServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.SearchService. + this.searchServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.SearchService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.SearchService, + 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 searchServiceStubMethods = ['search']; + for (const methodName of searchServiceStubMethods) { + const callPromise = this.searchServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.searchServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + + /** + * Performs a search. + * + * This feature is only available for users who have Retail Search enabled. + * Enable Retail Search on Cloud Console before using this feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. + * 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest | null, + protos.google.cloud.retail.v2beta.ISearchResponse + ] + >; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult + > + ): void; + search( + request: protos.google.cloud.retail.v2beta.ISearchRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult + > + ): void; + search( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.ISearchRequest, + protos.google.cloud.retail.v2beta.ISearchResponse | null | undefined, + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[], + protos.google.cloud.retail.v2beta.ISearchRequest | null, + protos.google.cloud.retail.v2beta.ISearchResponse + ] + > | 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({ + placement: request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.search(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @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 [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult} 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 `searchAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + searchStream( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.createStream( + this.innerApiCalls.search as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `search`, 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.placement + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving configuration name and the set + * of models that will be used to make the search. + * @param {string} request.branch + * The branch resource name, such as + * `projects/* /locations/global/catalogs/default_catalog/branches/0`. + * + * Use "default_branch" as the branch ID or leave this field empty, to search + * products under the default branch. + * @param {string} request.query + * Raw search query. + * + * If this field is empty, the request is considered a category browsing + * request and returned results are based on + * {@link google.cloud.retail.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.SearchRequest.page_categories|page_categories}. + * @param {string} request.visitorId + * Required. A unique identifier for tracking visitors. For example, this + * could be implemented with an HTTP cookie, which should be able to uniquely + * identify a visitor on a single device. This unique identifier should not + * change if the visitor logs in or out of the website. + * + * This should be the same identifier as + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id}. + * + * The field must be a UTF-8 encoded string with a length limit of 128 + * characters. Otherwise, an INVALID_ARGUMENT error is returned. + * @param {google.cloud.retail.v2beta.UserInfo} request.userInfo + * User information. + * @param {number} request.pageSize + * Maximum number of {@link google.cloud.retail.v2beta.Product|Product}s to return. + * If unspecified, defaults to a reasonable value. The maximum allowed value + * is 120. Values above 120 will be coerced to 120. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.pageToken + * A page token + * {@link google.cloud.retail.v2beta.SearchResponse.next_page_token|SearchResponse.next_page_token}, + * received from a previous + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link google.cloud.retail.v2beta.SearchService.Search|SearchService.Search} + * must match the call that provided the page token. Otherwise, an + * INVALID_ARGUMENT error is returned. + * @param {number} request.offset + * A 0-indexed integer that specifies the current offset (that is, starting + * result location, amongst the {@link google.cloud.retail.v2beta.Product|Product}s + * deemed by the API as relevant) in search results. This field is only + * considered if + * {@link google.cloud.retail.v2beta.SearchRequest.page_token|page_token} is unset. + * + * If this field is negative, an INVALID_ARGUMENT is returned. + * @param {string} request.filter + * The filter syntax consists of an expression language for constructing a + * predicate from one or more fields of the products being filtered. Filter + * expression is case-sensitive. See more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#filter). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {string} request.canonicalFilter + * The default filter that is applied when a user performs a search without + * checking any filters on the search page. + * + * The filter applied to every search request when quality improvement such as + * query expansion is needed. For example, if a query does not have enough + * results, an expanded query with + * {@link google.cloud.retail.v2beta.SearchRequest.canonical_filter|SearchRequest.canonical_filter} + * will be returned as a supplement of the original query. This field is + * strongly recommended to achieve high search quality. + * + * See {@link google.cloud.retail.v2beta.SearchRequest.filter|SearchRequest.filter} + * for more details about filter syntax. + * @param {string} request.orderBy + * The order in which products are returned. Products can be ordered by + * a field in an {@link google.cloud.retail.v2beta.Product|Product} object. Leave + * it unset if ordered by relevance. OrderBy expression is case-sensitive. See + * more details at this [user + * guide](https://cloud.google.com/retail/docs/filter-and-order#order). + * + * If this field is unrecognizable, an INVALID_ARGUMENT is returned. + * @param {number[]} request.facetSpecs + * Facet specifications for faceted search. If empty, no facets are returned. + * + * A maximum of 100 values are allowed. Otherwise, an INVALID_ARGUMENT error + * is returned. + * @param {google.cloud.retail.v2beta.SearchRequest.DynamicFacetSpec} request.dynamicFacetSpec + * Deprecated. Refer to https://cloud.google.com/retail/docs/configs#dynamic + * to enable dynamic facets. Do not set this field. + * + * The specification for dynamically generated facets. Notice that only + * textual facets can be dynamically generated. + * @param {google.cloud.retail.v2beta.SearchRequest.BoostSpec} request.boostSpec + * Boost specification to boost certain products. See more details at this + * [user guide](https://cloud.google.com/retail/docs/boosting). + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.boost_control_ids|ServingConfig.boost_control_ids} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.boost_spec|SearchRequest.boost_spec} + * are set, the boost conditions from both places are evaluated. If a search + * request matches multiple boost conditions, the final boost score is equal + * to the sum of the boost scores from all matched boost conditions. + * @param {google.cloud.retail.v2beta.SearchRequest.QueryExpansionSpec} request.queryExpansionSpec + * The query expansion specification that specifies the conditions under which + * query expansion will occur. See more details at this [user + * guide](https://cloud.google.com/retail/docs/result-size#query_expansion). + * @param {string[]} request.variantRollupKeys + * The keys to fetch and rollup the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s attributes, + * {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo} or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s attributes. + * The attributes from all the matching + * {@link google.cloud.retail.v2beta.Product.Type.VARIANT|variant} + * {@link google.cloud.retail.v2beta.Product|Product}s or + * {@link google.cloud.retail.v2beta.LocalInventory|LocalInventory}s are merged and + * de-duplicated. Notice that rollup attributes will lead to extra query + * latency. Maximum number of keys is 30. + * + * For {@link google.cloud.retail.v2beta.FulfillmentInfo|FulfillmentInfo}, a + * fulfillment type and a fulfillment ID must be provided in the format of + * "fulfillmentType.fulfillmentId". E.g., in "pickupInStore.store123", + * "pickupInStore" is fulfillment type and "store123" is the store ID. + * + * Supported keys are: + * + * * colorFamilies + * * price + * * originalPrice + * * discount + * * variantId + * * inventory(place_id,price) + * * inventory(place_id,original_price) + * * inventory(place_id,attributes.key), where key is any key in the + * {@link google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_inventories.attributes} + * map. + * * attributes.key, where key is any key in the + * {@link google.cloud.retail.v2beta.Product.attributes|Product.attributes} map. + * * pickupInStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "pickup-in-store". + * * shipToStore.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "ship-to-store". + * * sameDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "same-day-delivery". + * * nextDayDelivery.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "next-day-delivery". + * * customFulfillment1.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-1". + * * customFulfillment2.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-2". + * * customFulfillment3.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-3". + * * customFulfillment4.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-4". + * * customFulfillment5.id, where id is any + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|FulfillmentInfo.place_ids} + * for {@link google.cloud.retail.v2beta.FulfillmentInfo.type|FulfillmentInfo.type} + * "custom-type-5". + * + * If this field is set to an invalid value other than these, an + * INVALID_ARGUMENT error is returned. + * @param {string[]} request.pageCategories + * The categories associated with a category page. Required for category + * navigation queries to achieve good search quality. The format should be + * the same as + * {@link google.cloud.retail.v2beta.UserEvent.page_categories|UserEvent.page_categories}; + * + * To represent full path of category, use '>' sign to separate different + * hierarchies. If '>' is part of the category name, replace it with + * other character(s). + * + * Category pages include special pages such as sales or promotions. For + * instance, a special sale page may have the category hierarchy: + * "pageCategories" : ["Sales > 2017 Black Friday Deals"]. + * @param {google.cloud.retail.v2beta.SearchRequest.SearchMode} request.searchMode + * The search mode of the search request. If not specified, a single search + * request triggers both product search and faceted search. + * @param {google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec} request.personalizationSpec + * The specification for personalization. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @param {number[]} request.labels + * The labels applied to a resource must meet the following requirements: + * + * * Each resource can have multiple labels, up to a maximum of 64. + * * Each label must be a key-value pair. + * * Keys have a minimum length of 1 character and a maximum length of 63 + * characters and cannot be empty. Values can be empty and have a maximum + * length of 63 characters. + * * Keys and values can contain only lowercase letters, numeric characters, + * underscores, and dashes. All characters must use UTF-8 encoding, and + * international characters are allowed. + * * The key portion of a label must be unique. However, you can use the same + * key with multiple resources. + * * Keys must start with a lowercase letter or international character. + * + * See [Google Cloud + * Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements) + * for more details. + * @param {google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [SearchResult]{@link google.cloud.retail.v2beta.SearchResponse.SearchResult}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/search_service.search.js + * region_tag:retail_v2beta_generated_SearchService_Search_async + */ + searchAsync( + request?: protos.google.cloud.retail.v2beta.ISearchRequest, + 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({ + placement: request.placement ?? '', + }); + const defaultCallSettings = this._defaults['search']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.search.asyncIterate( + this.innerApiCalls['search'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified branch resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @returns {string} Resource name string. + */ + branchPath( + project: string, + location: string, + catalog: string, + branch: string + ) { + return this.pathTemplates.branchPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + }); + } + + /** + * Parse the project from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the project. + */ + matchProjectFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).project; + } + + /** + * Parse the location from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).location; + } + + /** + * Parse the catalog from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).catalog; + } + + /** + * Parse the branch from Branch resource. + * + * @param {string} branchName + * A fully-qualified path representing Branch resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromBranchName(branchName: string) { + return this.pathTemplates.branchPathTemplate.match(branchName).branch; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.searchServiceStub && !this._terminated) { + return this.searchServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/search_service_client_config.json b/packages/google-cloud-retail/src/v2beta/search_service_client_config.json new file mode 100644 index 00000000000..82de0f81873 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/search_service_client_config.json @@ -0,0 +1,40 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.SearchService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "Search": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/search_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/search_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/search_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts b/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts new file mode 100644 index 00000000000..144ddd5906e --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/serving_config_service_client.ts @@ -0,0 +1,1903 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/serving_config_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './serving_config_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for modifying ServingConfig. + * @class + * @memberof v2beta + */ +export class ServingConfigServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + servingConfigServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ServingConfigServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ServingConfigServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + // 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 = { + listServingConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'servingConfigs' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{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.cloud.retail.v2beta.ServingConfigService', + 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.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.ServingConfigService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ServingConfigService, + 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 servingConfigServiceStubMethods = [ + 'createServingConfig', + 'deleteServingConfig', + 'updateServingConfig', + 'getServingConfig', + 'listServingConfigs', + 'addControl', + 'removeControl', + ]; + for (const methodName of servingConfigServiceStubMethods) { + const callPromise = this.servingConfigServiceStub.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] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.servingConfigServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Creates a ServingConfig. + * + * A maximum of 100 {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig}s + * are allowed in a {@link google.cloud.retail.v2beta.Catalog|Catalog}, otherwise + * a FAILED_PRECONDITION error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full resource name of parent. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to create. + * @param {string} request.servingConfigId + * Required. The ID to use for the ServingConfig, which will become the final + * component of the ServingConfig's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link 0-9|a-z}-_/. + * @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 [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.create_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest | undefined, + {} | undefined + ] + >; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createServingConfig( + request?: protos.google.cloud.retail.v2beta.ICreateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.ICreateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.ICreateServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createServingConfig(request, options, callback); + } + /** + * Deletes a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.delete_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest | undefined, + {} | undefined + ] + >; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteServingConfig(request, options, callback); + } + /** + * Updates a ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2beta.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2beta.ServingConfig.name|ServingConfig.name} + * + * If not set, all supported fields are updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.update_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest | undefined, + {} | undefined + ] + >; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IUpdateServingConfigRequest | 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({ + 'serving_config.name': request.servingConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateServingConfig(request, options, callback); + } + /** + * Gets a ServingConfig. + * + * Returns a NotFound error if the ServingConfig does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the ServingConfig to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.get_serving_config.js + * region_tag:retail_v2beta_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest | undefined, + {} | undefined + ] + >; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getServingConfig( + request?: protos.google.cloud.retail.v2beta.IGetServingConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IGetServingConfigRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IGetServingConfigRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getServingConfig(request, options, callback); + } + /** + * Enables a Control on the specified ServingConfig. + * The control is added in the last position of the list of controls + * it belongs to (e.g. if it's a facet spec control it will be applied + * in the last position of servingConfig.facetSpecIds) + * Returns a ALREADY_EXISTS error if the control has already been applied. + * Returns a FAILED_PRECONDITION error if the addition could exceed maximum + * number of control allowed for that type of control. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config - if id is not found a NOT_FOUND error is 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 [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.add_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest | undefined, + {} | undefined + ] + >; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request: protos.google.cloud.retail.v2beta.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): void; + addControl( + request?: protos.google.cloud.retail.v2beta.IAddControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IAddControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IAddControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addControl(request, options, callback); + } + /** + * Disables a Control on the specified ServingConfig. + * The control is removed from the ServingConfig. + * Returns a NOT_FOUND error if the Control is not enabled for the + * ServingConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.servingConfig + * Required. The source ServingConfig resource name . Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/servingConfigs/{serving_config_id}` + * @param {string} request.controlId + * Required. The id of the control to apply. Assumed to be in the same catalog + * as the serving config. + * @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 [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.remove_control.js + * region_tag:retail_v2beta_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest | undefined, + {} | undefined + ] + >; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeControl( + request: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): void; + removeControl( + request?: protos.google.cloud.retail.v2beta.IRemoveControlRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IServingConfig, + | protos.google.cloud.retail.v2beta.IRemoveControlRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig, + protos.google.cloud.retail.v2beta.IRemoveControlRequest | 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({ + serving_config: request.servingConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeControl(request, options, callback); + } + + /** + * Lists all ServingConfigs linked to this catalog. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. + * 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ] + >; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + | protos.google.cloud.retail.v2beta.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IServingConfig + > + ): void; + listServingConfigs( + request: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + | protos.google.cloud.retail.v2beta.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IServingConfig + > + ): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + | protos.google.cloud.retail.v2beta.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IServingConfig + >, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + | protos.google.cloud.retail.v2beta.IListServingConfigsResponse + | null + | undefined, + protos.google.cloud.retail.v2beta.IServingConfig + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IServingConfig[], + protos.google.cloud.retail.v2beta.IListServingConfigsRequest | null, + protos.google.cloud.retail.v2beta.IListServingConfigsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listServingConfigs(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @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 [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig} 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 `listServingConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listServingConfigsStream( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.createStream( + this.innerApiCalls.listServingConfigs as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listServingConfigs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The catalog resource name. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {number} [request.pageSize] + * Optional. Maximum number of results to return. If unspecified, defaults + * to 100. If a value greater than 100 is provided, at most 100 results are + * returned. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListServingConfigs` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [ServingConfig]{@link google.cloud.retail.v2beta.ServingConfig}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2beta/serving_config_service.list_serving_configs.js + * region_tag:retail_v2beta_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2beta.IListServingConfigsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listServingConfigs']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listServingConfigs.asyncIterate( + this.innerApiCalls['listServingConfigs'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.servingConfigServiceStub && !this._terminated) { + return this.servingConfigServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/serving_config_service_client_config.json b/packages/google-cloud-retail/src/v2beta/serving_config_service_client_config.json new file mode 100644 index 00000000000..2d17b5273c2 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ServingConfigService": { + "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": { + "CreateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetServingConfig": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListServingConfigs": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AddControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "RemoveControl": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/serving_config_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/serving_config_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/serving_config_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts b/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts new file mode 100644 index 00000000000..994a7f011f8 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/user_event_service_client.ts @@ -0,0 +1,1812 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/user_event_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './user_event_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for ingesting end user actions on the customer website. + * @class + * @memberof v2beta + */ +export class UserEventServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + userEventServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of UserEventServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof UserEventServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + attributesConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/attributesConfig' + ), + catalogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}' + ), + completionConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/completionConfig' + ), + controlPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/controls/{control}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + productPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/branches/{branch}/products/{product}' + ), + servingConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}', + additional_bindings: [ + { + get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}', + }, + {get: '/v2beta/{name=projects/*/locations/*/operations/*}'}, + {get: '/v2beta/{name=projects/*/operations/*}'}, + ], + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations', + additional_bindings: [ + {get: '/v2beta/{name=projects/*/locations/*}/operations'}, + {get: '/v2beta/{name=projects/*}/operations'}, + ], + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const purgeUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeUserEventsResponse' + ) as gax.protobuf.Type; + const purgeUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.PurgeMetadata' + ) as gax.protobuf.Type; + const importUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportUserEventsResponse' + ) as gax.protobuf.Type; + const importUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.ImportMetadata' + ) as gax.protobuf.Type; + const rejoinUserEventsResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsResponse' + ) as gax.protobuf.Type; + const rejoinUserEventsMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.RejoinUserEventsMetadata' + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + purgeUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + purgeUserEventsResponse.decode.bind(purgeUserEventsResponse), + purgeUserEventsMetadata.decode.bind(purgeUserEventsMetadata) + ), + importUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importUserEventsResponse.decode.bind(importUserEventsResponse), + importUserEventsMetadata.decode.bind(importUserEventsMetadata) + ), + rejoinUserEvents: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + rejoinUserEventsResponse.decode.bind(rejoinUserEventsResponse), + rejoinUserEventsMetadata.decode.bind(rejoinUserEventsMetadata) + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.UserEventService', + 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.userEventServiceStub) { + return this.userEventServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.UserEventService. + this.userEventServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.retail.v2beta.UserEventService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.UserEventService, + 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 userEventServiceStubMethods = [ + 'writeUserEvent', + 'collectUserEvent', + 'purgeUserEvents', + 'importUserEvents', + 'rejoinUserEvents', + ]; + for (const methodName of userEventServiceStubMethods) { + const callPromise = this.userEventServiceStub.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.longrunning[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.userEventServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'retail.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'retail.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + 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 -- + // ------------------- + /** + * Writes a single user event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.UserEvent} request.userEvent + * Required. User event to write. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UserEvent]{@link google.cloud.retail.v2beta.UserEvent}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.write_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_WriteUserEvent_async + */ + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest | undefined, + {} | undefined + ] + >; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + | protos.google.cloud.retail.v2beta.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + | protos.google.cloud.retail.v2beta.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + writeUserEvent( + request?: protos.google.cloud.retail.v2beta.IWriteUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + | protos.google.cloud.retail.v2beta.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.retail.v2beta.IUserEvent, + | protos.google.cloud.retail.v2beta.IWriteUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.retail.v2beta.IUserEvent, + protos.google.cloud.retail.v2beta.IWriteUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.writeUserEvent(request, options, callback); + } + /** + * Writes a single user event from the browser. This uses a GET request to + * due to browser restriction of POST-ing to a 3rd party domain. + * + * This method is used only by the Retail API JavaScript pixel and Google Tag + * Manager. Users should not call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {string} request.userEvent + * Required. URL encoded UserEvent proto with a length limit of 2,000,000 + * characters. + * @param {string} request.uri + * The URL including cgi-parameters but excluding the hash fragment with a + * length limit of 5,000 characters. This is often more useful than the + * referer URL, because many browsers only send the domain for 3rd party + * requests. + * @param {number} request.ets + * The event timestamp in milliseconds. This prevents browser caching of + * otherwise identical get requests. The name is abbreviated to reduce the + * payload bytes. + * @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 [HttpBody]{@link google.api.HttpBody}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.collect_user_event.js + * region_tag:retail_v2beta_generated_UserEventService_CollectUserEvent_async + */ + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options?: CallOptions + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest | undefined, + {} | undefined + ] + >; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + options: CallOptions, + callback: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2beta.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + callback: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2beta.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): void; + collectUserEvent( + request?: protos.google.cloud.retail.v2beta.ICollectUserEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2beta.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.api.IHttpBody, + | protos.google.cloud.retail.v2beta.ICollectUserEventRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.api.IHttpBody, + protos.google.cloud.retail.v2beta.ICollectUserEventRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.collectUserEvent(request, options, callback); + } + + /** + * Deletes permanently all user events specified by the filter provided. + * Depending on the number of events specified by the filter, this operation + * could take hours or days to complete. To test a filter, use the list + * command first. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the catalog under which the events are + * created. The format is + * `projects/${projectId}/locations/global/catalogs/${catalogId}` + * @param {string} request.filter + * Required. The filter string to specify the events to be deleted with a + * length limit of 5,000 characters. Empty string filter is not allowed. The + * eligible fields for filtering are: + * + * * `eventType`: Double quoted + * {@link google.cloud.retail.v2beta.UserEvent.event_type|UserEvent.event_type} + * string. + * * `eventTime`: in ISO 8601 "zulu" format. + * * `visitorId`: Double quoted string. Specifying this will delete all + * events associated with a visitor. + * * `userId`: Double quoted string. Specifying this will delete all events + * associated with a user. + * + * Examples: + * + * * Deleting all events in a time range: + * `eventTime > "2012-04-23T18:25:43.511Z" + * eventTime < "2012-04-23T18:30:43.511Z"` + * * Deleting specific eventType in time range: + * `eventTime > "2012-04-23T18:25:43.511Z" eventType = "detail-page-view"` + * * Deleting all events for a specific visitor: + * `visitorId = "visitor1024"` + * + * The filtering fields are assumed to have an implicit AND. + * @param {boolean} request.force + * Actually perform the purge. + * If `force` is set to false, the method will return the expected purge count + * without deleting any user events. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + purgeUserEvents( + request?: protos.google.cloud.retail.v2beta.IPurgeUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `purgeUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.purge_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_PurgeUserEvents_async + */ + async checkPurgeUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.PurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.PurgeMetadata + > + > { + 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.purgeUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.PurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.PurgeMetadata + >; + } + /** + * Bulk import of User events. Request processing might be + * synchronous. Events that already exist are skipped. + * Use this method for backfilling historical user events. + * + * `Operation.response` is of type `ImportResponse`. Note that it is + * possible for a subset of the items to be successfully inserted. + * `Operation.metadata` is of type `ImportMetadata`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. `projects/1234/locations/global/catalogs/default_catalog` + * @param {google.cloud.retail.v2beta.UserEventInputConfig} request.inputConfig + * Required. The desired input location of the data. + * @param {google.cloud.retail.v2beta.ImportErrorsConfig} request.errorsConfig + * The desired location of errors incurred during the Import. Cannot be set + * for inline user event imports. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + importUserEvents( + request?: protos.google.cloud.retail.v2beta.IImportUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.importUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `importUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.import_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_ImportUserEvents_async + */ + async checkImportUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.ImportUserEventsResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + > + > { + 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.importUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.ImportUserEventsResponse, + protos.google.cloud.retail.v2beta.ImportMetadata + >; + } + /** + * Starts a user-event rejoin operation with latest product catalog. Events + * are not annotated with detailed product information for products that are + * missing from the catalog when the user event is ingested. These + * events are stored as unjoined events with limited usage on training and + * serving. You can use this method to start a join operation on specified + * events with the latest version of product catalog. You can also use this + * method to correct events joined with the wrong product catalog. A rejoin + * operation can take hours or days to complete. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + * @param {google.cloud.retail.v2beta.RejoinUserEventsRequest.UserEventRejoinScope} request.userEventRejoinScope + * The type of the user event rejoin to define the scope and range of the user + * events to be rejoined with the latest product catalog. Defaults to + * `USER_EVENT_REJOIN_SCOPE_UNSPECIFIED` if this field is not set, or set to + * an invalid integer value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + callback: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + rejoinUserEvents( + request?: protos.google.cloud.retail.v2beta.IRejoinUserEventsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.rejoinUserEvents(request, options, callback); + } + /** + * Check the status of the long running operation returned by `rejoinUserEvents()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2beta/user_event_service.rejoin_user_events.js + * region_tag:retail_v2beta_generated_UserEventService_RejoinUserEvents_async + */ + async checkRejoinUserEventsProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.retail.v2beta.RejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.RejoinUserEventsMetadata + > + > { + 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.rejoinUserEvents, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.retail.v2beta.RejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.RejoinUserEventsMetadata + >; + } + /** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + + /** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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 + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#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. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified attributesConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + attributesConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.attributesConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).project; + } + + /** + * Parse the location from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).location; + } + + /** + * Parse the catalog from AttributesConfig resource. + * + * @param {string} attributesConfigName + * A fully-qualified path representing AttributesConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromAttributesConfigName(attributesConfigName: string) { + return this.pathTemplates.attributesConfigPathTemplate.match( + attributesConfigName + ).catalog; + } + + /** + * Return a fully-qualified catalog resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + catalogPath(project: string, location: string, catalog: string) { + return this.pathTemplates.catalogPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).project; + } + + /** + * Parse the location from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).location; + } + + /** + * Parse the catalog from Catalog resource. + * + * @param {string} catalogName + * A fully-qualified path representing Catalog resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCatalogName(catalogName: string) { + return this.pathTemplates.catalogPathTemplate.match(catalogName).catalog; + } + + /** + * Return a fully-qualified completionConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @returns {string} Resource name string. + */ + completionConfigPath(project: string, location: string, catalog: string) { + return this.pathTemplates.completionConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + }); + } + + /** + * Parse the project from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).project; + } + + /** + * Parse the location from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).location; + } + + /** + * Parse the catalog from CompletionConfig resource. + * + * @param {string} completionConfigName + * A fully-qualified path representing CompletionConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromCompletionConfigName(completionConfigName: string) { + return this.pathTemplates.completionConfigPathTemplate.match( + completionConfigName + ).catalog; + } + + /** + * Return a fully-qualified control resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} control + * @returns {string} Resource name string. + */ + controlPath( + project: string, + location: string, + catalog: string, + control: string + ) { + return this.pathTemplates.controlPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + control: control, + }); + } + + /** + * Parse the project from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the project. + */ + matchProjectFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).project; + } + + /** + * Parse the location from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the location. + */ + matchLocationFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).location; + } + + /** + * Parse the catalog from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).catalog; + } + + /** + * Parse the control from Control resource. + * + * @param {string} controlName + * A fully-qualified path representing Control resource. + * @returns {string} A string representing the control. + */ + matchControlFromControlName(controlName: string) { + return this.pathTemplates.controlPathTemplate.match(controlName).control; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project: string, location: string, catalog: string, model: string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * Return a fully-qualified product resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} branch + * @param {string} product + * @returns {string} Resource name string. + */ + productPath( + project: string, + location: string, + catalog: string, + branch: string, + product: string + ) { + return this.pathTemplates.productPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + branch: branch, + product: product, + }); + } + + /** + * Parse the project from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).project; + } + + /** + * Parse the location from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).location; + } + + /** + * Parse the catalog from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).catalog; + } + + /** + * Parse the branch from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the branch. + */ + matchBranchFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).branch; + } + + /** + * Parse the product from Product resource. + * + * @param {string} productName + * A fully-qualified path representing Product resource. + * @returns {string} A string representing the product. + */ + matchProductFromProductName(productName: string) { + return this.pathTemplates.productPathTemplate.match(productName).product; + } + + /** + * Return a fully-qualified servingConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} serving_config + * @returns {string} Resource name string. + */ + servingConfigPath( + project: string, + location: string, + catalog: string, + servingConfig: string + ) { + return this.pathTemplates.servingConfigPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + serving_config: servingConfig, + }); + } + + /** + * Parse the project from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .project; + } + + /** + * Parse the location from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .location; + } + + /** + * Parse the catalog from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .catalog; + } + + /** + * Parse the serving_config from ServingConfig resource. + * + * @param {string} servingConfigName + * A fully-qualified path representing ServingConfig resource. + * @returns {string} A string representing the serving_config. + */ + matchServingConfigFromServingConfigName(servingConfigName: string) { + return this.pathTemplates.servingConfigPathTemplate.match(servingConfigName) + .serving_config; + } + + /** + * 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.userEventServiceStub && !this._terminated) { + return this.userEventServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-retail/src/v2beta/user_event_service_client_config.json b/packages/google-cloud-retail/src/v2beta/user_event_service_client_config.json new file mode 100644 index 00000000000..f5bd2baedcc --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/user_event_service_client_config.json @@ -0,0 +1,78 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.UserEventService": { + "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 + }, + "319f27672a8be83550d842a373549dd84649a57e": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 5000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "71ca22c74d2828b200f9ff1cc285a8beb96cc2af": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 30000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "49abb7cadc111ff8dd551b61fcad123362c8d090": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 300000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "WriteUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "CollectUserEvent": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + }, + "PurgeUserEvents": { + "timeout_millis": 30000, + "retry_codes_name": "idempotent", + "retry_params_name": "71ca22c74d2828b200f9ff1cc285a8beb96cc2af" + }, + "ImportUserEvents": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "49abb7cadc111ff8dd551b61fcad123362c8d090" + }, + "RejoinUserEvents": { + "timeout_millis": 5000, + "retry_codes_name": "idempotent", + "retry_params_name": "319f27672a8be83550d842a373549dd84649a57e" + } + } + } + } +} diff --git a/packages/google-cloud-retail/src/v2beta/user_event_service_proto_list.json b/packages/google-cloud-retail/src/v2beta/user_event_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/packages/google-cloud-retail/src/v2beta/user_event_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../protos/google/cloud/retail/v2beta/catalog.proto", + "../../protos/google/cloud/retail/v2beta/catalog_service.proto", + "../../protos/google/cloud/retail/v2beta/common.proto", + "../../protos/google/cloud/retail/v2beta/completion_service.proto", + "../../protos/google/cloud/retail/v2beta/control.proto", + "../../protos/google/cloud/retail/v2beta/control_service.proto", + "../../protos/google/cloud/retail/v2beta/export_config.proto", + "../../protos/google/cloud/retail/v2beta/import_config.proto", + "../../protos/google/cloud/retail/v2beta/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.proto", + "../../protos/google/cloud/retail/v2beta/prediction_service.proto", + "../../protos/google/cloud/retail/v2beta/product.proto", + "../../protos/google/cloud/retail/v2beta/product_service.proto", + "../../protos/google/cloud/retail/v2beta/promotion.proto", + "../../protos/google/cloud/retail/v2beta/purge_config.proto", + "../../protos/google/cloud/retail/v2beta/search_service.proto", + "../../protos/google/cloud/retail/v2beta/serving_config.proto", + "../../protos/google/cloud/retail/v2beta/serving_config_service.proto", + "../../protos/google/cloud/retail/v2beta/user_event.proto", + "../../protos/google/cloud/retail/v2beta/user_event_service.proto" +] diff --git a/packages/google-cloud-retail/system-test/fixtures/sample/src/index.js b/packages/google-cloud-retail/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..e08fd320370 --- /dev/null +++ b/packages/google-cloud-retail/system-test/fixtures/sample/src/index.js @@ -0,0 +1,34 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const retail = require('@google-cloud/retail'); + +function main() { + const catalogServiceClient = new retail.CatalogServiceClient(); + const completionServiceClient = new retail.CompletionServiceClient(); + const controlServiceClient = new retail.ControlServiceClient(); + const modelServiceClient = new retail.ModelServiceClient(); + const predictionServiceClient = new retail.PredictionServiceClient(); + const productServiceClient = new retail.ProductServiceClient(); + const searchServiceClient = new retail.SearchServiceClient(); + const servingConfigServiceClient = new retail.ServingConfigServiceClient(); + const userEventServiceClient = new retail.UserEventServiceClient(); +} + +main(); diff --git a/packages/google-cloud-retail/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-retail/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..0d91f723442 --- /dev/null +++ b/packages/google-cloud-retail/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,92 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { + CatalogServiceClient, + CompletionServiceClient, + ControlServiceClient, + ModelServiceClient, + PredictionServiceClient, + ProductServiceClient, + SearchServiceClient, + ServingConfigServiceClient, + UserEventServiceClient, +} from '@google-cloud/retail'; + +// check that the client class type name can be used +function doStuffWithCatalogServiceClient(client: CatalogServiceClient) { + client.close(); +} +function doStuffWithCompletionServiceClient(client: CompletionServiceClient) { + client.close(); +} +function doStuffWithControlServiceClient(client: ControlServiceClient) { + client.close(); +} +function doStuffWithModelServiceClient(client: ModelServiceClient) { + client.close(); +} +function doStuffWithPredictionServiceClient(client: PredictionServiceClient) { + client.close(); +} +function doStuffWithProductServiceClient(client: ProductServiceClient) { + client.close(); +} +function doStuffWithSearchServiceClient(client: SearchServiceClient) { + client.close(); +} +function doStuffWithServingConfigServiceClient( + client: ServingConfigServiceClient +) { + client.close(); +} +function doStuffWithUserEventServiceClient(client: UserEventServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const catalogServiceClient = new CatalogServiceClient(); + doStuffWithCatalogServiceClient(catalogServiceClient); + // check that the client instance can be created + const completionServiceClient = new CompletionServiceClient(); + doStuffWithCompletionServiceClient(completionServiceClient); + // check that the client instance can be created + const controlServiceClient = new ControlServiceClient(); + doStuffWithControlServiceClient(controlServiceClient); + // check that the client instance can be created + const modelServiceClient = new ModelServiceClient(); + doStuffWithModelServiceClient(modelServiceClient); + // check that the client instance can be created + const predictionServiceClient = new PredictionServiceClient(); + doStuffWithPredictionServiceClient(predictionServiceClient); + // check that the client instance can be created + const productServiceClient = new ProductServiceClient(); + doStuffWithProductServiceClient(productServiceClient); + // check that the client instance can be created + const searchServiceClient = new SearchServiceClient(); + doStuffWithSearchServiceClient(searchServiceClient); + // check that the client instance can be created + const servingConfigServiceClient = new ServingConfigServiceClient(); + doStuffWithServingConfigServiceClient(servingConfigServiceClient); + // check that the client instance can be created + const userEventServiceClient = new UserEventServiceClient(); + doStuffWithUserEventServiceClient(userEventServiceClient); +} + +main(); diff --git a/packages/google-cloud-retail/system-test/install.ts b/packages/google-cloud-retail/system-test/install.ts new file mode 100644 index 00000000000..6dd1eaadafa --- /dev/null +++ b/packages/google-cloud-retail/system-test/install.ts @@ -0,0 +1,51 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + it('TypeScript code', async function () { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts' + ).toString(), + }, + }; + await packNTest(options); + }); + + it('JavaScript code', async function () { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync( + './system-test/fixtures/sample/src/index.js' + ).toString(), + }, + }; + await packNTest(options); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_catalog_service_v2.ts b/packages/google-cloud-retail/test/gapic_catalog_service_v2.ts new file mode 100644 index 00000000000..5ba3c5b3c7a --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_catalog_service_v2.ts @@ -0,0 +1,2937 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2.CatalogServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + catalogserviceModule.v2.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + catalogserviceModule.v2.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + 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('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Catalog() + ); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Catalog() + ); + client.innerApiCalls.updateCatalog = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.ICatalog | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IGetDefaultBranchResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.innerApiCalls.listCatalogs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.ICatalog[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + 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.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Catalog[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Catalog) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + 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 catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_catalog_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_catalog_service_v2alpha.ts new file mode 100644 index 00000000000..64ae0b5c311 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_catalog_service_v2alpha.ts @@ -0,0 +1,3019 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2alpha.CatalogServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + catalogserviceModule.v2alpha.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + catalogserviceModule.v2alpha.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2alpha.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + 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('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Catalog() + ); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Catalog() + ); + client.innerApiCalls.updateCatalog = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.ICatalog | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IGetDefaultBranchResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.innerApiCalls.listCatalogs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.ICatalog[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Catalog) => { + 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.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Catalog[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Catalog) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + 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 catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_catalog_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_catalog_service_v2beta.ts new file mode 100644 index 00000000000..c24f91ecb78 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_catalog_service_v2beta.ts @@ -0,0 +1,3156 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as catalogserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2beta.CatalogServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + catalogserviceModule.v2beta.CatalogServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + catalogserviceModule.v2beta.CatalogServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = catalogserviceModule.v2beta.CatalogServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + await client.initialize(); + assert(client.catalogServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.catalogServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.catalogServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + 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('updateCatalog', () => { + it('invokes updateCatalog without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Catalog() + ); + client.innerApiCalls.updateCatalog = stubSimpleCall(expectedResponse); + const [response] = await client.updateCatalog(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Catalog() + ); + client.innerApiCalls.updateCatalog = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCatalog( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.ICatalog | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCatalog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCatalog with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCatalogRequest() + ); + request.catalog ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCatalogRequest', + ['catalog', 'name'] + ); + request.catalog.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateCatalog(request), expectedError); + }); + }); + + describe('setDefaultBranch', () => { + it('invokes setDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setDefaultBranch(request), expectedError); + }); + }); + + describe('getDefaultBranch', () => { + it('invokes getDefaultBranch without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.getDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchResponse() + ); + client.innerApiCalls.getDefaultBranch = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDefaultBranch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IGetDefaultBranchResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDefaultBranch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDefaultBranch with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetDefaultBranchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetDefaultBranchRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDefaultBranch(request), expectedError); + }); + }); + + describe('getCompletionConfig', () => { + it('invokes getCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetCompletionConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetCompletionConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCompletionConfig(request), expectedError); + }); + }); + + describe('updateCompletionConfig', () => { + it('invokes updateCompletionConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.ICompletionConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompletionConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', + ['completionConfig', 'name'] + ); + request.completionConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateCompletionConfig(request), + expectedError + ); + }); + }); + + describe('getAttributesConfig', () => { + it('invokes getAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetAttributesConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetAttributesConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAttributesConfig(request), expectedError); + }); + }); + + describe('updateAttributesConfig', () => { + it('invokes updateAttributesConfig without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttributesConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', + ['attributesConfig', 'name'] + ); + request.attributesConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.updateAttributesConfig(request), + expectedError + ); + }); + }); + + describe('addCatalogAttribute', () => { + it('invokes addCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + }); + }); + + describe('removeCatalogAttribute', () => { + it('invokes removeCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.removeCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('batchRemoveCatalogAttributes', () => { + it('invokes batchRemoveCatalogAttributes without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = + stubSimpleCall(expectedResponse); + const [response] = await client.batchRemoveCatalogAttributes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchRemoveCatalogAttributes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.batchRemoveCatalogAttributes(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.batchRemoveCatalogAttributes(request), + expectedError + ); + }); + }); + + describe('replaceCatalogAttribute', () => { + it('invokes replaceCatalogAttribute without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IAttributesConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceCatalogAttribute as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute with closed client', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', + ['attributesConfig'] + ); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.replaceCatalogAttribute(request), + expectedError + ); + }); + }); + + describe('listCatalogs', () => { + it('invokes listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = stubSimpleCall(expectedResponse); + const [response] = await client.listCatalogs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.innerApiCalls.listCatalogs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCatalogs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.ICatalog[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCatalogs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listCatalogsStream without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Catalog) => { + 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.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listCatalogsStream with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCatalogsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Catalog[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Catalog) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCatalogs, request) + ); + assert( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Catalog()), + ]; + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + const iterable = client.listCatalogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listCatalogs with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListCatalogsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListCatalogsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCatalogs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCatalogsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.ICatalog[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCatalogs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + 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 catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_completion_service_v2.ts b/packages/google-cloud-retail/test/gapic_completion_service_v2.ts new file mode 100644 index 00000000000..4d4026f71bb --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_completion_service_v2.ts @@ -0,0 +1,1493 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as completionserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2.CompletionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + completionserviceModule.v2.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + completionserviceModule.v2.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new completionserviceModule.v2.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + 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('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.ICompleteQueryResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IImportCompletionDataResponse, + protos.google.cloud.retail.v2.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportCompletionDataProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + 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 completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_completion_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_completion_service_v2alpha.ts new file mode 100644 index 00000000000..81af904d155 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_completion_service_v2alpha.ts @@ -0,0 +1,1609 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as completionserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2alpha.CompletionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + completionserviceModule.v2alpha.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + completionserviceModule.v2alpha.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2alpha.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + 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('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.ICompleteQueryResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IImportCompletionDataResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportCompletionDataProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + 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 completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = + new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_completion_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_completion_service_v2beta.ts new file mode 100644 index 00000000000..8884b5a0ced --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_completion_service_v2beta.ts @@ -0,0 +1,1648 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as completionserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2beta.CompletionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + completionserviceModule.v2beta.CompletionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + completionserviceModule.v2beta.CompletionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = completionserviceModule.v2beta.CompletionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new completionserviceModule.v2beta.CompletionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.completionServiceStub, undefined); + await client.initialize(); + assert(client.completionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + assert(client.completionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.completionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + 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('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryResponse() + ); + client.innerApiCalls.completeQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.ICompleteQueryResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes completeQuery with closed client', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CompleteQueryRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CompleteQueryRequest', + ['catalog'] + ); + request.catalog = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('importCompletionData', () => { + it('invokes importCompletionData without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importCompletionData(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importCompletionData = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCompletionData( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IImportCompletionDataResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with call error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCompletionData with LRO error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportCompletionDataRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportCompletionDataRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCompletionData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportCompletionDataProgress without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportCompletionDataProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportCompletionDataProgress with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportCompletionDataProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + 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 completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_control_service_v2.ts b/packages/google-cloud-retail/test/gapic_control_service_v2.ts new file mode 100644 index 00000000000..743368fabf8 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_control_service_v2.ts @@ -0,0 +1,1993 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2.ControlServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + controlserviceModule.v2.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + controlserviceModule.v2.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + 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('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.createControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.updateControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.getControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.innerApiCalls.listControls = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IControl[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.descriptors.page.listControls.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Control) => { + 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.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Control) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + 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 controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_control_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_control_service_v2alpha.ts new file mode 100644 index 00000000000..9a8f29da17e --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_control_service_v2alpha.ts @@ -0,0 +1,2075 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2alpha.ControlServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + controlserviceModule.v2alpha.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + controlserviceModule.v2alpha.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2alpha.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + 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('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.createControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.updateControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Control() + ); + client.innerApiCalls.getControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.innerApiCalls.listControls = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IControl[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Control) => { + 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.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Control[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Control) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + 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 controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_control_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_control_service_v2beta.ts new file mode 100644 index 00000000000..97c5e698653 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_control_service_v2beta.ts @@ -0,0 +1,2075 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as controlserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2beta.ControlServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + controlserviceModule.v2beta.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + controlserviceModule.v2beta.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2beta.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + await client.initialize(); + assert(client.controlServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.controlServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.controlServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + 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('createControl', () => { + it('invokes createControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.createControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateControlRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createControl(request), expectedError); + }); + }); + + describe('deleteControl', () => { + it('invokes deleteControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteControl( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteControl(request), expectedError); + }); + }); + + describe('updateControl', () => { + it('invokes updateControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.updateControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateControlRequest', + ['control', 'name'] + ); + request.control.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateControl(request), expectedError); + }); + }); + + describe('getControl', () => { + it('invokes getControl without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Control() + ); + client.innerApiCalls.getControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IControl | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetControlRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getControl(request), expectedError); + }); + }); + + describe('listControls', () => { + it('invokes listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.innerApiCalls.listControls = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IControl[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listControls as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Control) => { + 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.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listControlsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Control[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Control) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listControls, request) + ); + assert( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + const iterable = client.listControlsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListControlsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListControlsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listControls.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listControlsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IControl[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listControls.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + 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 controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_model_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_model_service_v2alpha.ts new file mode 100644 index 00000000000..0152b44a329 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_model_service_v2alpha.ts @@ -0,0 +1,2494 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as modelserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ModelServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + modelserviceModule.v2alpha.ModelServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + modelserviceModule.v2alpha.ModelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = modelserviceModule.v2alpha.ModelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + await client.initialize(); + assert(client.modelServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.modelServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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('pauseModel', () => { + it('invokes pauseModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); + const [response] = await client.pauseModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.pauseModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.pauseModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseModel(request), expectedError); + }); + }); + + describe('resumeModel', () => { + it('invokes resumeModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); + const [response] = await client.resumeModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.resumeModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.resumeModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeModel(request), expectedError); + }); + }); + + describe('deleteModel', () => { + it('invokes deleteModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); + const [response] = await client.deleteModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteModel( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteModel(request), expectedError); + }); + }); + + describe('updateModel', () => { + it('invokes updateModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); + const [response] = await client.updateModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.updateModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateModel(request), expectedError); + }); + }); + + describe('createModel', () => { + it('invokes createModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.createModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createModel( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.ICreateModelMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with call error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with LRO error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateModelProgress without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateModelProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateModelProgress with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkCreateModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('tuneModel', () => { + it('invokes tuneModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.tuneModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.tuneModel( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.ITuneModelResponse, + protos.google.cloud.retail.v2alpha.ITuneModelMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with call error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.tuneModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with LRO error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.tuneModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTuneModelProgress without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTuneModelProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTuneModelProgress with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkTuneModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listModels', () => { + it('invokes listModels without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); + const [response] = await client.listModels(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.innerApiCalls.listModels = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listModels( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IModel[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listModels = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listModels(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModelsStream without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.descriptors.page.listModels.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Model[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Model) => { + 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.listModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listModels, request) + ); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listModelsStream with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Model[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Model) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listModels, request) + ); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.descriptors.page.listModels.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; + const iterable = client.listModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listModelsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_model_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_model_service_v2beta.ts new file mode 100644 index 00000000000..68cc5ecaa5e --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_model_service_v2beta.ts @@ -0,0 +1,2494 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as modelserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ModelServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + modelserviceModule.v2beta.ModelServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + modelserviceModule.v2beta.ModelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = modelserviceModule.v2beta.ModelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new modelserviceModule.v2beta.ModelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + await client.initialize(); + assert(client.modelServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.modelServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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('pauseModel', () => { + it('invokes pauseModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); + const [response] = await client.pauseModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.pauseModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.pauseModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PauseModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseModel(request), expectedError); + }); + }); + + describe('resumeModel', () => { + it('invokes resumeModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); + const [response] = await client.resumeModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.resumeModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.resumeModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ResumeModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeModel(request), expectedError); + }); + }); + + describe('deleteModel', () => { + it('invokes deleteModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); + const [response] = await client.deleteModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteModel( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteModel(request), expectedError); + }); + }); + + describe('updateModel', () => { + it('invokes updateModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); + const [response] = await client.updateModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.updateModel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateModel( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IModel | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateModel = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateModelRequest', + ['model', 'name'] + ); + request.model.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateModel(request), expectedError); + }); + }); + + describe('createModel', () => { + it('invokes createModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.createModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createModel( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.ICreateModelMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with call error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with LRO error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateModelRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateModelProgress without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateModelProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateModelProgress with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkCreateModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('tuneModel', () => { + it('invokes tuneModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.tuneModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.tuneModel( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.ITuneModelResponse, + protos.google.cloud.retail.v2beta.ITuneModelMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with call error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.tuneModel(request), expectedError); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with LRO error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.TuneModelRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.tuneModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.tuneModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTuneModelProgress without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTuneModelProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTuneModelProgress with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkTuneModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listModels', () => { + it('invokes listModels without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); + const [response] = await client.listModels(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.innerApiCalls.listModels = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listModels( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IModel[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listModels = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listModels(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModelsStream without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.descriptors.page.listModels.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Model[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Model) => { + 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.listModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listModels, request) + ); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listModelsStream with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Model[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Model) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listModels, request) + ); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.descriptors.page.listModels.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IModel[] = []; + const iterable = client.listModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListModelsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listModelsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IModel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_prediction_service_v2.ts b/packages/google-cloud-retail/test/gapic_prediction_service_v2.ts new file mode 100644 index 00000000000..6b9559a4537 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_prediction_service_v2.ts @@ -0,0 +1,1259 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2.PredictionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + predictionserviceModule.v2.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + predictionserviceModule.v2.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + 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('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictResponse() + ); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictResponse() + ); + client.innerApiCalls.predict = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IPredictResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + 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 predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_prediction_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_prediction_service_v2alpha.ts new file mode 100644 index 00000000000..d2eadb2f26e --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_prediction_service_v2alpha.ts @@ -0,0 +1,1369 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2alpha.PredictionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + predictionserviceModule.v2alpha.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + predictionserviceModule.v2alpha.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2alpha.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + 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('predict', () => { + it('invokes predict without error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictResponse() + ); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict without error using callback', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictResponse() + ); + client.innerApiCalls.predict = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IPredictResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with closed client', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + 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 predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = + new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_prediction_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_prediction_service_v2beta.ts new file mode 100644 index 00000000000..c66a4dd8a47 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_prediction_service_v2beta.ts @@ -0,0 +1,1402 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as predictionserviceModule from '../src'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2beta.PredictionServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + predictionserviceModule.v2beta.PredictionServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + predictionserviceModule.v2beta.PredictionServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = predictionserviceModule.v2beta.PredictionServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new predictionserviceModule.v2beta.PredictionServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + fallback: true, + } + ); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.predictionServiceStub, undefined); + await client.initialize(); + assert(client.predictionServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + assert(client.predictionServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.predictionServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + 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('predict', () => { + it('invokes predict without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictResponse() + ); + client.innerApiCalls.predict = stubSimpleCall(expectedResponse); + const [response] = await client.predict(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictResponse() + ); + client.innerApiCalls.predict = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.predict( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IPredictResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes predict with closed client', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PredictRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PredictRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + 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 predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_product_service_v2.ts b/packages/google-cloud-retail/test/gapic_product_service_v2.ts new file mode 100644 index 00000000000..ca7e4f8f11f --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_product_service_v2.ts @@ -0,0 +1,3277 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.ProductServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + productserviceModule.v2.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + productserviceModule.v2.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + 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('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.createProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.getProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Product() + ); + client.innerApiCalls.updateProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IImportProductsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportProductsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.ISetInventoryResponse, + protos.google.cloud.retail.v2.ISetInventoryMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IAddFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2.IRemoveFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeFulfillmentPlaces(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkRemoveFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2.IAddLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2.IRemoveLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeLocalInventories(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.innerApiCalls.listProducts = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IProduct[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + 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.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Product[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Product) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + 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 productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_product_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_product_service_v2alpha.ts new file mode 100644 index 00000000000..d5069580f7d --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_product_service_v2alpha.ts @@ -0,0 +1,3553 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ProductServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + productserviceModule.v2alpha.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + productserviceModule.v2alpha.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2alpha.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + 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('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.createProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.getProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Product() + ); + client.innerApiCalls.updateProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('purgeProducts', () => { + it('invokes purgeProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = + stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IPurgeProductsResponse, + protos.google.cloud.retail.v2alpha.IPurgeProductsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeProductsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPurgeProductsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IImportProductsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportProductsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.ISetInventoryResponse, + protos.google.cloud.retail.v2alpha.ISetInventoryMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IAddFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2alpha.IRemoveFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeFulfillmentPlaces(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkRemoveFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IAddLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2alpha.IRemoveLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeLocalInventories(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.innerApiCalls.listProducts = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IProduct[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Product) => { + 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.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.Product) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + 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 productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_product_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_product_service_v2beta.ts new file mode 100644 index 00000000000..660a9af5ab2 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_product_service_v2beta.ts @@ -0,0 +1,3359 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as productserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ProductServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + productserviceModule.v2beta.ProductServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + productserviceModule.v2beta.ProductServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = productserviceModule.v2beta.ProductServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new productserviceModule.v2beta.ProductServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + await client.initialize(); + assert(client.productServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.productServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.productServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + 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('createProduct', () => { + it('invokes createProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); + const [response] = await client.createProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.createProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.getProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); + const [response] = await client.updateProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Product() + ); + client.innerApiCalls.updateProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IProduct | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateProductRequest() + ); + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('importProducts', () => { + it('invokes importProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importProducts = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importProducts( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IImportProductsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importProducts with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportProductsProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportProductsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportProductsProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportProductsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('setInventory', () => { + it('invokes setInventory without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = stubLongRunningCall(expectedResponse); + const [operation] = await client.setInventory(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setInventory = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setInventory( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.ISetInventoryResponse, + protos.google.cloud.retail.v2beta.ISetInventoryMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setInventory with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SetInventoryRequest() + ); + request.inventory ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SetInventoryRequest', + ['inventory', 'name'] + ); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setInventory as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetInventoryProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSetInventoryProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetInventoryProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkSetInventoryProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addFulfillmentPlaces', () => { + it('invokes addFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IAddFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeFulfillmentPlaces', () => { + it('invokes removeFulfillmentPlaces without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeFulfillmentPlaces(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeFulfillmentPlaces = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeFulfillmentPlaces( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesResponse, + protos.google.cloud.retail.v2beta.IRemoveFulfillmentPlacesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeFulfillmentPlaces(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeFulfillmentPlaces with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeFulfillmentPlaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkRemoveFulfillmentPlacesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveFulfillmentPlacesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveFulfillmentPlacesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addLocalInventories', () => { + it('invokes addLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.addLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.addLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IAddLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IAddLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkAddLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkAddLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkAddLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removeLocalInventories', () => { + it('invokes removeLocalInventories without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removeLocalInventories(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.removeLocalInventories = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeLocalInventories( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesResponse, + protos.google.cloud.retail.v2beta.IRemoveLocalInventoriesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with call error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.removeLocalInventories(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeLocalInventories with LRO error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', + ['product'] + ); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeLocalInventories as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRemoveLocalInventoriesProgress without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemoveLocalInventoriesProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRemoveLocalInventoriesProgress with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRemoveLocalInventoriesProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.innerApiCalls.listProducts = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IProduct[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Product) => { + 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.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.Product) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request) + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Product()), + ]; + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + 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 productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_search_service_v2.ts b/packages/google-cloud-retail/test/gapic_search_service_v2.ts new file mode 100644 index 00000000000..4de050e5d16 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_search_service_v2.ts @@ -0,0 +1,1582 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2.SearchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + searchserviceModule.v2.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + searchserviceModule.v2.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + 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('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2.SearchResponse.SearchResult + ) => { + 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.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2.SearchResponse.SearchResult + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = + []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.SearchResponse.ISearchResult[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + 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 searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_search_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_search_service_v2alpha.ts new file mode 100644 index 00000000000..950a2d19973 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_search_service_v2alpha.ts @@ -0,0 +1,1658 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2alpha.SearchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + searchserviceModule.v2alpha.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + searchserviceModule.v2alpha.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2alpha.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + 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('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult + ) => { + 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.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = + []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.SearchResponse.ISearchResult[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + 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 searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_search_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_search_service_v2beta.ts new file mode 100644 index 00000000000..478f1e4a2e5 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_search_service_v2beta.ts @@ -0,0 +1,1658 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as searchserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2beta.SearchServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + searchserviceModule.v2beta.SearchServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + searchserviceModule.v2beta.SearchServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = searchserviceModule.v2beta.SearchServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + await client.initialize(); + assert(client.searchServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.searchServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.searchServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + 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('search', () => { + it('invokes search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = stubSimpleCall(expectedResponse); + const [response] = await client.search(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + ]; + client.innerApiCalls.search = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.search( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.search as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchStream without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult + ) => { + 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.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchStream with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.searchStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.retail.v2beta.SearchResponse.SearchResult + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.search, request) + ); + assert( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchResponse.SearchResult() + ), + ]; + client.descriptors.page.search.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = + []; + const iterable = client.searchAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with search with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.SearchRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.SearchRequest', + ['placement'] + ); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.search.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.searchAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.SearchResponse.ISearchResult[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.search.asyncIterate as SinonStub).getCall(0) + .args[1], + request + ); + assert( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + 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 searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('branch', () => { + const fakePath = '/rendered/path/branch'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.branchPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.branchPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('branchPath', () => { + const result = client.branchPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.branchPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBranchName', () => { + const result = client.matchProjectFromBranchName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromBranchName', () => { + const result = client.matchLocationFromBranchName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromBranchName', () => { + const result = client.matchCatalogFromBranchName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromBranchName', () => { + const result = client.matchBranchFromBranchName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.branchPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_serving_config_service_v2.ts b/packages/google-cloud-retail/test/gapic_serving_config_service_v2.ts new file mode 100644 index 00000000000..346b6342ef0 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_serving_config_service_v2.ts @@ -0,0 +1,2346 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2.ServingConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + servingconfigserviceModule.v2.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + servingconfigserviceModule.v2.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + servingconfigserviceModule.v2.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.getServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.addControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.removeControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IServingConfig[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.ServingConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2.ServingConfig) => { + 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.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.ServingConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2.ServingConfig) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.IServingConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = + new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_serving_config_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_serving_config_service_v2alpha.ts new file mode 100644 index 00000000000..774f8047da0 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_serving_config_service_v2alpha.ts @@ -0,0 +1,2428 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2alpha.ServingConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + servingconfigserviceModule.v2alpha.ServingConfigServiceClient + .servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + servingconfigserviceModule.v2alpha.ServingConfigServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + servingconfigserviceModule.v2alpha.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.getServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.addControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ); + client.innerApiCalls.removeControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IServingConfig[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + 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.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.ServingConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2alpha.ServingConfig) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IServingConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = + new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_serving_config_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_serving_config_service_v2beta.ts new file mode 100644 index 00000000000..6118920ca29 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_serving_config_service_v2beta.ts @@ -0,0 +1,2426 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as servingconfigserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function 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('v2beta.ServingConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + servingconfigserviceModule.v2beta.ServingConfigServiceClient + .servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + servingconfigserviceModule.v2beta.ServingConfigServiceClient + .apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + servingconfigserviceModule.v2beta.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + await client.initialize(); + assert(client.servingConfigServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.servingConfigServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.servingConfigServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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('createServingConfig', () => { + it('invokes createServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.createServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CreateServingConfigRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createServingConfig(request), expectedError); + }); + }); + + describe('deleteServingConfig', () => { + it('invokes deleteServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.DeleteServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteServingConfig(request), expectedError); + }); + }); + + describe('updateServingConfig', () => { + it('invokes updateServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.UpdateServingConfigRequest', + ['servingConfig', 'name'] + ); + request.servingConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateServingConfig(request), expectedError); + }); + }); + + describe('getServingConfig', () => { + it('invokes getServingConfig without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.getServingConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getServingConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetServingConfigRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.GetServingConfigRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getServingConfig(request), expectedError); + }); + }); + + describe('addControl', () => { + it('invokes addControl without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.addControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.AddControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.AddControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.addControl(request), expectedError); + }); + }); + + describe('removeControl', () => { + it('invokes removeControl without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ); + client.innerApiCalls.removeControl = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeControl as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with closed client', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RemoveControlRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RemoveControlRequest', + ['servingConfig'] + ); + request.servingConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeControl(request), expectedError); + }); + }); + + describe('listServingConfigs', () => { + it('invokes listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + ]; + client.innerApiCalls.listServingConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IServingConfig[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServingConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + 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.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listServingConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.ServingConfig[] = []; + stream.on( + 'data', + (response: protos.google.cloud.retail.v2beta.ServingConfig) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listServingConfigs, request) + ); + assert( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + generateSampleMessage( + new protos.google.cloud.retail.v2beta.ServingConfig() + ), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = []; + const iterable = client.listServingConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListServingConfigsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ListServingConfigsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listServingConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServingConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IServingConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listServingConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + 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 servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = + new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_user_event_service_v2.ts b/packages/google-cloud-retail/test/gapic_user_event_service_v2.ts new file mode 100644 index 00000000000..7c64b40f5ae --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_user_event_service_v2.ts @@ -0,0 +1,2008 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as usereventserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2.UserEventServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + usereventserviceModule.v2.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + usereventserviceModule.v2.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + 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('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.UserEvent() + ); + client.innerApiCalls.writeUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2.IUserEvent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error | null, result?: protos.google.api.IHttpBody | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2.IPurgeMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPurgeUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IImportUserEventsResponse, + protos.google.cloud.retail.v2.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2.IRejoinUserEventsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRejoinUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + 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 usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_user_event_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_user_event_service_v2alpha.ts new file mode 100644 index 00000000000..7ed133b4807 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_user_event_service_v2alpha.ts @@ -0,0 +1,2085 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as usereventserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2alpha.UserEventServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + usereventserviceModule.v2alpha.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + usereventserviceModule.v2alpha.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2alpha.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new usereventserviceModule.v2alpha.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + 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('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UserEvent() + ); + client.innerApiCalls.writeUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2alpha.IUserEvent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error | null, result?: protos.google.api.IHttpBody | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2alpha.IPurgeMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPurgeUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IImportUserEventsResponse, + protos.google.cloud.retail.v2alpha.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2alpha.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2alpha.IRejoinUserEventsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2alpha.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRejoinUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + 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 usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/test/gapic_user_event_service_v2beta.ts b/packages/google-cloud-retail/test/gapic_user_event_service_v2beta.ts new file mode 100644 index 00000000000..fce1c1fb696 --- /dev/null +++ b/packages/google-cloud-retail/test/gapic_user_event_service_v2beta.ts @@ -0,0 +1,2084 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as usereventserviceModule from '../src'; + +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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('v2beta.UserEventServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + usereventserviceModule.v2beta.UserEventServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + usereventserviceModule.v2beta.UserEventServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = usereventserviceModule.v2beta.UserEventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + await client.initialize(); + assert(client.userEventServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.userEventServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.userEventServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + 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('writeUserEvent', () => { + it('invokes writeUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UserEvent() + ); + client.innerApiCalls.writeUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.writeUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UserEvent() + ); + client.innerApiCalls.writeUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.writeUserEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.retail.v2beta.IUserEvent | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes writeUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.WriteUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.WriteUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.writeUserEvent(request), expectedError); + }); + }); + + describe('collectUserEvent', () => { + it('invokes collectUserEvent without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.collectUserEvent( + request, + (err?: Error | null, result?: protos.google.api.IHttpBody | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.collectUserEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes collectUserEvent with closed client', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CollectUserEventRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.CollectUserEventRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.collectUserEvent(request), expectedError); + }); + }); + + describe('purgeUserEvents', () => { + it('invokes purgeUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IPurgeUserEventsResponse, + protos.google.cloud.retail.v2beta.IPurgeMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PurgeUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.PurgeUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPurgeUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPurgeUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPurgeUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importUserEvents', () => { + it('invokes importUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.importUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IImportUserEventsResponse, + protos.google.cloud.retail.v2beta.IImportMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ImportUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.ImportUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkImportUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('rejoinUserEvents', () => { + it('invokes rejoinUserEvents without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCall(expectedResponse); + const [operation] = await client.rejoinUserEvents(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.rejoinUserEvents = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rejoinUserEvents( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.retail.v2beta.IRejoinUserEventsResponse, + protos.google.cloud.retail.v2beta.IRejoinUserEventsMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with call error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rejoinUserEvents with LRO error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.RejoinUserEventsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.retail.v2beta.RejoinUserEventsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rejoinUserEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkRejoinUserEventsProgress without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRejoinUserEventsProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRejoinUserEventsProgress with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkRejoinUserEventsProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + 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 usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('attributesConfig', () => { + const fakePath = '/rendered/path/attributesConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.attributesConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attributesConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attributesConfigPath', () => { + const result = client.attributesConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attributesConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAttributesConfigName', () => { + const result = client.matchProjectFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromAttributesConfigName', () => { + const result = client.matchLocationFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromAttributesConfigName', () => { + const result = client.matchCatalogFromAttributesConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.attributesConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('catalog', () => { + const fakePath = '/rendered/path/catalog'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.catalogPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.catalogPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('catalogPath', () => { + const result = client.catalogPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.catalogPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCatalogName', () => { + const result = client.matchProjectFromCatalogName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCatalogName', () => { + const result = client.matchLocationFromCatalogName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCatalogName', () => { + const result = client.matchCatalogFromCatalogName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.catalogPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('completionConfig', () => { + const fakePath = '/rendered/path/completionConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.completionConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.completionConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('completionConfigPath', () => { + const result = client.completionConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue' + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.completionConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCompletionConfigName', () => { + const result = client.matchProjectFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCompletionConfigName', () => { + const result = client.matchLocationFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromCompletionConfigName', () => { + const result = client.matchCatalogFromCompletionConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.completionConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('control', () => { + const fakePath = '/rendered/path/control'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + control: 'controlValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.controlPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.controlPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('controlPath', () => { + const result = client.controlPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'controlValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.controlPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromControlName', () => { + const result = client.matchProjectFromControlName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromControlName', () => { + const result = client.matchLocationFromControlName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromControlName', () => { + const result = client.matchCatalogFromControlName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchControlFromControlName', () => { + const result = client.matchControlFromControlName(fakePath); + assert.strictEqual(result, 'controlValue'); + assert( + (client.pathTemplates.controlPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('model', () => { + const fakePath = '/rendered/path/model'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + model: 'modelValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.modelPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'modelValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, 'modelValue'); + assert( + (client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('product', () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + branch: 'branchValue', + product: 'productValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'branchValue', + 'productValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromProductName', () => { + const result = client.matchCatalogFromProductName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBranchFromProductName', () => { + const result = client.matchBranchFromProductName(fakePath); + assert.strictEqual(result, 'branchValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('servingConfig', () => { + const fakePath = '/rendered/path/servingConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + catalog: 'catalogValue', + serving_config: 'servingConfigValue', + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.servingConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.servingConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('servingConfigPath', () => { + const result = client.servingConfigPath( + 'projectValue', + 'locationValue', + 'catalogValue', + 'servingConfigValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.servingConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromServingConfigName', () => { + const result = client.matchProjectFromServingConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromServingConfigName', () => { + const result = client.matchLocationFromServingConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCatalogFromServingConfigName', () => { + const result = client.matchCatalogFromServingConfigName(fakePath); + assert.strictEqual(result, 'catalogValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchServingConfigFromServingConfigName', () => { + const result = client.matchServingConfigFromServingConfigName(fakePath); + assert.strictEqual(result, 'servingConfigValue'); + assert( + (client.pathTemplates.servingConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-retail/tsconfig.json b/packages/google-cloud-retail/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/packages/google-cloud-retail/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/packages/google-cloud-retail/webpack.config.js b/packages/google-cloud-retail/webpack.config.js new file mode 100644 index 00000000000..4ac1ab4448f --- /dev/null +++ b/packages/google-cloud-retail/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: 'CatalogService', + filename: './catalog-service.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 1cea325e26b..ba8c7119f5e 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -83,6 +83,7 @@ "packages/google-cloud-redis": {}, "packages/google-cloud-resourcemanager": {}, "packages/google-cloud-resourcesettings": {}, + "packages/google-cloud-retail": {}, "packages/google-cloud-scheduler": {}, "packages/google-cloud-secretmanager": {}, "packages/google-cloud-security-privateca": {}, @@ -122,4 +123,4 @@ } ], "release-type": "node" -} \ No newline at end of file +}